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

📄 datam.c

📁 dos下pos机程序 连接sybase数据库 使用Microsoft c7 编译
💻 C
📖 第 1 页 / 共 2 页
字号:
/*           前台收银程序数据处理单元           */
#include <dos.h>
#include <bios.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <math.h>
#include <fcntl.h>
#include <stdarg.h>
#include <memory.h>
#include <time.h>
#include <user.h>
#include <publ.h>

//fst
#include "fujistu.h"
#include "direct.h"


/* -------------------键盘输入处理函数----------------------*/
//把一个输入放入消息缓冲区
extern int MsgBoxEx(char *, int);
//
extern void InBuffer(int type, unsigned RetKey, int x, int y);
extern int sql_tm(_SPStruct *CurrSP, int Att);
extern int sql_insertspb(_SPStruct *rec, int lsh, char *time, char *fkfs, double bx,char *ccardNo);
extern void dbf_insertspb(_SPStruct *rec, int lsh, char *time, char *fkfs, double bx);
extern int sql_insertwqrb(_SPStruct *rec, int lsh, char *time, char *fkfs, double bx);
extern int sql_insertyhk(YHK *yptr, char *time, double sps, double ysje, double ssje);
extern int sql_insertthk(THK *yptr, char *time, double sps, double ysje, double ssje);
extern int sql_insertxyk(char *km, char *kh, char *time, double je);
extern int sql_begin(void);
extern int sql_commit(void);
extern int sql_rollback(void);
extern int uf_strmid(char *dest, char *sour, int from, int count);
extern int uf_strmidEx(char *dest, char *sour);
extern int uf_strfcat(char *dest, char *sour);
extern int sql_yhk(YHK *rec);
extern int sql_thk(THK *rec);
extern void sql_thkclose(void);
extern int sql_checkthk(char *kh);
extern int InPutPassWord(char *PW);
extern int ShowTiHuoKa(THK *lpThk);//显示提货卡
extern int TiJiaoQueRen(int MaxLines, int Att);//显示销售凭证
extern int sql_xspz(char *_bc, int _lsh);
extern void DrawText(int x, int y, char *String, unsigned char Co, int MaxLine);
extern void __process(char *sour);
extern int sql_xykxx(void);
extern char Syy_Name[];

//lijing
extern TOption Param;
extern char g_customer[];
extern char g_VIPsw[];
extern char g_VIPyhl[];
extern int ShowTiHuoKaEx(THK *lpThk);
extern void ShowSyInf(void);
extern void rdxykfh(void);
extern int sql_insertgq(int xh, int gqbs, double ysje, double ssje);
extern int sql_removegq(int xh, int gqbs, double ysje, double ssje);
extern double uf_round(double num, double dig);
void Reset(_SPLists *lp);
void TaxLogStart(char *taxCmd);
void TaxLogEnd(void);

void prtccard(void);//lyy,2005,March

//extern int g_hyxf;
//定义全局数据结构

//当前商品数据结构指针
_SPStruct OrigSP;             //工作缓冲区

//商品销售数据集
_SPLists *SPLists;
short __WorkCount = 1;          //工作区数
short __WorkBuffer = 8;         //可以挂起的笔数
_GQStruct __GQList[8];        //挂起工作区

_SPLists __SPLists[1];       //每个职员当前只操作一笔销售交易
short _SPListCount = 0;         //当前挂起的笔数
short __guxianmark = 0;
char __Preview[230][75];

//打印格式参数
int _nFormat = 0;
int _nFormatx = 0;
char p_Formats[31][61];
short _PortType = 2;            //打印端口类型
int _nFeedLine = 5;           //走纸行数
char _pFeedLine[65];
int _xsdws = 0;
int _spmcws = 15;
char _SpSplb[6][9] =
{
    "", "", "", "", "", ""
};

extern char g_now[11];       //时间
extern int g_lsh;            //流水号
extern int g_xsbs;           //销售笔数
extern int g_jycs;
extern double g_flhj[5];      //付款方式数组
extern char g_pos[];          //收银机类型
extern char g_scmc[];
extern char Syy_No[];
extern char g_bc[];           //班次
extern char g_gz_mode[];
extern char g_cashcode[];
extern int g_dyys;
extern char g_xyksy[];
extern CARDOUT xyk_fhxx;//zh
extern double g_sl[];  //商品税率
char NumUpper[11][3] =
{
    "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖", "点"
};
char NumUnit[9][3] =
{
    "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰"
};

/*对销售商品数据的管理包含以下的功能
    1-增加记录
    2-删除记录
        3-修改记录
        4-移动记录
        5-计算合计
        6-保存数据到文件中
        7-保存数据服务器
        8-结帐管理
*/
//固显
//统计非空格字符串长度
int _StrlenEx(char *str)
{
    int i, Result = 0;
    for (i = 0; i < (int) strlen(str); i++)
    {
        if (str[i] != ' ')
        {
            Result++;
        }
    }
    return Result;
}

void Trim(char *s)
{
    int i = 0, j = 0;
    while (s[i])
    {
        if (s[i] != ' ')
        {
            s[j++] = s[i];
        }
        i++;
    }
    s[j] = '\0';
    while (j >= 0)
    {
        if (s[j] == '\0' || s[j] == ' ')
        {
            s[j--] = '\0';
        }
        else
        {
            j = -1;
        }
    }
}

void LeftTrim(char *s, char c)
{
    int l;
    l = (int) strlen(s) - 1;
    while (l >= 0 && (unsigned) s[l] <= 32)
    {
        s[l--] = '\0';
    }
    l = l + 1;
    if (l > 0)
    {
        s[l] = c;
        s[l + 1] = '\0';
    }
}

void FormatStr(char *str, int nlen)   //格式化字符串
{
    int i, nl, nBlank = 0, j = 0, k = 0;         //nBlank空格计数
    char value[81];
    nl = _StrlenEx(str);                 //不包括空格的字符串长度
    nl = nlen - nl;                        //需要补的空格数
    if (nl <= 0)
    {
        return;
    }
    for (i = 0; i < (int) strlen(str); i++)
    {
        if (str[i] == ' ' && k < nl)
        {
            while (k < nl)
            {
                value[j++] = '~',k++;
            }
        }
        else
        {
            value[j++] = str[i];
        }
    }
    value[j] = '\0';
    strcpy(str, value);
}

//设置打印格式
int _Dyjg = 15;
void SetPrintFormat(void)
{
    FILE *fp;
    int i = 1, k = 0, c = 32;
    char value[4];
    _nFormat = 0;
    _nFormatx = 0;
    fp = fopen(Param.ForFile, "r");
    if (fp)
    {
        p_Formats[1][0] = '\0';
        while (c != EOF && _nFormat <= 30)
        {
            c = fgetc(fp);
            if (c == EOF || c == '\n')
            {
                p_Formats[i][k] = '\0';
                LeftTrim(p_Formats[i], '\n');
                i++;
                p_Formats[i][0] = '\0';
                _nFormat++;
                _nFormatx++;
                k = 0;
            }
            else
            {
                p_Formats[i][k++] = (char) c;
            }
        }
        fclose(fp);
    }
    //检查端口类型
    uf_strmid(value, Param.Port, 0, 3);
    if (strcmp(value, "COM") == 0 || strcmp(value, "LPT") == 0 || strcmp(value, "PRN") == 0)
    {
        _PortType = 0;
    } //端口
    else if (value[0] == '>')
    {
        _PortType = 1;
        uf_strmid(value, Param.Port, 1, 4);
        strcpy(Param.Port, value);
    }
    _nFeedLine = atoi(Param.PLine);  //走纸行数

    for (i = 0; i < _nFeedLine; i++)
    {
        _pFeedLine[i] = '\n';
    }
    _pFeedLine[i] = '\0';

    value[0] = Param.Slbhxs[0];
    value[1] = '\0';
    if (Param.Dyspbm[2] != '\0')
    {
        _spmcws = 3 + 2 * (Param.Dyspbm[2] - 47);
    }
    _xsdws = atoi(value);
    if (Param.Title[0] != '\0')
    {
        _Dyjg = atoi(Param.Title);
    }
    else
    {
        _Dyjg = 15;
    }

    for (i = 0; i < 8; i++)
    {
        __GQList[i].lsh = 0;
    }
    _SPListCount = 0;         //当前挂起的笔数
    __guxianmark = 0;
}

char _CustumDisp[2][31] =
{
    0
};
void ShowGuXian(char *Caption, int Lines, int Att)
{
    char valuex[51], value[121], value1[25];
    int i, k;
    __guxianmark = 0;
    switch (Att)
    {
    case 3:
    case 0:
        if (Param.Gx[0] == '0' || Param.GxDisp[0] == '\0')
        {
            return;
        } //禁止顾显
        __guxianmark = Att;
        strcpy(valuex, Caption);
        FormatStr(valuex, 20);   //补足~符号
        switch (Param.Gx[0])
        {
        case '2':
            strcpy(_CustumDisp[Lines - 1], valuex);
            sprintf(value, "%s 1 %s %s", Param.GxDisp, _CustumDisp[0], _CustumDisp[1]);
            break;
        case '9':
            if (Lines == 2)
            {
                if (valuex[0] == 'T')  // 显示总计
                {
                    Lines = 2;
                }
                else
                {
                    Lines = 4;
                }
                k = 20;
                while (k)
                {
                    if (valuex[k] == ' ' || valuex[k] == '~')
                    {
                        k++;
                        break;
                    }
                    else
                    {
                        k--;
                    }
                }
                for (i = k; i <= 20; i++)
                {
                    value1[i - k] = valuex[i];
                    if (value1[i - k] == ':')
                    {
                        value1[i - k] = '.';
                        Lines = 3;
                    }
                }
                sprintf(value, Param.GxDisp, "COM", Lines, value1);
                //           printf("%s\n",value1);
            }
            else
            {
                return;
            }
            break;
        default:
            sprintf(value, Param.GxDisp, Lines, valuex);
            break;
        }
        system(value);
        break;
    case 1:
        if (Param.Qx[0] == '0' || Param.QxOpen[0] == '\0')
        {
            return;
        } //禁止钱箱

⌨️ 快捷键说明

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