⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 go.c

📁 dos下pos机程序 连接sybase数据库 使用Microsoft c7 编译
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
  前台收银程序作图函数库
  本函数不调用C的图形函数,而直接采用操作显示卡的方法,从而可以减少内存
  的占用量和提高显示速度

                重庆运通资讯科技有限公司 蓝仕红 2000年11月
*/
#include <dos.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <bios.h>
#include <math.h>
#include <malloc.h>
#include <io.h>
#include <fcntl.h>
#include <stdarg.h>
#include <user.h>
#include <time.h>
#include <graphfun.h>
#include <publ.h>
#include "fujistu.h"
#include "conscard.h" //added by lyy,2005,March


const int XOR_PUT = 0x18;  // 异或
const int COPY_PUT = 0x0;  // 复制

union REGS reg;         // DOS中断调用参数
struct SREGS sreg;

/*参数结构*/
TOption Param;

/*商品信息全局变量*/
extern _SPStruct OrigSP;      //工作缓冲区,用于存储当前商品数据
extern _SPLists *SPLists;    //指向本次销售数据的指针
extern _SPLists __SPLists[]; //__SPLists[1],每个职员同一时间只销售一笔交易
extern short __WorkCount;     //__WorkCount=1; 工作区数
extern short _SPListCount;      //当前挂起的笔数
extern char __LoginUser[];
extern char g_gz_mode[];         //工作方式
extern char g_gz_modeex[];
extern char g_cashcode[];     //管理员密码
extern char g_xyksy[];

extern char g_server_thk[];
extern char g_customer[];
extern char g_bc[];
extern char g_now[];         //时间
extern int g_lsh;            //流水号
extern int g_xsbs;           //销售笔数
extern int g_jycs;
extern int g_dyys;
extern char g_dyysstr[];
extern double g_flhj[5];      //付款方式数组
extern char __Preview[230][75];//缓冲区
extern char p_Formats[31][61];
extern char Yyy_No[];
extern char _jxc_xsdb[];     // 提交表
extern short __syfs;          // 收银方式

extern int _hour, _minute, _second;
extern long __prostart, __pronow;
extern short __guxianmark;
extern short __sqlerrormark;           // 错误标记
extern int sql_yhk(YHK *rec);
extern int sql_thk(THK *rec);
extern void sql_thkclose(void);
extern void Sleep(clock_t nDelay);
extern void Reset(_SPLists *lp);
extern void ResetFK(_FKStruct *fklp);
extern int sql_tm(_SPStruct *CurrSP, int Att);
extern int TiJiaoPingZheng(void);
extern int sql_xspz(char *_bc, int _lsh);
extern int sql_xshz(void);
extern void dysyt(int MaxLines);
extern void wsyt(int MaxLines);
extern void fun_wtjsp(void);
extern void dyfile(char *FileName, char *afxStr);
extern void SetPrintFormat(void);
extern int sql_changpw(char *PW);
//extern int jieguafie(void);

//lijing
extern void dyPrompt(char *prompt);
int InputXYK(int sx, int sy, int ex, int ey, double fkje);
int ShowTiHuoKaEx(THK *lpThk);
extern int GetFreeXYK(void);
extern void QueryTHK(char *skh);
extern int CheckLysp(void);
extern void OpenAllDataSet(void);
extern int GetDataFromServer(const char *TableName, const char *sTableName, char *Where, int Att);
extern void sql_TransData(char *Data, char *FileName, char *dtime, char *xh);
extern void TranDataToServer(void);
extern void GetDec(char *value, double dec, int ws, int Att);
extern void SleepEx(clock_t nDelay);
extern void card(char *argv_1, char *argv_2, char *argv_3, char *argv_4);
extern int sql_gzrq(void);
extern int sql_lsdh(void);

double tempsl;
CARDOUT xyk_fhxx;//zh

//zh
//int g_hyxf=0;//会员消费标志
//
//错误信息常数
char *ErrorMsg[3] =
{
    "", "当前交易无销售记录,不需要挂起.",   //1
    "最多只能挂起8笔交易"
};             //2
short __clockmark = 0, __cursormark = 0;
void __ShowTime(void);
void OpenCurSor(TEdit *Edit);
long __guxianmarks = 0;
extern short __sqlok;
extern short __WorkBuffer;         //可以挂起的笔数
extern _GQStruct __GQList[5];        //挂起工作区
extern XYKLB _XykLb[20];

TEdit *__CurEdit;
/* -------------------键盘输入处理函数----------------------*/
//把一个输入放入消息缓冲区
void InBuffer(int type, unsigned RetKey, int x, int y)
{
    if ((CountS + 1) % 32 == CountE)
    {
        return;
    }    //缓冲区满,退出
    MSG[CountS].type = type;
    MSG[CountS].h.RetKey = RetKey;
    MSG[CountS].x = x;
    MSG[CountS++].y = y;
    CountS %= 32;
}

//获得键盘输入
unsigned GetInt16(void)
{
    reg.x.ax = 0;
    int86x(0x16, &reg, &reg, &sreg);
    return reg.x.ax;
}

//获得输入
void GetInput(void)
{
    long k, s, e;
    s = clock();
    while (1)
    {
        if (CountS != CountE)
        {
            break;
        }                    //缓冲区满
        if (_bios_keybrd(1))                           //键盘消息
        {
            GetInt16();
            if (reg.h.al == 0)
            {
                InBuffer(-2, reg.x.ax, 0, 0);
            }                //是功能键
            else
            {
                if (reg.h.ah == 0)                          //是汉字内码
                    //InBuffer(-3,reg.x.ax,0,0);
                {
                    InBuffer(0, reg.x.ax, 0, 0);
                }
                else if (reg.h.al < 0x20)
                {
                    InBuffer(-1, reg.x.ax, 0, 0);
                }         //是控制键
                else
                {
                    InBuffer(0, reg.x.ax, 0, 0);
                }          //是ASCII码
            }
            break;
        }                              //鼠标消息
        __pronow = clock();
        e = __pronow;
        if (e - s > 150)
        {
            s = e;
            if (__cursormark)
            {
                OpenCurSor(__CurEdit);
            }
        }
        k = __pronow - __prostart;
        k = k / (CLK_TCK - 11);                            //相差
        if (k)                                        //超过1
        {
            if (__guxianmarks)
            {
                __guxianmarks++;
            }           //秒数加1
            __prostart = __pronow;
            _second += (int)k;
            _minute += _second / 60;
            _second = _second % 60;
            _hour += _minute / 60;
            _minute = _minute % 60;
            _hour = _hour % 24;
            __ShowTime();
        }
    }
}

//获取一个消息
Msg * Getkey(void)
{
    short Temp;
    if (CountS == CountE)
    {
        GetInput();
    }
    Temp = CountE++;
    CountE %= 32;
    return &(MSG[Temp]);
}

//检查是否有消息
int BiosKey(void)
{
    return(_bios_keybrd(_KEYBRD_READY) || CountS != CountE);
}
//清除消息缓冲区
void ClearKey(void)
{
    while (_bios_keybrd(_KEYBRD_READY))
    {
        GetInt16();
    }
    CountS = CountE = 0;
}
/*                       第一:设置图形模式函数系列                  */

//设置图形模式
void InitGraph(int INT10)
{
    reg.x.ax = INT10;
    int86x(0x10, &reg, &reg, &sreg); //调用中断
}

//关闭屏幕显示
void CloseScr(void)
{
    _asm
    {
        mov   dx,0x3c4
        mov   al,1
        out   dx,al
        mov   dx,0x3c5
        in    al,dx
        or    al,0x20
        mov   dx,0x3c5
        out   dx,al
    }
}

//打开屏幕显示
void OpenScr(void)
{
    _asm
    {
        mov   dx,0x3c4
        mov   al,1
        out   dx,al
        mov   dx,0x3c5
        in    al,dx
        and   al,0xdf
        mov   dx,0x3c5
        out   dx,al
    }
}

/*                        第二部分:作图函数                       */
/*往显示缓冲区中填写数据
  LC-颜色
  LW-线宽
  WMODE-模式
  LS-线类型
*/
void Line0(int sx, int sy, int ex, unsigned char LC, int LW, int WMODE, unsigned char LS)
{
    int lsx, lex, lst, let;
    unsigned char n1,n2;
    int Off;
    _asm
    {
        mov  ax,ex
        mov  bx,sx
        cmp  ax,bx
        //    jl   RETU
        mov  ax,sx
        and  ax,7
        mov  lsx,ax
        mov  ax,sx
        mov  cl,3
        shr  ax,cl
        mov  lst,ax
        mov  ax,ex
        and  ax,7
        mov  lex,ax
        mov  ax,ex
        mov  cl,3
        shr  ax,cl
        mov  let,ax
        mov  ax,sy
        mov  cl,6
        shl  ax,cl
        mov  bx,ax
        mov  ax,sy
        mov  cl,4
        shl  ax,cl
        add  ax,bx
        mov  Off,ax
        mov  dx,0x3ce
        mov  al,0
        out  dx,al
        mov  dx,0x3cf
        mov  al,LC
        out  dx,al
        mov  dx,0x3ce
        mov  al,1
        out  dx,al
        mov  dx,0x3cf
        mov  al,0xff
        out  dx,al
        mov  dx,0x3ce
        mov  al,3
        out  dx,al
        mov  dx,0x3cf
        mov  ax,WMODE
        out  dx,al
        mov  dx,0x3c4
        mov  al,2
        out  dx,al
        // outportb(0x3c4,2)
        mov  dx,0x3c5
        mov  al,0xff
        out  dx,al
        // outportb(0x3c5,0xff)
        mov  ax,let
        cmp  ax,lst
        jnz  CONT
        jmp  NEXT
    }
    CONT:
    _asm
    {
        xor ax,ax
        mov  al,0xff         //      if(let!=lst)
        mov  cx,lsx          //      {
        shr  al,cl           //      n1=m>>lsx
        mov  bl,LS
        xor  bh,bh
        and  ax,bx           //      n1=n1&LineStyle,
        mov  n1,al
        mov  al,0xff         //      n2=m<<(7-lex)
        mov  cx,7
        sub  cx,lex
        shl  al,cl
        and  ax,bx
        mov  n2,al           //      n2=n2&LineStyle
        //
        mov  dx,0x3ce
        mov  al,8
        out  dx,al           //      outportb(0x3ce,8)
        mov  dx,0x3cf
        mov  al,n1
        out  dx,al           //      outportb(0x3cf,n1)
        mov  bx,Off
        add  bx,lst          //       k=OFF+lst
        mov  cx,LW
        mov  ax,0xa000       //      for(j=0;j<n;j++)
        mov  es,ax           //      { c=peekb(SEG,k)
        mov  si,bx
    }           //        pokeb(SEG,k,c)
    CONT1:
    _asm
    {
        mov  al,es:[si]      //        k+=80  }
        mov  es:[si],al
        add  si,80
        loop CONT1
        //
        mov  dx,0x3ce         //       outportb(0x3ce,8)
        mov  al,8
        out  dx,al
        mov  dx,0x3cf        //      outportb(0x3cf,n2)
        mov  al,n2
        out  dx,al
        mov  bx,Off          //      k=OFF+let
        add  bx,let
        mov  si,bx
        mov  ax,0xa000       //      for(j=0;j<n;j++)
        mov  es,ax
        mov  cx,LW
    }
    CONT2:
    _asm
    {
        mov  al,es:[si]      //      { c=peekb(SEG,k)
        mov  es:[si],al      //        pokeb(SEG,k,c)
        add  si,80           //        k+=80   }
        loop CONT2
        mov  dx,0x3ce         //      outportb(0x3ce,8)
        mov  al,8
        out  dx,al
        mov  dx,0x3cf
        mov  al,LS           //      outportb(0x3cf,LineStyle)
        out  dx,al
        mov  bx,Off          //      r=OFF+lst
        add  bx,lst
        mov  di,LW           //      for(j=0;j<n;j++)
        mov  dx,let
        sub  dx,lst
        dec  dx
        mov  ax,0xa000
        mov  es,ax
    }
    CONT3:
    _asm
    {
        mov  si,bx           //      k=r
        mov  cx,dx
    }         //       for(i=1;i<let-lst;i++)
    CONT4:
    _asm
    {
        cmp  cx,0
        jz   CONT6
        inc  si
        mov  al,es:[si]      //        c=peekb(SEG,k)
        mov  es:[si],al      //       pokeb(SEG,k,c)  }
        dec  cx
        jmp  CONT4
    }
    CONT6:
    _asm
    {
        add  bx,80
        dec  di
        jnz  CONT3
        jmp  EXIT
    }                //
    NEXT:
    _asm
    {
        mov  bx,7       //      else {
        sub  bx,lex          //      n1=m<<lsx
        mov  dx,bx
        add  bx,lsx          //      n1=n1>>(7-lex+lsx)
        mov  al,0xff
        mov  cx,lsx
        shl  al,cl
        mov  cx,bx
        shr  al,cl
        mov  cx,dx           //      n1=n1<<(7-lex)
        shl  al,cl
        mov  cl,LS           //      n1=n1&LineStyle
        xor  ch,ch
        and  al,cl
        mov  n1,al
        mov  dx,0x3ce         //      outportb(0x3ce,8)
        mov  al,8
        out  dx,al
        mov  dx,0x3cf         //      outportb(0x3cf,n1)
        mov  al,n1
        out  dx,al
        mov  bx,Off          //      k=OFF+lst
        add  bx,lst
        mov  ax,0xa000
        mov  es,ax
        mov  cx,LW
    }          //      for(j=0;j<n;j++)
    CONT5:
    _asm
    {
        mov  al,es:[bx]      //      { c=peekb(SEG,k)
        mov  es:[bx],al      //      pokeb(SEG,k,c)
        add  bx,80           //      k+=80
        loop CONT5
    }
    EXIT:
    _asm
    {
        mov  dx,0x3ce         //       outportb(0x3ce,3)
        mov  al,3
        out  dx,al
        mov  dx,0x3cf
        mov  al,0
        out  dx,al           //        outportb(0x3cf,0)
        mov  dx,0x3ce
        mov  al,8
        out  dx,al           //       outportb(0x3ce,8)
        mov  dx,0x3cf
        mov  al,0xff
        out  dx,al           //       outportb(0x3cf,0xff)
        mov  ax,0
        nop
    }
}

/*画一条直线*/
//sx,sy-直线的起点 ex,ey-直线的终点

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -