Beispiel #1
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询卖方销售汇总", "", "MSG", MyStart.giUserID);
            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);

            dataGridViewRst.Rows.Clear();
            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "卖方销售汇总表";
            }
            else
            {
                mszRptTitle = "卖方销售汇总表";
            }

            string  szDateCondition = "jy_tim>='" + szBgn + "' and jy_tim<='" + szEnd + "'";
            DataSet ds = new DataSet();

            int iFirmNum = comboBox_Firm.Items.Count - 1;

            string[] szFirmID   = new string[iFirmNum];
            string[] szFirmName = new string[iFirmNum];
            string[] szFirmCard = new string[iFirmNum];
            int      iBgnRow    = 0;

            try
            {
                if (radioButton_Sel.Checked)
                {
                    if (comboBox_Firm.SelectedIndex == 0)//all
                    {
                        //2)get STORE_CARD
                        for (int i = 0; i < iFirmNum; i++)
                        {
                            string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                            szFirmID[i]   = szItem[0];
                            szFirmName[i] = szItem[1];
                            szFirmCard[i] = Get_STORE_CARD(szFirmID[i], "");
                            //3)get data
                            if (szFirmCard[i].Trim().Length > 0)
                            {
                                WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow);
                            }
                        }
                    }
                    else//only one firm
                    {
                        //2)get STORE_CARD
                        string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                        szFirmID[0]   = szItem[0];
                        szFirmName[0] = szItem[1];
                        szFirmCard[0] = Get_STORE_CARD(szFirmID[0], "");
                        //3)get data
                        if (szFirmCard[0].Trim().Length > 0)
                        {
                            WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow);
                        }
                    }
                }
                if (radioButton_Input.Checked)
                {
                    string szCard = textBox_Card.Text;
                    if (szCard.Length == 15)
                    {
                        szCard = MyStart.gszCardFirmFirst + textBox_Card.Text;
                    }

                    //副卡,只查一张卡的交易
                    //第一副卡、结算卡查卖方名下所有卡交易

                    szFirmID[0]   = szCard;
                    szFirmCard[0] = szFirmID[0];
                    //check card and get name
                    string szSql = "select a.STORE_ID,CARD_TYPE,STORE_NAME from mng_card a,base_store b "
                                   + "where a.STORE_ID = b.STORE_ID and STORE_CARD = '" + szCard + "'";
                    string szErr = "";
                    int    iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("查询卖方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    int iNum = ds.Tables[0].Rows.Count;
                    if (iNum == 0)
                    {
                        MessageBox.Show("系统里无此卖方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=系统里无此卖方卡");
                        goto Eend;
                    }
                    if (iNum > 1)
                    {
                        MessageBox.Show("重复发卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=重复发卡");
                        goto Eend;
                    }
                    DataRow dr        = ds.Tables[0].Rows[0];
                    int     iFirmID   = Convert.ToInt16(dr[0]);
                    int     iCardType = Convert.ToInt16(dr[1]);
                    szFirmName[0] = dr[2].ToString();

                    if (iCardType != 2)//第一副卡、结算卡
                    {
                        szFirmCard[0] = Get_STORE_CARD(iFirmID.ToString(), "");
                    }

                    //3)get data
                    WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow);
                }
                if (radioButton_name.Checked)
                {
                    //check card and get name
                    string szSql = "select distinct(STORE_ID),STORE_PERSON from mng_card where STORE_PERSON like '%" + textBox_name.Text.Trim() + "%' order by store_ID";
                    string szErr = "";
                    int    iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("查询卖方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    iFirmNum = ds.Tables[0].Rows.Count;
                    if (iFirmNum == 0)
                    {
                        MessageBox.Show("系统里无此卖方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=系统里无此卖方卡");
                        goto Eend;
                    }

                    //3)get data
                    for (int i = 0; i < iFirmNum; i++)
                    {
                        DataRow dr = ds.Tables[0].Rows[i];
                        szFirmID[i]   = dr[0].ToString();
                        szFirmName[i] = dr[1].ToString();
                        szFirmCard[i] = Get_STORE_CARD(szFirmID[i], "");
                        //3)get data
                        if (szFirmCard[i].Trim().Length > 0)
                        {
                            WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow);
                        }
                    }
                }
                if (iBgnRow == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #2
0
        private void frm_Qry_DayProd_Load(object sender, EventArgs e)
        {
            this.Icon              = new Icon(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report2.ico"));
            button_Qry.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.preview.ico"));
            button_Rpt.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report.ico"));
            button_Exit.Image      = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.exit01.ico"));
            groupBox2.Width        = this.Width - 50;
            groupBox2.Height       = this.Height - groupBox2.Top - 50;
            dataGridViewRst.Width  = groupBox2.Width - 20;
            dataGridViewRst.Height = groupBox2.Height - 30;

            dateTimePicker_Bgn.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_Bgn.Format       = DateTimePickerFormat.Custom;
            dateTimePicker_End.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_End.Format       = DateTimePickerFormat.Custom;
            //dateTimePicker_End.Value = DateTime.Now;
            dateTimePicker_Bgn.Text = MyStart.gdtLogin.ToString("yyyy-MM-dd 08:00:00");            //DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");//.AddMonths(-1);
            dateTimePicker_End.Text = MyStart.gdtLogin.AddDays(1).ToString("yyyy-MM-dd 07:59:59"); //DateTime.Now.ToString("yyyy-MM-dd 07:59:59");
            DateTime Dt = DateTime.Now;

            if (Dt >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")) && Dt < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 08:00:00")))
            {
                dateTimePicker_Bgn.Text = Dt.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }
            else
            {
                dateTimePicker_Bgn.Text = Dt.ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.AddDays(1).ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }

            textBox_Card.Text = "";
            textBox_name.Text = "";

            DataSet ds        = new DataSet();
            string  szErr     = "";
            int     iStoreNum = 0;//买方
            string  szSql     = "select concat(user_card,'-',user_name) from base_ucard order by user_card";
            int     iRst      = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            if (iRst == 0)
            {
                iStoreNum = ds.Tables[0].Rows.Count;
                if (iStoreNum > 0)
                {
                    comboBox_Firm.Items.Add("0-所有买方");
                }
                for (int i = 0; i < iStoreNum; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    comboBox_Firm.Items.Add(dr[0].ToString());
                }
            }
            if (iStoreNum > 0)
            {
                comboBox_Firm.SelectedIndex = 0;
            }

            /*            int iProdNum = 0;//商品
             *        szSql = "select concat(PROD_ID,'-',PROD_NAME) from base_prod where PROD_LEVEL=1 order by PROD_ID";
             *        iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
             *        if (iRst == 0)
             *        {
             *            iProdNum = ds.Tables[0].Rows.Count;
             *            if (iProdNum > 0)
             *                comboBox_Prod.Items.Add("0-所有商品");
             *            for (int i = 0; i < iProdNum; i++)
             *            {
             *                DataRow dr = ds.Tables[0].Rows[i];
             *                comboBox_Prod.Items.Add(dr[0].ToString());
             *            }
             *        }
             *        if (iProdNum > 0)
             *            comboBox_Prod.SelectedIndex = 0;
             *
             *        int iPosNum = 0;
             *        szSql = "select concat(tmn_code,'-',tmn_name) from base_psam order by tmn_code";
             *        iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
             *        if (iRst == 0)
             *        {
             *            iPosNum = ds.Tables[0].Rows.Count;
             *            if (iPosNum > 0)
             *                comboBox_POS.Items.Add("0-所有收银终端");
             *            for (int i = 0; i < iPosNum; i++)
             *            {
             *                DataRow dr = ds.Tables[0].Rows[i];
             *                comboBox_POS.Items.Add(dr[0].ToString());
             *            }
             *        }
             *        if (iPosNum > 0)
             *            comboBox_POS.SelectedIndex = 0;*/

            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            string[] szX = mszTitle.Split(',');
            miCols = szX.Length;

            radioButton_Sel.Checked = true;
            MyStart.oMyDb.Close();
        }
Beispiel #3
0
        private void frm_Rpt_Minus_Load(object sender, EventArgs e)
        {
            this.Icon              = new Icon(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report2.ico"));
            button_Qry.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.preview.ico"));
            button_Rpt.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report.ico"));
            button_Exit.Image      = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.exit01.ico"));
            groupBox2.Width        = this.Width - 50;
            groupBox2.Height       = this.Height - groupBox2.Top - 50;
            dataGridViewRst.Width  = groupBox2.Width - 20;
            dataGridViewRst.Height = groupBox2.Height - 30;

            dateTimePicker_Bgn.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_Bgn.Format       = DateTimePickerFormat.Custom;
            dateTimePicker_End.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_End.Format       = DateTimePickerFormat.Custom;
            //dateTimePicker_End.Value = DateTime.Now;
            //dateTimePicker_Bgn.Text = MyStart.gdtLogin.ToString("yyyy-MM-dd 08:00:00");//DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");//.AddMonths(-1);
            //dateTimePicker_End.Text = MyStart.gdtLogin.AddDays(1).ToString("yyyy-MM-dd 07:59:59");//DateTime.Now.ToString("yyyy-MM-dd 07:59:59");
            DateTime Dt = DateTime.Now;

            if (Dt >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")) && Dt < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 08:00:00")))
            {
                dateTimePicker_Bgn.Text = Dt.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }
            else
            {
                dateTimePicker_Bgn.Text = Dt.ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.AddDays(1).ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }

            comboBox_Type.Items.Clear();
            string  szSql = "select sub_type from base_value where type=2 order by id";
            string  szErr = "";
            DataSet ds    = new DataSet();
            int     iNum  = 0;
            int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            if (iRst == 0)
            {
                iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    comboBox_Type.Items.Add("所有");
                    for (int i = 0; i < iNum; i++)
                    {
                        DataRow dr = ds.Tables[0].Rows[i];
                        comboBox_Type.Items.Add(dr[0].ToString());
                    }
                    comboBox_Type.SelectedIndex = 0;
                }
            }

            szSql = "select concat(user_id,'-',user_name) from sys_users where USER_DPT='财务' and user_stat='USED' order by user_id";
            szErr = "";
            iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
            if (iRst == 0)
            {
                iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    comboBox_POS.Items.Add("0-所有收银员");
                }
                for (int i = 0; i < iNum; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    comboBox_POS.Items.Add(dr[0].ToString());
                }
            }
            if (iNum > 0)
            {
                comboBox_POS.SelectedIndex = 0;
            }

            textBox_buyer.Text        = "";
            radioButton_buyer.Checked = true;

            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            string[] szX = mszTitle.Split(',');
            miCols = szX.Length;
            MyStart.oMyDb.Close();
        }
Beispiel #4
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string szSql;
            string szTitle;
            string szErr = "";
            int    iRst;

            if (DialogResult.No == MessageBox.Show("请确认要保存该工作网点信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (miType == 1)//add
            {
                szTitle = "工作网点基本信息-新增";
            }
            else//edit
            {
                szTitle = "工作网点基本信息-修改";
            }

            if (textBox_Name.Text.Length == 0)
            {
                MessageBox.Show("网点名称不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Name.SelectAll();
                textBox_Name.Focus();
                return;
            }

            if (textBox_Key.Text.Length == 0)
            {
                MessageBox.Show("KEY值不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Key.SelectAll();
                textBox_Key.Focus();
                return;
            }

            if (textBox_tellerNo.Text.Length == 0)
            {
                MessageBox.Show("发起方操作员不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_tellerNo.SelectAll();
                textBox_tellerNo.Focus();
                return;
            }

            if (textBox_Psam.Text.Length == 0)
            {
                MessageBox.Show("PSAM卡不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Psam.SelectAll();
                textBox_Psam.Focus();
                return;
            }
            try
            {
                if (miType == 1)//add
                {
                    szSql = "select * from base_net where psam_no='" + textBox_Psam.Text.Trim() + "'";
                    DataSet ds = new DataSet();
                    iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst < 0)
                    {
                        MessageBox.Show("查询信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        MessageBox.Show("PSAM卡号不能重复,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=PSAM卡号不能重复,请重新输入");
                        textBox_Psam.SelectAll();
                        textBox_Psam.Focus();
                        goto Eend;
                    }

                    szSql = "INSERT INTO base_net(net_name,net_key,teller_no,psam_no,tel) VALUES ('"
                            + textBox_Name.Text.Trim() + "','" + textBox_Key.Text.Trim() + "','" + textBox_tellerNo.Text.Trim() + "','"
                            + textBox_Psam.Text.Trim() + "','" + textBox_tel.Text.Trim() + "')";
                }
                else//edit
                {
                    szSql = "UPDATE base_net SET net_name = '" + textBox_Name.Text.Trim()
                            + "',net_key = '" + textBox_Key.Text.Trim()
                            + "',tel = '" + textBox_tel.Text.Trim()
                            + "',teller_no = '" + textBox_tellerNo.Text.Trim()
                            + "' WHERE psam_no=" + textBox_Psam.Text.Trim();
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                }
                else
                {
                    szSql = "PSAM号" + mszPsam + "-网点名称" + mszName;
                    MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID);

                    MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridDataRefresh();
                    //dataGridView1.Refresh();
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK");
                }
                groupBoxInf.Enabled  = false;
                groupBoxList.Enabled = true;

                mszName   = textBox_Name.Text;
                mszKey    = textBox_Key.Text;
                mszPsam   = textBox_Psam.Text;
                mszTeller = textBox_tellerNo.Text;
                mszTel    = textBox_tel.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
            //textBox_Name.Text = mszName;
            //textBox_Psam.Text = mszPsam;
            //textBox_Key.Text = mszKey;
            //textBox_tellerNo.Text = mszTeller;
            //textBox_tel.Text = mszTel;
        }
Beispiel #5
0
        static void Main()
        {
            //Process current = Process.GetCurrentProcess();
            //Process[] processes = Process.GetProcessesByName(current.ProcessName);

            //if (processes.GetLength(0) > 1)
            //{
            //    MessageBox.Show("该程序已经运行,请退出!", "系统提示",
            //                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}

            if (File.Exists(Application.StartupPath + "\\YTB.ini") != true)
            {
                MessageBox.Show("没有找到配置文件YTB.ini,请修改后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (MyFunc.GetSysParaFromIni(Application.StartupPath + MyIniFile.mszIniFile) != 0)
            {
                MessageBox.Show("读取配置文件YTB.ini失败,请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            oMyDb = new CDb("MYSQL", gszDbIp, gszDbPort, gszDbSrv, gszDbLogin, gszDbPwd);
            if (oMyDb == null)
            {
                MessageBox.Show("连接数据库失败,请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string szErr = "";

            if (MyFunc.GetSysParaFromDb(oMyDb, ref szErr) != 0)
            {
                MessageBox.Show("读取数据库失败(错误原因=" + szErr + "),请检查后再运行!", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            oMyDb.Close();

            if (gszYTBIp.CompareTo("183.58.24.209") == 0)//生产环境
            {
                gszHttpSrv = "https://183.58.24.209:8088/ytb-http-sersc/servlet/server";
            }
            else
            {
                gszHttpSrv = "http://58.213.110.146:9082/ytb-http-server/servlet/server";
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            UserCheckIn = false;
            frm_Login Frm_Login = new frm_Login();

            Frm_Login.ShowDialog();

            giUserID = 1;//only for test

            if (UserCheckIn)
            {
                Application.Run(new frm_Main());
            }
        }
Beispiel #6
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            //select
            //case when b.USER_NAME is not null then b.USER_NAME else '合计' end as '操作员',
            //case when oper_subtype is not null then oper_subtype else '小计' end as '类型',
            //sum(chg_val) as '金额' from rec_user a,sys_users b
            //where oper_type = 'ADD' and a.Oper_ID = b.USER_ID group by b.USER_NAME, oper_subtype with rollup;

            MyFunc.WriteToDbLog("查询充值汇总", "", "MSG", MyStart.giUserID);
            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);

            //dataGridViewRst.Rows.Clear();
            //MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "充值汇总表";
            }
            else
            {
                mszRptTitle = "充值汇总表";
            }

            string szDateCondition = "Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'";
            string szSql           = "select "
                                     + "case when b.USER_NAME is not null then b.USER_NAME else '合计' end as '收银员',"
                                     + "case when oper_subtype is not null then oper_subtype else '小计' end as '充值类型',"
                                     + "count(chg_val) as 充值笔数,format(sum(chg_val) / 100, 2) as '充值金额(元)' from rec_user a,sys_users b where oper_type = 'ADD' and a.Oper_ID=b.USER_ID  ";

            if (comboBox_Type.SelectedIndex > 0)//only one type
            {
                szSql += " and oper_subtype='" + comboBox_Type.Text.Trim() + "' ";
            }
            if (comboBox_POS.SelectedIndex > 0)//only one oper
            {
                string[] szX = comboBox_POS.Text.Split('-');
                szSql += " and a.Oper_ID=" + szX[0];
            }
            if (!(textBox_buyer.Text.Length == 0 && comboBox_Buyer.SelectedIndex == 0))//only one buyer
            {
                string[] szX = comboBox_Buyer.Text.Split('-');
                szSql += " and a.Card_No='" + szX[0] + "' ";
            }
            szSql += " and " + szDateCondition + " group by b.USER_NAME, oper_subtype with rollup";
            try
            {
                DataSet ds    = new DataSet();
                string  szErr = "";
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询充值汇总", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                DataTable dt = ds.Tables[0];
                if (dataGridViewRst.Columns.Count > 0)
                {
                    dataGridViewRst.Columns.Clear();
                }
                dataGridViewRst.DataSource = dt;
                dataGridViewRst.Refresh();

                int iNum = dt.Rows.Count;
                if (iNum == 0)
                {
                    button_Rpt.Enabled = false;
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                int iCurNum = (iNum < miDefRows ? miDefRows : iNum);
                int iBgnRow = 0;
                //MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum);
                iBgnRow += iNum;

                if (iBgnRow == 0)
                {
                    goto Eend;
                }


                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #7
0
        private void button_qry2_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询发卡明细", "", "MSG", MyStart.giUserID);

            dataGridView_Detail.Columns.Clear();
            dataGridView_Detail.DataSource = null;
            MyFunc.GridInit(ref dataGridView_Detail, mszTitle, mszTitleWidth, 15, miDefRows, true);

            string szWhere = "";

            if (radioButton_card.Checked)
            {
                szWhere += "STORE_CARD like '%" + textBox_Card.Text.Trim() + "%' ";
            }
            if (radioButton_cell.Checked)
            {
                szWhere += "a.USER_TEL like '%" + textBox_Cell.Text.Trim() + "%' ";
            }
            if (radioButton_name.Checked)
            {
                szWhere += "a.STORE_PERSON like '%" + textBox_name.Text.Trim() + "%' ";
            }
            if (radioButton_date.Checked)
            {
                szWhere += "DATE_FORMAT(a.ADD_DT, '%Y-%m-%d') = '" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "' ";
            }

            string szSql = "(SELECT store_name as 卖方名称,a.ADD_DT as 发卡时间, "
                           + "if (CARD_TYPE = 1,'第一副卡',if (CARD_TYPE = 2,'副卡','结算卡')) as 卡类,STORE_CARD as 卡号, "
                           + "if (CARD_STAT = 'BGN','正常',if (CARD_STAT = 'STOP','无效','挂失')) as 状态,STALL_INF as 档口信息, "
                           + "a.STORE_PERSON as 联系人,a.USER_TEL as 联系电话, a.cert_id as 身份证, b.USER_NAME as 开卡人 "
                           + "FROM mng_card a,sys_users b,base_store c where a.ADD_ID=b.USER_ID and a.STORE_ID=c.STORE_ID and " + szWhere + " order by a.ADD_DT) "
                           + "union "
                           + "(select '小计', '', '', count(*),  '','', '', '', '',  '' from mng_card a where " + szWhere + ")";

            try
            {
                string  szErr = "";
                DataSet ds    = new DataSet();
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    goto Eend;
                }

                DataTable dt   = ds.Tables[0];
                int       iNum = dt.Rows.Count;

                dataGridView_Detail.Columns.Clear();//
                dataGridView_Detail.DataSource = dt;
                dataGridView_Detail.Refresh();

                if (iNum > 0)
                {
                    button_Rpt.Enabled = true;
                }
                else
                {
                    //groupBox3.Text = "发卡明细:";
                    button_Rpt.Enabled = false;
                }
                if (!radioButton_date.Checked)
                {
                    mszRptDate = "";
                }
                else
                {
                    mszRptDate = "发卡日期:" + dateTimePicker1.Value.ToString("yyyy-MM-dd");
                }
                miRows = iNum;
            }
            catch (Exception ex)
            {
                MessageBox.Show("买方卡开卡查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();

            if (dataGridView_Detail.RowCount > 0)
            {
                button_Rpt.Enabled = true;
            }
            //miRows = iBgnRow + 1;
        }
Beispiel #8
0
        private void button_Cancel_Click(object sender, EventArgs e)
        {
            string szCard = dataGridView1.CurrentRow.Cells[4].Value.ToString();

            if (szCard.Length == 0)
            {
                MessageBox.Show("请先选择要解绑的买方卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string  szSql = "select count(*) from rec_trade where substr(USER_CARD,2)='" + szCard + "'";
            string  szErr = "";
            DataSet ds    = new DataSet();
            int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            if (iRst < 0)
            {
                MessageBox.Show("买方卡号查询失败,请重新操作", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                goto EEnd;
            }
            DataRow dr   = ds.Tables[0].Rows[0];
            int     iNum = Convert.ToInt16(dr[0]);

            if (iNum > 0)
            {
                MessageBox.Show("该买方卡号已有交易,不能解绑", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                goto EEnd;
            }

            if (iNum > 1)
            {
                if (DialogResult.No == MessageBox.Show("有" + iNum + "张卡号相同,会同时解绑,解绑后不可恢复,是否继续?", "操作提示",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    goto EEnd;
                }
            }
            else
            {
                if (DialogResult.No == MessageBox.Show("买方卡解绑后不可恢复,是否继续?", "操作提示",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    goto EEnd;
                }
            }

            //连接银石后台

            //写入DB
            szSql = "delete from base_ucard where substr(user_card,2)='" + szCard + "'";
            iRst  = MyStart.oMyDb.WriteData(szSql, ref szErr);
            if (iRst <= 0)
            {
                MessageBox.Show("该买方卡号解绑失败(错误原因=" + szErr + ")", "操作提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                goto EEnd;
            }
            MessageBox.Show("该买方卡号解绑成功", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            MyFunc.WriteToDbLog("发买方卡-解绑", "买方卡号" + szCard, "MSG", MyStart.giUserID);
            //GridDataRefresh(miFirmID, miStallID);
EEnd:
            MyStart.oMyDb.Close();
        }
Beispiel #9
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("确认当前的发卡信息吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            //    return;
            if (textBox_Person.TextLength == 0)
            {
                MessageBox.Show("姓名不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Person.SelectAll();
                textBox_Person.Focus();
                return;
            }
            if (textBox_Card.Text.Length != 16)
            {
                MessageBox.Show("卡号长度错误(买方卡号长度为16),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button_Card.Focus();
                return;
            }

            DataSet ds    = new DataSet();
            string  szErr = "";
            string  szSql = "";

            try
            {
                szErr = "";
                szSql = "select * from base_ucard where user_card='" + textBox_Card.Text.Trim() + "'";
                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发买方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    MessageBox.Show("卡号重复,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button_Card.Focus();
                    goto Eend;
                }

                szSql = "select * from base_ucard where card_type=1 and user_name='" + textBox_Person.Text.Trim() + "'";
                //+ "' and USER_TEL='" + textBox_Cell.Text.Trim() + "'";
                iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发买方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                iNum = ds.Tables[0].Rows.Count;
                int iPID = 0;
                if (iNum > 0)
                {
                    if (MessageBox.Show("该持卡人已有" + iNum + "张买方卡,确认发副卡吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        goto Eend;
                    }

                    checkBox_multy.Checked = true;
                    DataRow dr = ds.Tables[0].Rows[0];
                    textBox_Cell.Text   = dr["USER_TEL"].ToString();
                    textBox_CertID.Text = dr["CERT_ID"].ToString();
                    textBox_Addr.Text   = dr["user_addr"].ToString();
                    textBox_rmrk.Text   = dr["rmrk"].ToString();
                    string szTruck = dr["truck_no"].ToString();
                    if (szTruck.Length > 1)
                    {
                        comboBox_truck.Text = dr["truck_no"].ToString().Substring(0, 1);
                        textBox_truck.Text  = dr["truck_no"].ToString().Substring(1);
                    }
                    iPID = Convert.ToInt32(dr["ID"]);
                    if (dr["is_sign"].ToString() == "1")
                    {
                        checkBox_Sign.Checked = true;
                    }
                    else
                    {
                        checkBox_Sign.Checked = false;
                    }

                    //checkBox_Sign.Enabled = false;
                    //textBox_Addr.Enabled = false;
                    //comboBox_truck.Enabled = false;
                    //textBox_truck.Enabled = false;
                    if (MessageBox.Show("是否需要继续补齐资料?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        goto Eend;
                    }
                }
                else
                {
                    MessageBox.Show("该人未开过卡,只能开主卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    checkBox_multy.Checked = false;
                }

                if (textBox_Cell.TextLength == 0)
                {
                    MessageBox.Show("请输入联系电话", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_Cell.SelectAll();
                    textBox_Cell.Focus();
                    return;
                }
                if (textBox_CertID.TextLength == 0)
                {
                    MessageBox.Show("身份证号不能为空,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_CertID.SelectAll();
                    textBox_CertID.Focus();
                    return;
                }
                if (textBox_pwd.Text.Trim() != textBox_pwd2.Text.Trim())
                {
                    MessageBox.Show("两次输入的密码不同,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_pwd.SelectAll();
                    textBox_pwd.Focus();
                    return;
                }
                if (textBox_pwd.TextLength == 0)
                {
                    MessageBox.Show("退款时需要密码,请输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_pwd.SelectAll();
                    textBox_pwd.Focus();
                    goto Eend;
                }

                /*if (textBox_Cell.TextLength != 11)
                 * {
                 *  MessageBox.Show("请输入买方手机号码,长度为11", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 *  textBox_Cell.SelectAll();
                 *  textBox_Cell.Focus();
                 *  return;
                 * }*/

                //连接银石后台
                EbHttpClass objHttp = new EbHttpClass();
                string      szPwd   = "1," + textBox_pwd.Text;
                bool        bRst    = objHttp.IssueNewUserCard(textBox_Card.Text, textBox_Person.Text, textBox_Cell.Text, textBox_CertID.Text, ref szPwd, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台注册买方卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //写入DB
                szSql = "INSERT INTO base_ucard (user_name,USER_TEL,CERT_ID,user_card,card_pwd,pwd_crypt,oper_time,ADD_ID,user_addr,rmrk,truck_no,is_sign,card_type,parent_ID) VALUES ('"
                        + textBox_Person.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "','" + textBox_CertID.Text.Trim() + "','"
                        + textBox_Card.Text.Trim() + "',' ',' ',curtime()," + MyStart.giUserID + ",'" + textBox_Addr.Text.Trim() + "','" + textBox_rmrk.Text.Trim() + "','"
                        + comboBox_truck.Text + textBox_truck.Text.Trim() + "', ";
                if (checkBox_Sign.Checked)
                {
                    szSql += "1,";
                }
                else
                {
                    szSql += "0,";
                }

                if (checkBox_multy.Checked)
                {
                    szSql += "2," + iPID + ")";
                }
                else
                {
                    szSql += "1,0)";
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("发买方卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发买方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                if (!checkBox_multy.Checked)
                {
                    szSql = "update base_ucard set parent_ID=id where card_type=1 and parent_ID=0";
                    iRst  = MyStart.oMyDb.WriteData(szSql, ref szErr);
                    if (iRst < 1)
                    {
                        MessageBox.Show("发买方卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("发买方卡", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                }
                szSql = "持卡人" + textBox_Person.Text.Trim() + "-电话" + textBox_Cell.Text.Trim() + "-卡号" + textBox_Card.Text.Trim();
                MyFunc.WriteToDbLog("发买方卡", szSql, "MSG", MyStart.giUserID);
                GridDataRefresh();

                if (Convert.ToDecimal(textBox_Fee.Text) > 0)
                {
                    long lVal = (long)(Convert.ToDecimal(textBox_Fee.Text) * 100);
                    szSql = "insert into rec_user (card_no,oper_time,oper_type,chg_val,oper_id,tmn_id) values ('" + textBox_Card.Text.Trim()
                            + "',curtime(),'ISSU'," + lVal + "," + MyStart.giUserID + ",'" + frm_Main.POS_ID + "')";
                    iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                    if (iRst < 1)
                    {
                        MessageBox.Show("记录买方卡工本费出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("发买方卡", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                }
                MessageBox.Show("发买方卡成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                textBox_Card.Text   = "";
                textBox_pwd.Text    = "";
                textBox_Person.Text = "";
                textBox_Cell.Text   = "";
                textBox_CertID.Text = "";
                textBox_Addr.Text   = "";
                textBox_rmrk.Text   = "";
                comboBox_truck.Text = "粤";
                textBox_truck.Text  = "";
                goto Eend;
            }
            catch (Exception ex)
            {
                MessageBox.Show("发买方卡失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #10
0
        private void button_SaveM_Click(object sender, EventArgs e)
        {
            if (textBox_CardM.Text.Length != 15)
            {
                MessageBox.Show("第一副卡卡号长度错误(卖方卡号长度为15),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button_CardM.Focus();
                return;
            }
            if (textBox_CardV.Text.Length != 16)
            {
                MessageBox.Show("结算卡卡号长度错误(卖方卡号长度为16),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button_CardM.Focus();
                return;
            }
            if (textBox_pwd.Text.Trim() != textBox_pwd2.Text.Trim())
            {
                MessageBox.Show("两次输入的密码不同,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_pwd.SelectAll();
                textBox_pwd.Focus();
                return;
            }


            DataSet ds    = new DataSet();
            string  szErr = "";

            string[] szFirmInf = comboBox_NameM.Text.Split('-');
            int      iFirmID   = Convert.ToInt16(szFirmInf[0]);
            string   szSql     = "select * from mng_card where STORE_CARD='" + MyStart.gszCardFirmFirst + textBox_CardM.Text.Trim() + "'";

            try
            {
                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    MessageBox.Show("卡号重复,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button_CardM.Focus();
                    goto Eend;
                }

                szSql = "select * from mng_card a where CARD_TYPE = 1 and store_id = " + iFirmID;
                iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    MessageBox.Show("该卖方已发第一副卡和结算卡,请换卖方", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    comboBox_NameM.Focus();
                    goto Eend;
                }

                //必须同时发第一副卡和结算卡
                if (textBox_CardM.TextLength == 0 || textBox_CardV.TextLength == 0)
                {
                    MessageBox.Show("第一副卡和结算卡必须同时发放,请输入卡号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button_CardM.Focus();
                    goto Eend;
                }
                if (textBox_pwd.TextLength != 6)
                {
                    MessageBox.Show("必须设置提款密码!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_pwd.Focus();
                    goto Eend;
                }
                //连接银石后台
                EbHttpClass objHttp = new EbHttpClass();
                string      szPwd   = "1," + textBox_pwd.Text;
                bool        bRst    = objHttp.IssueNewUserCard(textBox_CardV.Text, szFirmInf[1], textBox_TelM.Text, textBox_CertIDM.Text, ref szPwd, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台注册结算卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //EbHttpClass objHttp = new EbHttpClass();
                szPwd = textBox_pwd.Text;
                bRst  = objHttp.IssueNewFirmCard(textBox_CardM.Text, textBox_CardV.Text, szFirmInf[1], textBox_TelM.Text, textBox_CertIDM.Text, ref szPwd, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台注册卖方卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //写入DB
                szPwd = textBox_pwd.Text + "," + szPwd;
                szSql = "INSERT INTO mng_card (STORE_ID,STORE_PERSON,USER_TEL,CERT_ID,CARD_TYPE,STORE_CARD,RMRK,ADD_DT,ADD_ID) VALUES ("
                        + iFirmID + ",'" + textBox_PersonM.Text.Trim() + "','" + textBox_TelM.Text.Trim() + "','"
                        + textBox_CertIDM.Text.Trim() + "',1,'"
                        + MyStart.gszCardFirmFirst + textBox_CardM.Text.Trim() + "',' ',curtime()," + MyStart.giUserID + ")";
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("发卖方第一副卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                szSql = iFirmID + "-持卡人" + textBox_PersonM.Text.Trim() + "-电话" + textBox_TelM.Text.Trim() + "-卡号"
                        + textBox_CardM.Text.Trim();
                MyFunc.WriteToDbLog("发卖方第一副卡", szSql, "MSG", MyStart.giUserID);

                szSql = "INSERT INTO mng_card (STORE_ID,STORE_PERSON,USER_TEL,CERT_ID,CARD_TYPE,STORE_CARD,RMRK,ADD_DT,ADD_ID) VALUES ("
                        + iFirmID + ",'" + textBox_PersonM.Text.Trim() + "','" + textBox_TelM.Text.Trim() + "','"
                        + textBox_CertIDM.Text.Trim() + "',3,'"
                        + textBox_CardV.Text.Trim() + "',' ',curtime()," + MyStart.giUserID + ")";
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("发卖方结算卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }

                szSql = iFirmID + "-持卡人" + textBox_PersonM.Text.Trim() + "-电话" + textBox_TelM.Text.Trim() + "-卡号"
                        + textBox_CardV.Text.Trim();
                MyFunc.WriteToDbLog("发卖方结算卡", szSql, "MSG", MyStart.giUserID);

                if (Convert.ToDecimal(textBox_Fee_M.Text) > 0)
                {
                    long lVal = (long)(Convert.ToDecimal(textBox_Fee_M.Text) * 100);
                    szSql = "insert into rec_firm (card_no,rmrk,store_id,oper_time,oper_type,chg_val,oper_id,tmn_id) values ('"
                            + textBox_CardV.Text.Trim() + "','" + MyStart.gszCardFirmFirst + textBox_CardM.Text.Trim() + "'," + iFirmID + ",curtime(),'ISSU',"
                            + lVal + "," + MyStart.giUserID + ",'" + frm_Main.POS_ID + "')";
                    iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                    if (iRst < 1)
                    {
                        MessageBox.Show("记录卖方第一副卡与结算卡工本费出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("发卖方第一副卡与结算卡收费", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                }

                MessageBox.Show("发卖方卡成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                GridDataRefresh(iFirmID, 0);
                //GridDataRefresh(miFirmID, miStallID);
                textBox_CardM.Text   = "";
                textBox_CardV.Text   = "";
                textBox_PersonM.Text = "";
                textBox_TelM.Text    = "";
                textBox_CertIDM.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("发卖方卡失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
            return;
        }
Beispiel #11
0
        private void button_SaveS_Click(object sender, EventArgs e)
        {
            if (textBox_CardS.Text.Length != 15)
            {
                MessageBox.Show("卡号长度错误(卖方卡号长度为15),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button_CardM.Focus();
                return;
            }

            DataSet ds    = new DataSet();
            string  szErr = "";

            string[] szFirmInf = comboBox_NameS.Text.Split('-');
            int      iFirmID   = Convert.ToInt16(szFirmInf[0]);

            string[] szStall = comboBox_Rent.Text.Split('-');
            int      iRendID = Convert.ToInt16(szStall[0]);
            //string szStallInf = szStall[1];
            string szSql = "select * from mng_card where STORE_CARD='" + MyStart.gszCardFirmFirst + textBox_CardS.Text.Trim() + "'";

            try
            {
                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    MessageBox.Show("卡号重复,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button_CardS.Focus();
                    goto Eend;
                }

                szSql = "select STORE_CARD,STORE_PERSON from mng_card where CARD_TYPE = 1 and STORE_ID=" + iFirmID;
                iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                iNum = ds.Tables[0].Rows.Count;
                if (iNum == 0)
                {
                    MessageBox.Show("该卖方没有第一副卡和结算卡,不能发副卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + "该卖方没有第一副卡和结算卡,不能发副卡");
                    goto Eend;
                }
                DataRow dr         = ds.Tables[0].Rows[0];
                string  szCardM    = dr[0].ToString();
                string  szCardName = dr[1].ToString();

                szSql = "select * from mng_card where CARD_TYPE = 2 and STALL_ID=" + szStall[0]
                        + " and STORE_PERSON='" + textBox_PersonS.Text.Trim()
                        + "' and USER_TEL='" + textBox_TelS.Text.Trim() + "'";
                iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)
                {
                    if (MessageBox.Show("该持卡人已有" + iNum + "张副卡,确认继续发卡吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        goto Eend;
                    }
                }

                /*连接银石后台
                 * EbHttpClass objHttp = new EbHttpClass();
                 * string szPwd = "";
                 * bool bRst = objHttp.IssueNewFirmCard(szCardM.Substring(1,15), textBox_CardS.Text, szFirmInf[1], textBox_TelS.Text, textBox_CertIDS.Text,  ref szPwd, ref szErr);
                 * if (!bRst)
                 * {
                 *  MessageBox.Show("后台注册卖方卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 *  return;
                 * }*/

                //写入DB
                szSql = "INSERT INTO mng_card (STORE_ID,STALL_ID,STALL_INF,STORE_PERSON,USER_TEL,CERT_ID,CARD_TYPE,STORE_CARD,ADD_DT,ADD_ID) VALUES (";
                if (textBox_PersonS.Text.Trim() != "")
                {
                    szSql += iFirmID + "," + szStall[0] + ",'" + comboBox_Rent.Text + "','" + textBox_PersonS.Text.Trim() + "','" + textBox_TelS.Text.Trim() + "','";
                }
                else
                {
                    szSql += iFirmID + "," + szStall[0] + ",'" + comboBox_Rent.Text + "','" + szCardName.Trim() + "','" + textBox_TelS.Text.Trim() + "','";
                }
                szSql += textBox_CertIDS.Text.Trim() + "',2,'";
                szSql += MyStart.gszCardFirmFirst + textBox_CardS.Text.Trim() + "',curtime()," + MyStart.giUserID + ")";
                iRst   = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("发卖方副卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方副卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }

                szSql = "select STALL_ID from mng_card where CARD_TYPE=1 and STORE_ID=" + iFirmID;
                iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("发卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                iNum = ds.Tables[0].Rows.Count;
                if (iNum > 1)
                {
                    MessageBox.Show("发卡出错(错误原因:该卖方有多张第一副卡)", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("发卖方卡", "SQL=" + szSql + ",Err=该卖方有多张第一副卡");
                    goto Eend;
                }
                dr = ds.Tables[0].Rows[0];
                if (Convert.ToInt16(dr[0]) == 0)
                {
                    szSql = "update mng_card set STALL_ID=" + szStall[0] + " where STORE_ID=" + iFirmID + " and CARD_TYPE<>2";
                    iRst  = MyStart.oMyDb.WriteData(szSql, ref szErr);
                    if (iRst < 1)
                    {
                        MessageBox.Show("发卖方副卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("发卖方副卡", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                }

                szSql = szStall[1] + "-持卡人" + textBox_PersonS.Text.Trim() + "-电话" + textBox_TelS.Text.Trim() + "-卡号"
                        + textBox_CardS.Text.Trim();
                MyFunc.WriteToDbLog("发卖方副卡", szSql, "MSG", MyStart.giUserID);
                GridDataRefresh(iFirmID, iRendID);

                if (Convert.ToDecimal(textBox_Fee_S.Text) > 0)
                {
                    long lVal = (long)(Convert.ToDecimal(textBox_Fee_S.Text) * 100);
                    szSql = "insert into rec_firm (card_no,store_id,oper_time,oper_type,chg_val,oper_id,tmn_id) values ('"
                            + MyStart.gszCardFirmFirst + textBox_CardS.Text.Trim() + "'," + iFirmID + ",curtime(),'ISSU',"
                            + lVal + "," + MyStart.giUserID + ",'" + frm_Main.POS_ID + "')";
                    iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                    if (iRst < 1)
                    {
                        MessageBox.Show("记录卖方副卡工本费出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("发卖方副卡收费", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                }
                MessageBox.Show("发卖方副卡成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_CardS.Text   = "";
                textBox_PersonS.Text = "";
                textBox_TelS.Text    = "";
                textBox_CertIDS.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("发卖方副卡失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
            return;
        }
Beispiel #12
0
        private void button_unlost_Click(object sender, EventArgs e)
        {
            mszTip = "解挂";
            string szSql = "";

            if (radioButton_unlost_card.Checked)
            {
                if (textBox_unlost_card.TextLength != 16)
                {
                    MessageBox.Show("请输入" + mszTip + "卡的卡号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_tel,cert_id,card_flag,card_pwd from base_ucard where user_card='" + textBox_unlost_card.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, user_tel, cert_id,CARD_STAT,RMRK from mng_card where CARD_TYPE = 3 and STORE_CARD = '" + textBox_unlost_card.Text.Trim() + "'";
                }
            }
            if (radioButton_unlost_cell.Checked)
            {
                if (textBox_unlost_cell.TextLength <= 0)
                {
                    MessageBox.Show("手机号不能为空", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_card,cert_id,card_flag,card_pwd from base_ucard where user_tel='" + textBox_unlost_cell.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, STORE_CARD, cert_id,CARD_STAT,RMRK from mng_card where CARD_TYPE = 3 and user_tel = '" + textBox_unlost_cell.Text.Trim() + "'";
                }
            }
            if (radioButton_unlost_cert.Checked)
            {
                if (textBox_unlost_cert.TextLength <= 0)
                {
                    MessageBox.Show("身份证号不能为空", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_tel,user_card,card_flag,card_pwd from base_ucard where cert_id='" + textBox_unlost_cert.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, user_tel, STORE_CARD,CARD_STAT,RMRK from mng_card where CARD_TYPE = 3 and  cert_id= '" + textBox_unlost_cert.Text.Trim() + "'";
                }
            }

            //确认卡片信息
            //if (mszFlag.ToUpper() == "USER_CARD")//买方卡
            //{
            //    szSql = "select user_name,user_tel,cert_id,card_flag from base_ucard where user_card='" + textBox_Card_Lost.Text + "'";
            //}
            //else//卖方结算卡
            //{
            //    szSql = "select STORE_PERSON, user_tel, cert_id,CARD_STAT from mng_card where CARD_TYPE = 3 and STORE_CARD = '" + textBox_Card_Lost.Text + "'";
            //}
            try
            {
                DataSet ds    = new DataSet();
                string  szErr = "";
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("卡片查询出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(this.Text + mszTip + "卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum < 1)
                {
                    MessageBox.Show("查不到卡片信息,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                if (iNum > 1)
                {
                    MessageBox.Show("卡号关联多买方,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                DataRow dr    = ds.Tables[0].Rows[0];
                string  szPwd = "";
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szPwd = dr[4].ToString();
                }
                else//卖方结算卡
                {
                    string[] szX = dr[4].ToString().Split(',');
                    szPwd = szX[0];
                }
                if (dr[3].ToString().ToUpper() == "BGN")
                {
                    MessageBox.Show("非挂失状态,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //bool bLost = (mszTip == "挂失" ? true : false);
                //if(bLost)
                //{
                //if (dr[3].ToString().ToUpper() == "LOST")
                //{
                //    MessageBox.Show("卡号已挂失,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                //}
                //else
                //{
                //}
                string szCard = "";
                if (radioButton_unlost_card.Checked)
                {
                    szCard = textBox_unlost_card.Text.Trim();
                    label_unLostCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + dr[1].ToString() + "\r\n" + "身份证号:" + dr[2].ToString();
                }
                if (radioButton_unlost_cell.Checked)
                {
                    szCard = dr[1].ToString();
                    label_unLostCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + textBox_unlost_cell.Text + "\r\n" + "身份证号:" + dr[2].ToString();
                }
                if (radioButton_unlost_cert.Checked)
                {
                    szCard = dr[2].ToString();
                    label_unLostCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + dr[1].ToString() + "\r\n" + "身份证号:" + textBox_unlost_cert.Text;
                }
                if (DialogResult.No == MessageBox.Show("是否继续" + mszTip + "卡操作?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    goto Eend;
                }

                ////银石后台验密
                //EbHttpClass objHttp = new EbHttpClass();
                //bool bRst = objHttp.CheckPwd(szCard, textBox_unlost_pwd.Text.Trim(), ref szErr);
                //if (!bRst)//szPwd != textBox_unlost_pwd.Text)
                //{
                //    MessageBox.Show("验密失败(后台"+szErr+"),不能解挂", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    //MessageBox.Show("卡号密码错误,不能解挂", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}

                //银石后台修改
                EbHttpClass objHttp = new EbHttpClass();
                bool        bRst    = objHttp.LostCard(false, szCard, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台" + mszTip + "卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //新卡写DB
                string szField = "BGN";               // (bLost ? "LOST" : "BGN");
                if (mszFlag.ToUpper() == "USER_CARD") //换买方卡
                {
                    szSql = "update base_ucard set card_flag = '" + szField + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID
                            + " where user_card = '" + szCard + "'";
                }
                else//换卖方结算卡
                {
                    szSql = "update mng_card set CARD_STAT = '" + szField + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID
                            + " where CARD_TYPE = 3 and STORE_CARD = '" + szCard + "'";
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show(mszTip + "卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(this.Text + mszTip + "卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                MyFunc.WriteToDbLog(this.Text + mszTip + "卡", "卡号" + textBox_Card_Lost.Text, "MSG", MyStart.giUserID);
                MessageBox.Show(mszTip + "卡成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("解挂卡片失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #13
0
        private void button_ChgCard_Click(object sender, EventArgs e)
        {
            if (textBox_Card_New.TextLength != 16)
            {
                MessageBox.Show("请输入换卡后,新卡卡号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string szSql = "";

            if (radioButton_chg_card.Checked)
            {
                if (textBox_Card_Old.TextLength != 16)
                {
                    MessageBox.Show("请输入换卡前,旧卡卡号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_tel,cert_id,card_flag,card_pwd from base_ucard where user_card='" + textBox_Card_Old.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, user_tel, cert_id,STORE_ID,RMRK from mng_card where CARD_TYPE = 3 and STORE_CARD = '" + textBox_Card_Old.Text.Trim() + "'";
                }
            }
            if (radioButton_chg_cell.Checked)
            {
                if (textBox_chg_cell.TextLength <= 0)
                {
                    MessageBox.Show("手机号不能为空", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_card,cert_id,card_flag,card_pwd from base_ucard where user_tel='" + textBox_chg_cell.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, STORE_CARD, cert_id,STORE_ID,RMRK from mng_card where CARD_TYPE = 3 and user_tel = '" + textBox_chg_cell.Text.Trim() + "'";
                }
            }
            if (radioButton_chg_cert.Checked)
            {
                if (textBox_chg_cert.TextLength <= 0)
                {
                    MessageBox.Show("身份证号不能为空", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szSql = "select user_name,user_tel,user_card,card_flag,card_pwd from base_ucard where cert_id='" + textBox_chg_cert.Text.Trim() + "'";
                }
                else//卖方结算卡
                {
                    szSql = "select STORE_PERSON, user_tel, STORE_CARD,STORE_ID,RMRK from mng_card where CARD_TYPE = 3 and  cert_id= '" + textBox_chg_cert.Text.Trim() + "'";
                }
            }

            //确认卡片信息
            //if (mszFlag.ToUpper() == "USER_CARD")//买方卡
            //{
            //    szSql = "select user_name,user_tel,cert_id from base_ucard where user_card='" + textBox_Card_Old.Text + "'";
            //}
            //else//卖方结算卡
            //{
            //    szSql = "select STORE_PERSON, user_tel, cert_id,STORE_ID from mng_card where CARD_TYPE = 3 and STORE_CARD = '" + textBox_Card_Old.Text + "'";
            //}
            try
            {
                DataSet ds    = new DataSet();
                string  szErr = "";
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("卡片查询出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(this.Text + "换卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum < 1)
                {
                    MessageBox.Show("查不到卡片信息,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                if (iNum > 1)
                {
                    MessageBox.Show("卡号关联多买方,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                DataRow dr    = ds.Tables[0].Rows[0];
                string  szPwd = "";
                if (mszFlag.ToUpper() == "USER_CARD")//买方卡
                {
                    szPwd = dr[4].ToString();
                }
                else//卖方结算卡
                {
                    string[] szItem = dr[4].ToString().Split(',');
                    szPwd = szItem[0];
                }


                //}
                string szCard = "";
                if (radioButton_chg_card.Checked)
                {
                    szCard             = textBox_Card_Old.Text.Trim();
                    label_ChgCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + dr[1].ToString() + "\r\n" + "身份证号:" + dr[2].ToString();
                }
                if (radioButton_chg_cell.Checked)
                {
                    szCard             = dr[1].ToString();
                    label_ChgCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + textBox_chg_cell.Text + "\r\n" + "身份证号:" + dr[2].ToString();
                }
                if (radioButton_chg_cert.Checked)
                {
                    szCard             = dr[2].ToString();
                    label_ChgCard.Text = "卡号:" + szCard + "\r\n" + "持卡人:" + dr[0].ToString() + "\r\n" + "联系电话:" + dr[1].ToString() + "\r\n" + "身份证号:" + textBox_chg_cert.Text;
                }
                //银石后台验密
                EbHttpClass objHttp = new EbHttpClass();
                bool        bRst    = objHttp.CheckPwd(szCard, textBox_chg_pwd.Text.Trim(), ref szErr);
                if (!bRst)//if (szPwd != textBox_chg_pwd.Text)
                {
                    MessageBox.Show("卡号密码错误,不能换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                if (DialogResult.No == MessageBox.Show("是否继续换卡操作?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    goto Eend;
                }

                //EbHttpClass objHttp = new EbHttpClass();
                /*bool*/
                bRst = false;

                /*int iVal = 0;// Convert.ToInt16(Convert.ToDecimal( textBox_Val.Text)*100)/100;
                 * int iFee = miFee * 100;// Convert.ToInt16(Convert.ToDecimal(textBox_Fee.Text)*100);
                 * if (iFee > 0)
                 * {
                 *  if (iVal == 0)
                 *  {//银石后台读余额
                 *      bRst = objHttp.QryCard(MyStart.gszCardYtbFirst + textBox_Card_Old.Text, ref iVal,ref miUncofirmVal, ref szErr);
                 *      if (!bRst)
                 *      {
                 *          MessageBox.Show("后台读余额失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 *          return;
                 *      }
                 *      textBox_Val.Text = (Convert.ToDecimal(iVal) /100).ToString("0.00");
                 *  }
                 *  if(iVal<iFee)
                 *  {
                 *      if(DialogResult.No== MessageBox.Show("卡内余额不足,是否继续?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                 *          return;
                 *  }
                 *
                 *  //扣费 -- not code yet
                 *  ;
                 * }*/

                //银石后台修改
                string   szNewPwd = "888888";// + textBox_New_Pwd.Text;
                string[] szX      = comboBox_Why.Text.Split('-');
                decimal  dFee     = Convert.ToDecimal(textBox_Fee.Text);
                bRst = objHttp.ChangeCard(szCard, textBox_Card_New.Text, szX[0], dFee, ref szNewPwd, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台换卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                if (mszFlag.ToUpper() != "USER_CARD")//重新捆绑
                {
                    miStoreID = Convert.ToInt16(dr[3]);
                    //read
                    szSql = "select STORE_CARD, STORE_NAME,USER_TEL, a.cert_id from mng_card a,base_store b "
                            + "where a.STORE_ID = b.STORE_ID and CARD_TYPE = 1 and a.STORE_ID = " + miStoreID;
                    iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("换卖方卡查询出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(this.Text + "换卖方卡", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    iNum = ds.Tables[0].Rows.Count;
                    if (iNum < 1)
                    {
                        MessageBox.Show("查不到卖方卡信息,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        goto Eend;
                    }

                    dr   = ds.Tables[0].Rows[0];
                    bRst = objHttp.IssueNewFirmCard(dr[0].ToString().Substring(1, 15), textBox_Card_New.Text, dr[1].ToString(), dr[2].ToString(), dr[3].ToString(), ref szNewPwd, ref szErr);
                    if (!bRst)
                    {
                        MessageBox.Show("后台绑定新的结算卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        goto Eend;
                    }
                }

                //旧卡写DB
                if (mszFlag.ToUpper() == "USER_CARD")//换买方卡
                {
                    szSql = "update base_ucard CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID + ",card_flag='STOP' where user_card = '" + szCard + "'";
                }
                else//换卖方结算卡
                {
                    szSql = "update mng_card set CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID + ",card_flag='STOP' where CARD_TYPE = 3 and STORE_CARD = '" + szCard + "'";
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("换卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(this.Text + "换卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                //新卡写DB
                if (mszFlag.ToUpper() == "USER_CARD")//换买方卡
                {
                    //szSql = "update base_ucard set user_card = '" + textBox_Card_New.Text
                    //    + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID + " where user_card = '" + szCard + "'";
                    szSql = "insert into base_ucard(user_card, user_name, oper_time, USER_TEL, card_flag, CERT_ID, ADD_ID, rmrk, user_addr, card_type, parent_ID) "
                            + "(select '" + textBox_Card_New.Text + "', user_name, curtime(), USER_TEL, 'BGN', CERT_ID, " + MyStart.giUserID + ", rmrk, user_addr, card_type, parent_ID " +
                            "from base_ucard where user_card = '" + szCard + "')";
                }
                else//换卖方结算卡
                {
                    //szSql = "update mng_card set STORE_CARD = '" + textBox_Card_New.Text
                    //    + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID + " where CARD_TYPE = 3 and STORE_CARD = '" + szCard + "'";
                    szSql = "insert into mng_card(STORE_ID, STALL_ID, STORE_PERSON, USER_TEL, CARD_TYPE, STORE_CARD, CARD_STAT, ADD_DT, ADD_ID, CERT_ID, STALL_INF) "
                            + "(select STORE_ID, STALL_ID, STORE_PERSON, USER_TEL, 3, '" + szCard + "', 'BGN', curtime(),  " + MyStart.giUserID + ", CERT_ID, STALL_INF " +
                            "from mng_card where STORE_CARD = '" + szCard + "')";
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("换卡出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(this.Text + "换卡", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                MyFunc.WriteToDbLog(this.Text + "-换卡", "旧卡号" + szCard + ",新卡号" + textBox_Card_New.Text, "MSG", MyStart.giUserID);
                MessageBox.Show("换卡成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //收费记录
                if (checkBox_Fee.Checked && Convert.ToDecimal(textBox_Fee.Text) > 0)
                {
                    long lVal = (long)(Convert.ToDecimal(textBox_Fee.Text) * 100);
                    if (mszFlag.ToUpper() == "USER_CARD")//换买方卡
                    {
                        szSql = "insert into rec_user (card_no,oper_time,oper_type,chg_val,oper_id,tmn_id) values ('" + szCard
                                + "',curtime(),'CHG'," + lVal + "," + MyStart.giUserID + ",'" + frm_Main.POS_ID + "')";
                        iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                        if (iRst < 1)
                        {
                            MessageBox.Show("记录买方换卡工本费出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MyIniFile.WriteLog("买方换卡", "SQL=" + szSql + ",Err=" + szErr);
                            goto Eend;
                        }
                    }
                    else//换卖方结算卡
                    {
                        szSql = "select STORE_ID from mng_card where STORE_CARD='" + szCard + "'";
                        szErr = "";
                        iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                        if (iRst < 1)
                        {
                            MessageBox.Show("查找卖方换卡记录出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MyIniFile.WriteLog("卖方换卡", "SQL=" + szSql + ",Err=" + szErr);
                            goto Eend;
                        }
                        dr = ds.Tables[0].Rows[0];
                        int iFirmID = Convert.ToInt32(dr[0]);

                        szSql = "insert into rec_firm (card_no,store_id,oper_time,oper_type,chg_val,oper_id,tmn_id) values ('"
                                + MyStart.gszCardFirmFirst + szCard + "'," + iFirmID + ",curtime(),'CHG',"
                                + lVal + "," + MyStart.giUserID + ",'" + frm_Main.POS_ID + "')";
                        iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                        if (iRst < 1)
                        {
                            MessageBox.Show("记录卖方换卡工本费出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MyIniFile.WriteLog("卖方换卡", "SQL=" + szSql + ",Err=" + szErr);
                            goto Eend;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("更换卡片失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #14
0
        private void button_ChgPwd_Click(object sender, EventArgs e)
        {
            /*if (textBox_Old_Pwd.Text.Trim().ToUpper().CompareTo(MyStart.gszUserPwd.ToUpper()) != 0)
             * {
             *  MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *  textBox_Old_Pwd.Focus();
             *  return;
             * }*/

            if (textBox_New_Pwd.Text.CompareTo(textBox_2nd_Pwd.Text) != 0)
            {
                MessageBox.Show("两次输入的新密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_New_Pwd.Focus();
                return;
            }

            //读旧卡密码密文
            //string szSql = "";
            string szErr    = "";
            string szOldPwd = "";
            //if (mszFlag.ToUpper() == "USER_CARD")
            //{
            //    szSql = "select card_pwd,pwd_crypt from base_ucard where user_card='" + textBox_Card_ChgPwd.Text + "'";
            //}
            //else
            //{
            //    szSql = "select RMRK from mng_card where STORE_CARD='" + textBox_Card_ChgPwd.Text + "'";
            //}
            //DataSet ds = new DataSet();
            //int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
            //if (iRst != 0)
            //{
            //    MessageBox.Show("读取卡片信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    MyIniFile.WriteLog(this.Text + "-更改密码", "SQL=" + szSql + ",Err=" + szErr);
            //    return;
            //}
            //int iNum = ds.Tables[0].Rows.Count;
            //if (iNum < 1)
            //{
            //    MessageBox.Show("查不到卡片信息,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    button_Card_ChgPwd.Focus();
            //    return;
            //}
            //if (iNum > 1)
            //{
            //    MessageBox.Show("卡片信息错误,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    button_Card_ChgPwd.Focus();
            //    return;
            //}

            //DataRow dr = ds.Tables[0].Rows[0];
            //string[] szX;
            //if (mszFlag.ToUpper() == "USER_CARD")
            //{
            //    if (textBox_Old_Pwd.Text.Trim().ToUpper().CompareTo(dr[0].ToString().ToUpper()) != 0)
            //    {
            //        MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        textBox_Old_Pwd.Focus();
            //        return;
            //    }
            //    szOldPwd = dr[1].ToString();
            //}
            //else
            //{
            //    szX = dr[0].ToString().Split(',');
            //    if (textBox_Old_Pwd.Text.Trim().ToUpper().CompareTo(szX[0].ToString().ToUpper()) != 0)
            //    {
            //        MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        textBox_Old_Pwd.Focus();
            //        return;
            //    }
            //    szOldPwd = szX[1];
            //}
            //银石后台验密
            EbHttpClass objHttp = new EbHttpClass();
            bool        bRst    = objHttp.GetPwdCrypt(textBox_Card_ChgPwd.Text.Trim(), textBox_Old_Pwd.Text.Trim(), ref szOldPwd, ref szErr);

            if (!bRst)//szPwd != textBox_unlost_pwd.Text)
            {
                MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Old_Pwd.Focus();
                return;
            }

            //银石后台修改
            string szNewPwd = "1," + textBox_New_Pwd.Text;

            //EbHttpClass objHttp = new EbHttpClass();
            /*bool*/ bRst = objHttp.ChgPwd(textBox_Card_ChgPwd.Text, szOldPwd, ref szNewPwd, ref szErr);
            if (!bRst)
            {
                MessageBox.Show("后台修改卡片密码失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            /*新密码和密文写DB
             * //szNewPwd = textBox_New_Pwd.Text  + "," + szNewPwd;
             * if (mszFlag.ToUpper() == "USER_CARD")
             * {
             *  szSql = "update base_ucard set card_pwd='" + textBox_New_Pwd.Text + "',pwd_crypt='"
             + szNewPwd + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID
             + " where user_card='" + textBox_Card_ChgPwd.Text + "'";
             + }
             + else
             + {
             +  szNewPwd = textBox_New_Pwd.Text + "," + szNewPwd;
             +  szSql = "update mng_card set RMRK='" + szNewPwd + "',CHG_DT=curtime(),CHG_ID=" + MyStart.giUserID
             + " where CARD_TYPE=3 " + "and STORE_CARD='" + textBox_Card_ChgPwd.Text + "'";
             + }
             + try
             + {
             +  int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
             +  if (iRst < 1)
             +  {
             +      MessageBox.Show("更改密码失败(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             +      MyIniFile.WriteLog(this.Text + "-更改密码", "SQL=" + szSql + ",Err=" + szErr);
             +      goto Eend;
             +  }
             +
             + }
             + catch (Exception ex)
             + {
             +  MessageBox.Show("更改密码失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             + }
             + Eend:
             + MyStart.oMyDb.Close();*/
            MyFunc.WriteToDbLog(this.Text + "-更改密码", "卡号" + textBox_Card_ChgPwd.Text, "MSG", MyStart.giUserID);
            MessageBox.Show("更改密码成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #15
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询商品销售汇总", "", "MSG", MyStart.giUserID);
            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);

            dataGridViewRst.Rows.Clear();
            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "商品销售汇总表";
            }
            else
            {
                mszRptTitle = "商品销售汇总表";
            }

            string  szDateCondition = "jy_tim>='" + szBgn + "' and jy_tim<='" + szEnd + "'";
            DataSet ds = new DataSet();

            int iFirmNum = comboBox_Firm.Items.Count - 1;

            string[] szFirmID   = new string[iFirmNum]; //prod id
            string[] szFirmName = new string[iFirmNum];
            string[] szFirmCard = new string[iFirmNum]; //prod id
            int      iBgnRow    = 0;

            try
            {
                if (comboBox_Firm.SelectedIndex == 0)//all
                {
                    //2)get STORE_CARD
                    for (int i = 0; i < iFirmNum; i++)
                    {
                        string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                        szFirmID[i]   = szItem[0];
                        szFirmName[i] = szItem[1];
                        szFirmCard[i] = szFirmID[i];
                        //3)get data
                        if (szFirmCard[i].Trim().Length > 0)
                        {
                            WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow);
                        }
                    }
                    WriteSumToGrid(szDateCondition, ref iBgnRow);
                }
                else//only one firm
                {
                    //2)get STORE_CARD
                    string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                    szFirmID[0]   = szItem[0];
                    szFirmName[0] = szItem[1];
                    szFirmCard[0] = szFirmID[0];
                    //3)get data
                    if (szFirmCard[0].Trim().Length > 0)
                    {
                        WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow);
                    }
                }

                if (iBgnRow == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #16
0
        private void QryCash(string szBgn, string szEnd)
        {
            DataSet ds = new DataSet();

            int iFirmNum = comboBox_Firm.Items.Count - 1;

            string[] szFirmID   = new string[iFirmNum]; //prod id
            string[] szFirmName = new string[iFirmNum];
            string[] szFirmCard = new string[iFirmNum]; //prod id
            int      iBgnRow    = 0;

            try
            {
                if (comboBox_Firm.SelectedIndex == 0)//all
                {
                    //2)get STORE_CARD
                    for (int i = 0; i < iFirmNum; i++)
                    {
                        string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                        szFirmID[i]   = szItem[0];
                        szFirmName[i] = szItem[1];
                        szFirmCard[i] = szFirmID[i];
                        //3)get data
                        if (szFirmCard[i].Trim().Length > 0)
                        {
                            WriteDataToGrid2(szFirmName[i], szFirmID[i], szBgn, szEnd, ref iBgnRow);
                        }
                    }

                    Decimal[] dItem = new Decimal[miCols - 1];
                    for (int i = 0; i < iBgnRow - 1; i++)
                    {
                        for (int j = 0; j < miCols - 1; j++)
                        {
                            dItem[j] += Convert.ToDecimal(dataGridViewRst.Rows[i].Cells[j + 1].Value);
                        }
                    }
                    string szText = "合计";
                    for (int index = 0; index < miCols - 1; index++)
                    {
                        szText += "#" + dItem[index].ToString("#0,000.00");
                    }
                    MyFunc.GridWriteData(ref dataGridViewRst, szText, ref iBgnRow);
                }
                else//only one firm
                {
                    //2)get STORE_CARD
                    string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                    szFirmID[0]   = szItem[0];
                    szFirmName[0] = szItem[1];
                    szFirmCard[0] = szFirmID[0];
                    //3)get data
                    if (szFirmCard[0].Trim().Length > 0)
                    {
                        WriteDataToGrid2(szFirmName[0], szFirmID[0], szBgn, szEnd, ref iBgnRow);
                    }
                }

                if (iBgnRow == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #17
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("请确认要保存该档口信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string szSql;
            string szTitle;
            string szErr = "";
            int    iRst;

            string[] szItem = comboBox_Name.Text.Split('-');
            if (comboBox_Name.Enabled)//add
            {
                /*if (textBox_Cert.TextLength == 0)
                 * {
                 *  MessageBox.Show("请输入卖方联系人身份证号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 *  textBox_Cert.SelectAll();
                 *  textBox_Cert.Focus();
                 *  return;
                 * }
                 * if (textBox_Cell.TextLength == 0)
                 * {
                 *  MessageBox.Show("请输入卖方联系电话", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 *  textBox_Cell.SelectAll();
                 *  textBox_Cell.Focus();
                 *  return;
                 * }*/
                szTitle = "卖方档口信息-新增";
                szSql   = "INSERT INTO base_stall(STORE_ID,STALL_INF,STALL_PERSON,STALL_TEL,RENT_BGN,STALL_STAT) VALUES "
                          + "(" + szItem[0].Trim() + ",'" + textBox_Desc.Text.Trim() + "','"
                          + textBox_Person.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "','"
                          + dateTimePicker_valid.Value + "','USED')";
            }
            else//edit
            {
                szTitle = "卖方档口信息-修改";
                if (radioButton_Bgn.Checked)
                {
                    mszBgn = dateTimePicker_valid.Value.ToString();
                }
                szSql = "UPDATE base_stall SET STORE_ID = " + szItem[0].Trim()
                        + ",STALL_PERSON = '" + textBox_Person.Text.Trim()
                        + "',STALL_TEL = '" + textBox_Cell.Text.Trim()
                        + "',STALL_INF = '" + textBox_Desc.Text.Trim() + "',";
                if (radioButton_Bgn.Checked)
                {
                    szSql += "RENT_BGN='" + dateTimePicker_valid.Value + "' ";
                }
                if (radioButton_End.Checked)
                {
                    if (dateTimePicker_valid.Value <= Convert.ToDateTime(mszBgn))
                    {
                        MessageBox.Show("退租日期应该晚于租用日期,请重新设置", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dateTimePicker_valid.Focus();
                        return;
                    }
                    szSql += "RENT_END='" + dateTimePicker_valid.Value + "' ";

                    if (dateTimePicker_valid.Value <= DateTime.Now)
                    {
                        szSql += ",STALL_STAT='STOP' ";
                    }
                }
                szSql += " WHERE STALL_ID=" + textBox_Code.Text.Trim();
            }
            try
            {
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                }
                else
                {
                    szSql = "卖方名:" + comboBox_Name.Text + "-档口信息:" + textBox_Code.Text + textBox_Desc.Text;
                    MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID);

                    MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridDataRefresh(Convert.ToInt16(mszSotreID));
                    //dataGridView1.Refresh();
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存档口信息失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            MyStart.oMyDb.Close();

            groupBoxInf.Enabled  = false;
            groupBoxList.Enabled = true;

            textBox_Code.Text   = mszCode;
            comboBox_Name.Text  = mszName;
            textBox_Person.Text = mszPerson;
            textBox_Cell.Text   = mszCell;
            //if(radioButton_Bgn.Checked)
            //dateTimePicker_valid.Text = mszBgn;
            textBox_Desc.Text = mszInf;
        }
Beispiel #18
0
        private void WriteDataToGrid2(string szFirmName, string szID, string szBgn, string szEnd, ref int iBgnRow)
        {
            /*   string szSql = "select b.USER_NAME,if (oper_type = 'ADD','买方充值',"
             + "if (oper_type = 'TRADE','买方消费',if (oper_type = 'CASH','买方取现',if (oper_type='CHG','买方换卡','买方取消交易')))),"
             + "format(sum(chg_val)/100,2) from rec_user a,sys_users b "
             + "where a.Oper_ID = b.USER_ID and b.USER_NAME = '" + szFirmName + "' and " + szDateCondition + " group by oper_type "
             + "union "
             + "select b.USER_NAME,if (oper_type = 'ADD','卖方充值',"
             + "if (oper_type = 'TRADE','卖方消费',if (oper_type = 'CASH','卖方取现',if (oper_type='CHG','卖方换卡','卖方取消交易')))),"
             + "format(sum(chg_val)/100,2) from rec_firm a,sys_users b "
             + "where a.Oper_ID = b.USER_ID and b.USER_NAME = '" + szFirmName + "' and " + szDateCondition + " group by oper_type "
             + "union "
             + "select '小计','-','-' from dual";*/
            /*select z.USER_ID, z.USER_NAME,i as 买方提现,k as 卖方充值,l as 卖方提现,k-i-l as 结合
             * from
             * (sys_users z
             * left join
             * (select a.Oper_ID as h,sum(a.Chg_Val) as i from rec_firm a where a.Oper_Type='TRADE' group by a.Oper_ID) x
             * on z.USER_ID=x.h)
             * left join
             * (select b.Oper_ID as j,sum(b.Chg_Val) as k,sum(c.Chg_Val) as l from rec_user b,rec_user c
             * where b.Oper_ID=c.Oper_ID and b.Oper_Type='ADD' and c.Oper_Type='CASH' group by b.Oper_ID,c.Oper_ID) y
             * on z.USER_ID=y.j
             * where z.USER_STAT='USED' */

            Int64[] iItem = new Int64[miCols - 1];
            string  szSql = "select Oper_ID,sum(Chg_Val) from rec_user where Oper_Type='ADD' and Oper_ID=" + szID
                            + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'";

            string  szErr = "";
            DataSet ds    = new DataSet();
            int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            if (iRst != 0)
            {
                MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("查询收银记录", "SQL=" + szSql + ",Err=" + szErr);
                MyStart.oMyDb.Close();
                return;
            }
            DataRow dr = ds.Tables[0].Rows[0];

            try
            {
                iItem[0] = Convert.ToInt64(dr[1]);//买方充值
            }
            catch
            {
                iItem[0] = 0;
            }
            iItem[1] = iItem[0];//收入结余

            szSql = "select Oper_ID,sum(Chg_Val) from rec_user where Oper_Type='CASH' and Oper_ID=" + szID
                    + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'";
            szErr = "";
            iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
            if (iRst != 0)
            {
                MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("查询收银记录", "SQL=" + szSql + ",Err=" + szErr);
                MyStart.oMyDb.Close();
                return;
            }
            dr = ds.Tables[0].Rows[0];
            try
            {
                iItem[2] = Convert.ToInt64(dr[1]);//买方提现
            }
            catch
            {
                iItem[2] = 0;
            }

            szSql = "select Oper_ID,sum(Chg_Val) from rec_firm where Oper_Type='CASH' and Oper_ID=" + szID
                    + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'";
            szErr = "";
            iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
            if (iRst != 0)
            {
                MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("查询收银记录", "SQL=" + szSql + ",Err=" + szErr);
                MyStart.oMyDb.Close();
                return;
            }
            dr = ds.Tables[0].Rows[0];
            try
            {
                iItem[3] = Convert.ToInt64(dr[1]);//卖方提现
            }
            catch
            {
                iItem[3] = 0;
            }
            iItem[4] = iItem[2] + iItem[3]; //支出结余
            iItem[5] = iItem[1] - iItem[4]; //总结余

            szSql = szID + "-" + szFirmName;
            for (int index = 0; index < miCols - 1; index++)
            {
                szSql += "#" + ((decimal)iItem[index] / 100).ToString("0,000.00");
            }
            MyFunc.GridWriteData(ref dataGridViewRst, szSql, ref iBgnRow);
        }
Beispiel #19
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询发卡明细", "", "MSG", MyStart.giUserID);

            dataGridView_Detail.Columns.Clear();
            dataGridView_Detail.DataSource = null;
            MyFunc.GridInit(ref dataGridView_Detail, mszTitle, mszTitleWidth, 15, miDefRows, true);

            int iFirmNum = comboBox_Firm.Items.Count - 1;

            string[] szFirmID = new string[iFirmNum];
            //string[] szFirmName = new string[iFirmNum];
            string[] szFirmCard  = new string[iFirmNum];
            int      iBgnRow     = 0;
            int      iCardNum    = 0;
            int      iAllCardNum = 0;
            int      iCurLine    = 0;
            bool     bHasCard    = false;
            int      iDoFirm     = 0;

            dataGridView_Detail.Rows.Clear();
            MyFunc.GridInit(ref dataGridView_Detail, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (comboBox_Firm.SelectedIndex == 0)//all
            {
                //2)get STORE_CARD
                for (int i = 0; i < iFirmNum; i++)
                {
                    string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                    szFirmID[i] = szItem[0];
                    //szFirmName[i] = szItem[1];
                    szFirmCard[i] = Get_STORE_CARD(szFirmID[i], "");
                    //if(Convert.ToInt16( szFirmID[i])>160)
                    //{
                    //    ;
                    //}
                    //3)get data
                    iCardNum = 0;
                    bHasCard = false;
                    if (szFirmCard[i].Trim().Length > 16)
                    {
                        WriteDataToGrid(comboBox_Firm.Items[i + 1].ToString(), szFirmCard[i], "", ref iBgnRow, ref iCardNum, ref bHasCard);
                    }
                    if (bHasCard)
                    {
                        iDoFirm++;
                    }
                    iAllCardNum += iCardNum;
                    //iCurLine += iCardNum + 1;
                }
                DataTable dt = new DataTable();
                for (int i = 0; i < miCols; i++)
                {
                    dt.Columns.Add(i.ToString(), Type.GetType("System.String"));
                }
                dt.Rows.Add(new object[] { "合计 " + iDoFirm + " 卖方已发卡", "", "", "发卡总数 " + iAllCardNum + " 张", "", "", "", "", "" });

                //int iRtnNum = iCurLine;
                MyFunc.GridWriteDt(ref dataGridView_Detail, ref dt, iBgnRow, miCols, ref iCurLine);
                groupBox3.Text = "发卡明细:总卖方数 " + iFirmNum + " 户,已发卡卖方 " + iDoFirm + " 户,发卡总数 " + iAllCardNum + " 张";
            }
            else//only one firm
            {
                if (comboBox_Stall.SelectedIndex == 0)//all
                {//2)get STORE_CARD
                    string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                    szFirmID[0] = szItem[0];
                    //szFirmName[0] = szItem[1];
                    szFirmCard[0] = Get_STORE_CARD(szFirmID[0], "");
                    //3)get data
                    iCardNum = 0;
                    if (szFirmCard[0].Trim().Length > 0)
                    {
                        WriteDataToGrid(comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString(), szFirmCard[0], "", ref iBgnRow, ref iCardNum, ref bHasCard);
                    }

                    groupBox3.Text = "发卡明细:该卖方发卡总数 " + iCardNum + " 张";
                }
                else
                {
                    string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                    szFirmID[0] = szItem[0];
                    string[] szX      = comboBox_Stall.Items[comboBox_Stall.SelectedIndex].ToString().Split('-');
                    string   szRentID = szX[0];
                    //szFirmName[0] = szItem[1];
                    szFirmCard[0] = Get_STORE_CARD(szFirmID[0], szRentID);
                    //3)get data
                    iCardNum = 0;
                    if (szFirmCard[0].Trim().Length > 0)
                    {
                        WriteDataToGrid(comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString(), szFirmCard[0], "", ref iBgnRow, ref iCardNum, ref bHasCard);
                    }

                    groupBox3.Text = "发卡明细:该档口发卡总数 " + iCardNum + " 张";
                }
            }
            if (dataGridView_Detail.RowCount > 0)
            {
                button_Rpt.Enabled = true;
            }
            miRows = iBgnRow + 1;
        }
Beispiel #20
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            string szCard = textBox_Card.Text;

            if (szCard.Length == 15)
            {
                szCard = MyStart.gszCardFirmFirst + textBox_Card.Text;
            }

            DataSet ds    = new DataSet();
            string  szErr = "";
            string  szSql = "select a.ADD_DT,CARD_STAT,a.STORE_PERSON,a.user_tel,a.cert_id,CARD_TYPE,a.STORE_ID,STORE_NAME,c.USER_NAME "
                            + "from mng_card a,base_store b, sys_users c where a.ADD_ID=c.USER_ID "
                            + "and a.STORE_ID=b.STORE_ID and STORE_CARD='" + szCard + "'";

            try
            {
                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("卖方卡查询失败,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_time.Text   = "";
                    textBox_stat.Text   = "";
                    textBox_Firm.Text   = "";
                    textBox_Person.Text = "";
                    textBox_Cell.Text   = "";
                    textBox_CertID.Text = "";
                    textBoxOper.Text    = "";
                    dataGridView1.Rows.Clear();
                    MyFunc.GridInit(ref dataGridView1, "发卡时间,卡号,卡类,卡片状态,档口联系人,联系电话,身份证,开卡人", "1,1,1,1,1,1,1,1", 15, 15, true);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum == 0)
                {
                    MessageBox.Show("系统无此卖方卡信息,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_time.Text   = "";
                    textBox_stat.Text   = "";
                    textBox_Firm.Text   = "";
                    textBox_Person.Text = "";
                    textBox_Cell.Text   = "";
                    textBox_CertID.Text = "";
                    textBoxOper.Text    = "";
                    dataGridView1.Rows.Clear();
                    MyFunc.GridInit(ref dataGridView1, "发卡时间,卡号,卡类,卡片状态,档口联系人,联系电话,身份证,开卡人", "1,1,1,1,1,1,1,1", 15, 15, true);
                    goto Eend;
                }

                DataRow dr = ds.Tables[0].Rows[0];
                textBox_time.Text = dr[0].ToString();
                switch (dr[1].ToString().ToUpper())
                {
                case "BGN": textBox_stat.Text = "正常"; break;

                case "LOST": textBox_stat.Text = "挂失"; break;

                default: textBox_stat.Text = "无效"; break;
                }
                textBox_Person.Text = dr[2].ToString();
                textBox_Cell.Text   = dr[3].ToString();
                textBox_CertID.Text = dr[4].ToString();
                switch (Convert.ToInt16(dr[5]))
                {
                case 1: textBox_Type.Text = "第一副卡"; break;

                case 2: textBox_Type.Text = "副卡"; break;

                default: textBox_Type.Text = "结算卡"; break;
                }
                textBox_Firm.Text = dr[7].ToString();
                textBoxOper.Text  = dr[8].ToString();
                //ds = null;

                int iFirmID = Convert.ToInt16(dr[6]);
                szSql = "SELECT b.ADD_DT as 发卡时间,STORE_CARD as 卡号,"
                        + "if (CARD_TYPE = 1,'第一副卡','结算卡') as 卡类,"
                        + "if (CARD_STAT = 'BGN','正常',if (CARD_STAT = 'STOP','无效','挂失')) as 状态,"
                        + "STORE_PERSON as 联系人,b.USER_TEL as 联系电话,b.cert_id as 身份证,c.USER_NAME as 开卡人 "
                        + "FROM mng_card b, sys_users c where b.ADD_ID=c.USER_ID and b.CARD_TYPE<>2 and b.STORE_ID = " + iFirmID
                        + " UNION "
                        + "SELECT b.ADD_DT as 发卡时间,STORE_CARD as 卡号,"
                        + "'副卡' as 卡类,"
                        + "if (CARD_STAT = 'BGN','正常',if (CARD_STAT = 'STOP','无效','挂失')) as 状态,"
                        + "STORE_PERSON as 联系人,b.USER_TEL as 联系电话,b.cert_id as 身份证,c.USER_NAME as 开卡人 "
                        + "FROM base_stall a,mng_card b, sys_users c where b.ADD_ID=c.USER_ID and b.CARD_TYPE=2 and a.STORE_ID = b.STORE_ID and b.STORE_ID = " + iFirmID;
                //+"order by CARD_TYPE,CARD_ID desc";
                iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    goto Eend;
                }

                DataTable dt = ds.Tables[0];
                dataGridView1.Columns.Clear();//
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("卖方卡查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #21
0
        private void SetMenu()
        {
            bool[,] bDispMenu = new bool[iMainMenuNum, iSubMenuMaxNum];
            MyFunc.GetApp(MyStart.gszUserApp, ref bDispMenu);

            ToolStripMenuItemParaSys.Visible = bDispMenu[0, 0];
            ToolStripMenuItemParaRun.Visible = bDispMenu[0, 1];
            ToolStripMenuItemParaKey.Visible = bDispMenu[0, 2];
            ToolStripMenuItem_Setup.Visible  = bDispMenu[0, 0] || bDispMenu[0, 1] || bDispMenu[0, 2];

            ToolStripMenuItemUserNet.Visible = bDispMenu[1, 0];
            ToolStripMenuItemUserInf.Visible = bDispMenu[1, 1];
            ToolStripMenuItemUserApp.Visible = bDispMenu[1, 2];
            ToolStripMenuItemUserLog.Visible = bDispMenu[1, 3];
            ToolStripMenuItem_Worker.Visible = bDispMenu[1, 0] || bDispMenu[1, 1] || bDispMenu[1, 2] || bDispMenu[1, 3];

            ToolStripMenuItemProdType.Visible  = bDispMenu[2, 0];
            ToolStripMenuItemProdBase.Visible  = bDispMenu[2, 1];
            ToolStripMenuItemProdFee.Visible   = bDispMenu[2, 2];
            ToolStripMenuItem_Material.Visible = bDispMenu[2, 0] || bDispMenu[2, 1] || bDispMenu[2, 2];

            ToolStripMenuItemFirmBase.Visible          = bDispMenu[3, 0];
            ToolStripMenuItemFirmRent.Visible          = bDispMenu[3, 1];
            ToolStripMenuItemFirmCard.Visible          = bDispMenu[3, 2];
            ToolStripMenuItemFirmQry.Visible           = bDispMenu[3, 3];
            ToolStripMenuItemFirmQryCard.Visible       = bDispMenu[3, 4];
            ToolStripMenuItemFirmCard_Mng.Visible      = bDispMenu[3, 5];
            ToolStripMenuItemFirmCard_Trade.Visible    = false; //bDispMenu[3, 6];
            ToolStripMenuItemFirmCard_Cash.Visible     = false;
            ToolStripMenuItemFirmCard_QryVal.Visible   = false;
            ToolStripMenuItemFirmCard_QryTrade.Visible = false;
            ToolStripMenuItem_Firm.Visible             = bDispMenu[3, 0] || bDispMenu[3, 1] || bDispMenu[3, 2] || bDispMenu[3, 3] ||
                                                         bDispMenu[3, 4] || bDispMenu[3, 5] || bDispMenu[3, 6];

            ToolStripMenuItem_Firm_M_Trans.Visible    = bDispMenu[4, 0];
            ToolStripMenuItem_Firm_M_QryVal.Visible   = bDispMenu[4, 1];
            ToolStripMenuItem_Firm_M_Cash.Visible     = bDispMenu[4, 2];
            ToolStripMenuItem_Firm_M_QryTrade.Visible = bDispMenu[4, 3];
            ToolStripMenuItem_Firm_Money.Visible      = bDispMenu[4, 0] || bDispMenu[4, 1] || bDispMenu[4, 2] || bDispMenu[4, 3];

            ToolStripMenuItemClient_Card.Visible     = bDispMenu[5, 0];
            ToolStripMenuItemClient_Qry.Visible      = bDispMenu[5, 1];
            ToolStripMenuItemClient_QryCard.Visible  = bDispMenu[5, 2];
            ToolStripMenuItemClient_Mng.Visible      = bDispMenu[5, 3];
            ToolStripMenuItemClient_Add.Visible      = false;
            ToolStripMenuItemClient_Cash.Visible     = false;
            ToolStripMenuItemClient_QryVal.Visible   = false;
            ToolStripMenuItemClient_QryTrade.Visible = false;
            ToolStripMenuItem_User.Visible           = bDispMenu[5, 0] || bDispMenu[5, 1] || bDispMenu[5, 2] || bDispMenu[5, 3];

            ToolStripMenuItem_User_M_QryVal.Visible   = bDispMenu[6, 0];
            ToolStripMenuItem_User_M_Add.Visible      = bDispMenu[6, 1];
            ToolStripMenuItem_User_M_Minus.Visible    = bDispMenu[6, 2];
            ToolStripMenuItem_User_M_QryTrade.Visible = bDispMenu[6, 3];
            ToolStripMenuItem_User_Money.Visible      = bDispMenu[6, 0] || bDispMenu[6, 1] || bDispMenu[6, 2] || bDispMenu[6, 3];

            ToolStripMenuItemQryMkt.Visible    = bDispMenu[7, 0];
            ToolStripMenuItemQryFirm.Visible   = bDispMenu[7, 1];
            ToolStripMenuItemQryUser.Visible   = bDispMenu[7, 2];
            ToolStripMenuItemQryProd.Visible   = bDispMenu[7, 3];
            ToolStripMenuItemQryPos.Visible    = bDispMenu[7, 4];
            ToolStripMenuItemQryDetail.Visible = bDispMenu[7, 5];
            ToolStripMenuItemQryCard.Visible   = bDispMenu[7, 6];
            ToolStripMenuItem_Search.Visible   = bDispMenu[7, 0] || bDispMenu[7, 1] || bDispMenu[7, 2] ||
                                                 bDispMenu[7, 3] || bDispMenu[7, 4] || bDispMenu[7, 5] || bDispMenu[7, 6];

            ToolStripMenuItemRptICAdd.Visible = bDispMenu[8, 0];
            ToolStripMenuItemRptAdd.Visible   = bDispMenu[8, 1];
            ToolStripMenuItemRptMinus.Visible = bDispMenu[8, 2];
            ToolStripMenuItemRptPos.Visible   = bDispMenu[8, 3];
            ToolStripMenuItem_Rpt.Visible     = bDispMenu[8, 0] || bDispMenu[8, 1] || bDispMenu[8, 2] || bDispMenu[8, 3];

            ToolStripMenuItemDutyPwd.Visible   = bDispMenu[9, 0];
            ToolStripMenuItemDutyPause.Visible = bDispMenu[9, 1];
            ToolStripMenuItemDutyQry.Visible   = bDispMenu[9, 2];
            ToolStripMenuItem_Onduty.Visible   = bDispMenu[9, 0] || bDispMenu[9, 1] || bDispMenu[9, 2];
        }
Beispiel #22
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("请确认要保存该商品信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string szSql;
            string szTitle;

            string[] szType = comboBox_Type.Text.Split('-');
            int      iCode  = 0xff;

            try
            {
                iCode = Convert.ToInt16(textBox_Code.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("商品的编号输入错误(" + ex.ToString() + "),请重新设置", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (textBox_Code.Enabled)//add
            {
                bool bSameID = false;
                int  iNum    = dataGridView1.Rows.Count;
                for (int i = 0; i < iNum; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value != null)
                    {
                        if (dataGridView1.Rows[i].Cells[0].Value.ToString() == iCode.ToString())
                        {
                            bSameID = true;
                            break;
                        }
                    }
                }
                if (bSameID)
                {
                    MessageBox.Show("商品的编号不能重复,请重新设置", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox_Code.SelectAll();
                    textBox_Code.Focus();
                    return;
                }

                szTitle = "商品基本信息-新增";
                szSql   = "INSERT INTO base_prod(PROD_ID,PROD_NAME,PROD_LEVEL,PROD_ORIGIN,PROD_RMRK,PARENT_ID) VALUES("
                          + iCode + ",'" + textBox_Name.Text.Trim() + "',1,'"
                          + textBox_Origin.Text.Trim() + "','" + textBox_Desc.Text.Trim()
                          + "'," + szType[0] + ")";
            }
            else//edit
            {
                szTitle = "商品基本信息-修改";
                szSql   = "UPDATE base_prod SET PROD_NAME='" + textBox_Name.Text.Trim()
                          + "',PROD_RMRK = '" + textBox_Desc.Text.Trim()
                          + "',PROD_ORIGIN = '" + textBox_Origin.Text.Trim()
                          + "',PARENT_ID = " + szType[0]
                          + " WHERE PROD_ID=" + iCode;
            }
            string szErr = "";

            try
            {
                int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                }
                else
                {
                    szSql = "编号" + mszCode + "-品名" + mszName;
                    MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID);

                    MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridDataRefresh();
                    //dataGridView1.Refresh();
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK");
                }
                groupBoxInf.Enabled  = false;
                groupBoxList.Enabled = true;

                textBox_Code.Text   = mszCode;
                textBox_Name.Text   = mszName;
                comboBox_Type.Text  = mszType;
                textBox_Origin.Text = mszOrigin;
                textBox_Desc.Text   = mszInf;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            MyStart.oMyDb.Close();
        }
Beispiel #23
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("请确认要保存该卖方信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string szSql;
            string szTitle;
            string szErr = "";
            int    iRst;

            string[] szItem = comboBox_Cert.Text.Split(',');
            try
            {
                if (IsNew)// textBox_Name.Enabled)//add
                {
                    szTitle = "卖方基本信息-新增";
                    if (textBox_Cert.TextLength == 0)
                    {
                        MessageBox.Show("请输入卖方联系人身份证号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox_Cert.SelectAll();
                        textBox_Cert.Focus();
                        return;
                    }
                    if (textBox_Cell.TextLength == 0)
                    {
                        MessageBox.Show("请输入卖方联系电话", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox_Cell.SelectAll();
                        textBox_Cell.Focus();
                        return;
                    }
                    szSql = "select * from base_store where STORE_NAME='" + textBox_Name.Text.Trim() + "'";
                    DataSet ds = new DataSet();
                    iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst < 0)
                    {
                        MessageBox.Show("查询信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        MessageBox.Show("卖方名称不能重复,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=卖方名称不能重复,请重新输入");
                        textBox_Name.SelectAll();
                        textBox_Name.Focus();
                        goto Eend;
                    }

                    szSql = "INSERT INTO base_store(STORE_NAME,STORE_ADDR,STORE_BOSS,STORE_TEL,CERT_TYPE,CERT_ID,CERT_VALID,"
                            + "STORE_PERSON,STORE_CELL,STORE_TYPE,CITY,RMRK,STORE_STAT) VALUES "
                            + "('" + textBox_Name.Text.Trim() + "','" + textBox_Addr.Text.Trim() + "','"
                            + textBox_Boss.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "',"
                            + Convert.ToInt16(szItem[0]) + ",'" + textBox_Cert.Text.Trim() + "','" + dateTimePicker_valid.Value + "','"
                            + textBox_Person.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "',"
                            + comboBox_Type.SelectedIndex + 1 + ",'ZHONGSHAN','" + textBox_Desc.Text.Trim() + "','USED')";
                }
                else//edit
                {
                    szTitle = "卖方基本信息-修改";
                    szSql   = "UPDATE base_store set STORE_ADDR = '" + textBox_Addr.Text.Trim()
                              + "',STORE_NAME = '" + textBox_Name.Text.Trim()
                              + "',STORE_BOSS = '" + textBox_Boss.Text.Trim()
                              + "',STORE_TEL = '" + textBox_Cell.Text.Trim()
                              + "',CERT_TYPE = " + Convert.ToInt16(szItem[0])
                              + ",CERT_ID = '" + textBox_Cert.Text.Trim()
                              + "',CERT_VALID = '" + dateTimePicker_valid.Value
                              + "',STORE_PERSON = '" + textBox_Person.Text.Trim()
                              + "',STORE_CELL = '" + textBox_Cell.Text.Trim()
                              + "',STORE_TYPE = " + (comboBox_Type.SelectedIndex + 1)
                              + ",RMRK = '" + textBox_Desc.Text.Trim()
                              + "' WHERE STORE_ID=" + textBox_Code.Text.Trim();
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                }
                else
                {
                    szSql = "编号" + textBox_Code.Text + "-卖方名" + textBox_Name.Text;
                    MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID);

                    MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridDataRefresh();
                    //dataGridView1.Refresh();
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK");
                }
                groupBoxInf.Enabled  = false;
                groupBoxList.Enabled = true;

                textBox_Code.Text         = mszCode;
                textBox_Name.Text         = mszName;
                textBox_Addr.Text         = mszAddr;
                textBox_Boss.Text         = mszBoss;
                comboBox_Cert.Text        = mszCertType;
                textBox_Cert.Text         = mszCert;
                dateTimePicker_valid.Text = mszValid;
                textBox_Person.Text       = mszPerson;
                textBox_Cell.Text         = mszCell;
                comboBox_Type.Text        = mszType;
                textBox_Desc.Text         = mszInf;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #24
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            //dataGridViewRst.Rows.Clear();
            //MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName;
            }

            MyFunc.WriteToDbLog("查询开卡汇总", "", "MSG", MyStart.giUserID);
            if (radioButton_buyer.Checked)
            {
                mszRptTitle += "买方开卡汇总表";
            }
            if (radioButton_seller.Checked)
            {
                mszRptTitle += "卖方开卡汇总表";
            }

            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);
            string szBuyerDateCondition  = "a.oper_time>='" + szBgn + "' and a.oper_time<='" + szEnd + "' ";
            string szSellerDateCondition = "a.ADD_DT>='" + szBgn + "' and a.ADD_DT<='" + szEnd + "' ";
            string szSqlItem             = "select A1 as '开卡人',A2 as '开卡时间',A3 as '类型',A4 as '持卡人',A5 as '卡号',A6 as '卡类'," +
                                           "if (A7 = '-','-',(if (A7 = 'BGN','正常','停用'))) as '卡状态',format(A8 / 100, 2) as '收费金额(元)' ";
            string szSqlBuyerDetail = "select b.USER_NAME as A1,a.oper_time as A2,'买方' as A3,a.user_name as A4,user_card as A5," +
                                      "if(card_type=1,'主卡','副卡') as A6,card_flag as A7,Chg_Val as A8 " +
                                      "from base_ucard a ,sys_users b, rec_user c " +
                                      "where a.ADD_ID = b.USER_ID and a.user_card = c.Card_No and c.Oper_Type = 'ISSU' and " + szBuyerDateCondition + " ";
            string szSqlSellerDetail = "select b.USER_NAME as A1,a.ADD_DT as A2,'卖方' as A3,a.STORE_PERSON as A4,STORE_CARD as A5," +
                                       "if (card_type = 3,'结算卡',(if (card_type = 1,'第一副卡','副卡'))) as A6,CARD_STAT as A7,Chg_Val as A8 " +
                                       "from mng_card a,sys_users b, rec_firm c " +
                                       "where a.ADD_ID = b.USER_ID and a.STORE_CARD = c.Card_No and c.Oper_Type = 'ISSU' and " + szSellerDateCondition + " ";
            string szSqlBuyerSum = "select b.USER_NAME as A1,a.oper_time as A2,'买方' as A3,a.user_name as A4,user_card as A5,card_type as A6,card_flag as A7,Chg_Val as A8 " +
                                   "from base_ucard a ,sys_users b, rec_user c " +
                                   "where a.ADD_ID = b.USER_ID and a.user_card = c.Card_No and c.Oper_Type = 'ISSU' and " + szBuyerDateCondition + " ";
            string szSqlSellerSum = "select b.USER_NAME as A1,a.ADD_DT as A2,'卖方' as A3,a.STORE_PERSON as A4,STORE_CARD as A5,card_type as A6,CARD_STAT as A7,Chg_Val as A8 " +
                                    "from mng_card a,sys_users b, rec_firm c " +
                                    "where a.ADD_ID = b.USER_ID and a.STORE_CARD = c.Card_No and c.Oper_Type = 'ISSU' and " + szSellerDateCondition + " ";
            string szSql = "";

            if (radioButton_all.Checked)
            {
                szSql = szSqlItem + " from ( " +
                        szSqlBuyerDetail +
                        " union " + szSqlSellerDetail +
                        " union (select A1,'-','-','小计',count(A2),'-','-',sum(A8)  from ( " + szSqlBuyerSum + " union " + szSqlSellerSum + " )M group by A1) " +
                        " union (select '-','-','-','合计',count(A2),'-','-',sum(A8)  from ( " + szSqlBuyerSum + " union " + szSqlSellerSum + " )N ) " +
                        ") Z ";
                //if (comboBox_POS.SelectedIndex > 0)
                //{
                //    string[] szX = comboBox_POS.Text.Split('-');
                //    szSql += "where Z.A1='"+szX[1].Trim()+"' ";
                //}
                //szSql += "order by Z.A1 desc, Z.A2 desc";
            }

            if (radioButton_buyer.Checked)
            {
                string szName = " and a.user_name ";
                //if (comboBox_Buyer.SelectedIndex <0)
                //    szName += "like '%" + textBox_buyer.Text.Trim() + "%' ";
                //else
                //{
                string[] szX = comboBox_Buyer.Text.Split('-');
                szName += "='" + szX[1].Trim() + "' ";
                //}
                szSql = szSqlItem + " from ( " +
                        szSqlBuyerDetail + szName +
                        " union (select A1,'-','-','小计',count(A2),'-','-',sum(A8)  from ( " + szSqlBuyerSum + szName + " )M group by A1) " +
                        " union (select '-','-','-','合计',count(A2),'-','-',sum(A8)  from ( " + szSqlBuyerSum + szName + " )N ) " +
                        ") Z ";
                //if (comboBox_POS.SelectedIndex > 0)
                //{
                //    string[] szX = comboBox_POS.Text.Split('-');
                //    szSql += "where Z.A1='" + szX[1].Trim() + "' ";
                //}
                //szSql += "order by Z.A1 desc, Z.A2 desc";
            }
            if (radioButton_seller.Checked)
            {
                string   szName = " and a.STORE_PERSON ";
                string[] szX    = comboBox_Buyer.Text.Split('-');
                szName += "='" + szX[1].Trim() + "' ";
                //}
                szSql = szSqlItem + " from ( " +
                        szSqlSellerDetail + szName +
                        " union (select A1,'-','-','小计',count(A2),'-','-',sum(A8)  from ( " + szSqlSellerSum + szName + " )M group by A1) " +
                        " union (select '-','-','-','合计',count(A2),'-','-',sum(A8)  from ( " + szSqlSellerSum + szName + " )N ) " +
                        ") Z ";
            }

            if (comboBox_POS.SelectedIndex > 0)
            {
                string[] szX = comboBox_POS.Text.Split('-');
                szSql += "where Z.A1='" + szX[1].Trim() + "' ";
            }
            szSql += "order by Z.A1 desc, Z.A2 desc";
            try
            {
                DataSet ds    = new DataSet();
                string  szErr = "";
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询开卡汇总", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                DataTable dt = ds.Tables[0];
                if (dataGridViewRst.Columns.Count > 0)
                {
                    dataGridViewRst.Columns.Clear();
                }
                dataGridViewRst.DataSource = dt;
                dataGridViewRst.Refresh();

                int iNum = dt.Rows.Count;
                if (iNum == 0)
                {
                    button_Rpt.Enabled = false;
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                //int iCurNum = (iNum < miDefRows ? miDefRows : iNum);
                //int iBgnRow = 0;
                ////MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum);
                //iBgnRow += iNum;

                //if (iBgnRow == 0)
                //    goto Eend;


                miRows             = iNum;// iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #25
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询买方交易汇总", "", "MSG", MyStart.giUserID);
            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);

            dataGridViewRst.Rows.Clear();
            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "买方交易汇总表";
            }
            else
            {
                mszRptTitle = "买方交易汇总表";
            }

            string  szDateCondition = "jy_tim>='" + szBgn + "' and jy_tim<='" + szEnd + "'";
            DataSet ds = new DataSet();

            int iFirmNum = comboBox_Firm.Items.Count - 1;

            string[] szFirmID   = new string[iFirmNum]; //user card id
            string[] szFirmName = new string[iFirmNum];
            string[] szFirmCard = new string[iFirmNum]; //user card id
            int      iBgnRow    = 0;

            try
            {
                if (radioButton_Sel.Checked)
                {
                    if (comboBox_Firm.SelectedIndex == 0)//all
                    {
                        //2)get STORE_CARD
                        for (int i = 0; i < iFirmNum; i++)
                        {
                            string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                            szFirmID[i]   = szItem[0];
                            szFirmName[i] = szItem[1];
                            szFirmCard[i] = szFirmID[i];
                            //3)get data
                            if (szFirmCard[i].Trim().Length > 0)
                            {
                                WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow);
                            }
                        }
                    }
                    else//only one firm
                    {
                        //2)get STORE_CARD
                        string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-');
                        szFirmID[0]   = szItem[0];
                        szFirmName[0] = szItem[1];
                        szFirmCard[0] = szFirmID[0];
                        //3)get data
                        if (szFirmCard[0].Trim().Length > 0)
                        {
                            WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow);
                        }
                    }
                }
                if (radioButton_Input.Checked)
                {
                    szFirmID[0]   = textBox_Card.Text.Trim();
                    szFirmCard[0] = szFirmID[0];
                    //check card and get name
                    string szSql = "select user_name from base_ucard where user_card='" + szFirmCard[0] + "'";
                    string szErr = "";
                    int    iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("查询买方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    int iNum = ds.Tables[0].Rows.Count;
                    if (iNum == 0)
                    {
                        MessageBox.Show("系统里无此买方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=系统里无此买方卡");
                        goto Eend;
                    }
                    if (iNum > 1)
                    {
                        MessageBox.Show("重复发卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=重复发卡");
                        goto Eend;
                    }
                    DataRow dr = ds.Tables[0].Rows[0];
                    szFirmName[0] = dr[0].ToString();

                    //3)get data
                    if (szFirmCard[0].Trim().Length > 0)
                    {
                        WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow);
                    }
                }
                if (radioButton_name.Checked)
                {
                    szFirmID[0]   = textBox_Card.Text.Trim();
                    szFirmCard[0] = szFirmID[0];
                    //check card and get name
                    string szSql = "select user_card,user_name from base_ucard where user_name like '%" + textBox_name.Text + "%'";
                    string szErr = "";
                    int    iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("查询买方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    iFirmNum = ds.Tables[0].Rows.Count;
                    if (iFirmNum == 0)
                    {
                        MessageBox.Show("系统里无此买方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=系统里无此买方卡");
                        goto Eend;
                    }
                    for (int i = 0; i < iFirmNum; i++)
                    {
                        DataRow  dr     = ds.Tables[0].Rows[i];
                        string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-');
                        szFirmID[i]   = dr[0].ToString();
                        szFirmName[i] = dr[1].ToString();
                        szFirmCard[i] = szFirmID[i];
                        //3)get data
                        if (szFirmCard[i].Trim().Length > 0)
                        {
                            WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow);
                        }
                    }
                }

                if (iBgnRow == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #26
0
        private void frm_Rpt_IC_Load(object sender, EventArgs e)
        {
            this.Icon              = new Icon(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report2.ico"));
            button_Qry.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.preview.ico"));
            button_Rpt.Image       = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.report.ico"));
            button_Exit.Image      = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.exit01.ico"));
            groupBox2.Width        = this.Width - 50;
            groupBox2.Height       = this.Height - groupBox2.Top - 50;
            dataGridViewRst.Width  = groupBox2.Width - 20;
            dataGridViewRst.Height = groupBox2.Height - 30;

            dateTimePicker_Bgn.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_Bgn.Format       = DateTimePickerFormat.Custom;
            dateTimePicker_End.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dateTimePicker_End.Format       = DateTimePickerFormat.Custom;
            //dateTimePicker_End.Value = DateTime.Now;
            dateTimePicker_Bgn.Text = MyStart.gdtLogin.ToString("yyyy-MM-dd 08:00:00");            //DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");//.AddMonths(-1);
            dateTimePicker_End.Text = MyStart.gdtLogin.AddDays(1).ToString("yyyy-MM-dd 07:59:59"); //DateTime.Now.ToString("yyyy-MM-dd 07:59:59");
            DateTime Dt = DateTime.Now;

            if (Dt >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")) && Dt < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 08:00:00")))
            {
                dateTimePicker_Bgn.Text = Dt.AddDays(-1).ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }
            else
            {
                dateTimePicker_Bgn.Text = Dt.ToString("yyyy-MM-dd 08:00:00");
                //dateTimePicker_Bgn.MaxDate = DateTime.Parse(dateTimePicker_Bgn.Text);

                dateTimePicker_End.Text = Dt.AddDays(1).ToString("yyyy-MM-dd 07:59:59");
                //dateTimePicker_End.MaxDate = DateTime.Parse(dateTimePicker_End.Text);
            }

            DataSet ds    = new DataSet();
            string  szErr = "";

            int    iDptNum = 0;//
            string szSql   = "select USER_DPT from sys_users group by USER_DPT ";
            int    iRst    = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            if (iRst == 0)
            {
                iDptNum = ds.Tables[0].Rows.Count;
                if (iDptNum > 0)
                {
                    comboBox_dpt.Items.Add("所有部门");
                }
                for (int i = 0; i < iDptNum; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    comboBox_dpt.Items.Add(dr[0].ToString());
                }
            }
            if (iDptNum > 0)
            {
                comboBox_dpt.SelectedIndex = 4;
                DispUser(comboBox_dpt.Text);
            }
            comboBox_dpt.Enabled = false;

            textBox_buyer.Text      = "";
            radioButton_all.Checked = true;
            //radioButton_buyer.Checked = true;

            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            string[] szX = mszTitle.Split(',');
            miCols = szX.Length;
            MyStart.oMyDb.Close();
        }
Beispiel #27
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("查询取款汇总", "", "MSG", MyStart.giUserID);
            string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value);
            string szEnd = string.Format("{0:yyyy-MM-dd  HH:mm:ss}", dateTimePicker_End.Value);

            string szTable = "";

            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "";
            }
            else
            {
                mszRptTitle = "";
            }

            /*
             * if (radioButton_buyer.Checked)
             * {
             *  szTable = "rec_user";
             *  mszRptTitle += "买方";
             * }
             * if (radioButton_seller.Checked)
             * {
             *  szTable = "rec_firm";
             *  mszRptTitle += "卖方";
             * }*/
            mszRptTitle += "取款汇总表";

            string szDateCondition = "Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'";

            /*string szSql = "select "
             + "case when b.USER_NAME is not null then b.USER_NAME else '合计' end as '收银员',"
             + "case when oper_subtype is not null then oper_subtype else '小计' end as '取款类型',"
             + "count(chg_val) as 取款笔数,format(sum(chg_val) / 100, 2) as 取款金额(元) from " + szTable + " a,sys_users b where oper_type = 'CASH' and a.Oper_ID=b.USER_ID  ";
             +
             + if (comboBox_Type.SelectedIndex > 0)//only one type
             + {
             +  szSql += " and oper_subtype='" + comboBox_Type.Text.Trim() + "' ";
             + }
             + if (comboBox_POS.SelectedIndex > 0)//only one oper
             + {
             +  string[] szX = comboBox_POS.Text.Split('-');
             +  szSql += " and a.Oper_ID=" + szX[0];
             + }
             + if (!(textBox_buyer.Text.Length == 0 && comboBox_Buyer.SelectedIndex == 0))//only one buyer
             + {
             +  string[] szX = comboBox_Buyer.Text.Split('-');
             +  szSql += " and a.Card_No='" + szX[0] + "' ";
             + }
             + szSql += " and " + szDateCondition + " group by b.USER_NAME, oper_subtype with rollup";*/
            string szSql = "select "
                           + "case when Z.USER_NAME is not null then Z.USER_NAME else '合计' end as '收银员',"
                           + "case when X_TYPE is not null then X_TYPE else '小计' end as '取款类型',"
                           + "sum(A) as 卖方取款笔数,format(sum(B) / 100, 2) as '卖方取款金额(元)',sum(C) as 买方取款笔数,format(sum(D) / 100, 2) as '买方取款金额(元)',"
                           + "sum(A + C) as 取款总笔数, format(sum(B + D) / 100, 2) as '取款总金额(元)' "
                           + "from "
                           + "(select X_ID, X_TYPE, A, B, C, D from "
                           + " (select Oper_ID as X_ID, Oper_SubType as X_TYPE, count(Chg_Val) as A, sum(Chg_Val) as B from rec_firm where Oper_Type = 'CASH' and " + szDateCondition + " group by Oper_ID, Oper_SubType) X,"
                           + " (select Oper_ID as Y_ID, Oper_SubType as Y_TYPE, count(Chg_Val) as C, sum(Chg_Val) as D from rec_user where Oper_Type = 'CASH' and " + szDateCondition + " group by Oper_ID, Oper_SubType) Y "
                           + " where X_ID = Y_ID and X_TYPE = Y_TYPE"
                           + ") XX,sys_users Z where XX.X_ID = Z.USER_ID ";

            if (comboBox_POS.SelectedIndex > 0)//only one oper
            {
                string[] szX = comboBox_POS.Text.Split('-');
                szSql += " and Z.USER_ID=" + szX[0];
            }
            szSql += " group by Z.USER_NAME,XX.X_TYPE with rollup";
            try
            {
                DataSet ds    = new DataSet();
                string  szErr = "";
                int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询取款汇总", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                DataTable dt = ds.Tables[0];
                if (dataGridViewRst.Columns.Count > 0)
                {
                    dataGridViewRst.Columns.Clear();
                }
                dataGridViewRst.DataSource = dt;
                dataGridViewRst.Refresh();

                int iNum = dt.Rows.Count;
                if (iNum == 0)
                {
                    button_Rpt.Enabled = false;
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                int iCurNum = (iNum < miDefRows ? miDefRows : iNum);
                int iBgnRow = 0;
                //MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum);
                iBgnRow += iNum;

                if (iBgnRow == 0)
                {
                    goto Eend;
                }

                miRows             = iBgnRow;
                mszRptDate         = szBgn + " 至 " + szEnd;
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #28
0
        private void button_CheckCard_Click(object sender, EventArgs e)
        {
            string  szInf   = "";
            string  sCardID = "";
            DataSet odt     = null;
            string  sErrMsg = "";

            if (!frm_Main.bHaveRd)
            {
                if (textBox_CardID.Text.Trim() != "")
                {
                    sCardID = textBox_CardID.Text;
                }
                else
                {
                    MessageBox.Show("没有连接读写器,也没有输入卡号,不能执行查询余额功能!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                if (!myRdr.ComOpen(frm_Main.sRdPort))
                {
                    myRdr.ComClose();
                    if (textBox_CardID.Text.Trim() != "")
                    {
                        sCardID = textBox_CardID.Text;
                    }
                    else
                    {
                        MessageBox.Show("打开串口失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    if (!myRdr.ReadCardInf(out szInf))
                    {
                        if (textBox_CardID.Text.Trim() != "")
                        {
                            sCardID = textBox_CardID.Text;
                        }
                        else
                        {
                            MessageBox.Show("读卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            myRdr.ComClose();
                            goto Eend;
                        }
                    }
                    else
                    {
                        sCardID = szInf.Substring(0, 16);
                    }
                }
                myRdr.ComClose();
            }
            textBox_CardID.Text = sCardID;

            if (sCardID.Substring(0, 1) == MyStart.gszCardFirmFirst)
            {
                MessageBox.Show("不接受商户卡查询余额,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                goto Eend;
            }

            try
            {
                string sSql = "";
                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    sSql = "SELECT * FROM mng_card WHERE STORE_CARD = '" + sCardID + "' AND card_type = 3";
                }
                else  // if (mszFlag.ToUpper() == "USER_CARD")
                {
                    sSql = "SELECT * FROM base_ucard WHERE user_card = '" + sCardID + "'";
                }

                int iRst = MyStart.oMyDb.ReadData(sSql, "TableA", ref odt, ref sErrMsg);
                if (iRst != 0)
                {
                    MessageBox.Show("后台查询卡余额失败( " + sErrMsg + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                if (odt.Tables[0].Rows.Count <= 0)
                {
                    if (mszFlag.ToUpper() == "FIRM_CARD")
                    {
                        MessageBox.Show("这是错误的商户结算卡,请更换。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else  // if (mszFlag.ToUpper() == "USER_CARD")
                    {
                        MessageBox.Show("没有此用户卡的信息,请更换。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    goto Eend;
                }

                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    sUserName = odt.Tables[0].Rows[0]["STORE_PERSON"].ToString().Trim();
                }
                else  // if (mszFlag.ToUpper() == "USER_CARD")
                {
                    sUserName = odt.Tables[0].Rows[0]["user_name"].ToString().Trim();
                }

                //银石后台
                objHttp = new EbHttpClass();
                string szErr       = "";
                int    iValue      = 0;
                int    iTrade      = 0;
                int    CardBalance = 0;
                float  fi          = 0.00f;

                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    iTrade = 1;
                }
                else
                {
                    iTrade = 0;
                }

                bool bRst = objHttp.QryCard(sCardID, ref iValue, ref iTrade, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台查询卡余额失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //return;
                }
                else
                {
                    if (mszFlag.ToUpper() == "FIRM_CARD")
                    {
                        fi = iValue;
                        fi = fi / 100;
                        textBox_FinishBalance.Text = fi.ToString("0.00");

                        if (iTrade > 0)
                        {
                            fi = iTrade;
                        }
                        else
                        {
                            fi = 0;
                        }
                        fi = fi / 100;
                        textBox_UnFinishBalance.Text = fi.ToString("0.00");

                        CardBalance             = iValue + iTrade;
                        fi                      = CardBalance;
                        fi                      = fi / 100;
                        textBox_OldBalance.Text = fi.ToString("0.00");
                        MyFunc.WriteToDbLog("卖方资金-余额查询", " ", "MSG", MyStart.giUserID);
                    }
                    else
                    {
                        textBox_FinishBalance.Text   = "";
                        textBox_UnFinishBalance.Text = "";
                        fi = iValue;
                        fi = fi / 100;
                        textBox_OldBalance.Text = fi.ToString("0.00");
                        MyFunc.WriteToDbLog("买方资金-余额查询", " ", "MSG", MyStart.giUserID);
                    }

                    if (checkBox1.Checked)
                    {
                        int i = 0;
                        // 打印票据
                        MyTools.sPrintTopic = "余额查询票据";
                        MyTools.sPrintID    = "";

                        MyTools.oPrintData      = new string[10];
                        MyTools.oPrintData[i++] = "卡片号码:" + textBox_CardID.Text;
                        MyTools.oPrintData[i++] = "持卡人名:" + sUserName;
                        MyTools.oPrintData[i++] = "--------------------------------------";
                        MyTools.oPrintData[i++] = "可取金额:" + textBox_FinishBalance.Text;
                        MyTools.oPrintData[i++] = "未结余额:" + textBox_UnFinishBalance.Text;
                        MyTools.oPrintData[i++] = "合计余额:" + textBox_OldBalance.Text;

                        MyTools.iPrintData = i;
                        MyTools.PrintTicket();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败 = " + ex.Message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

Eend:
            if (odt != null)
            {
                odt.Clear();
            }
            MyStart.oMyDb.Close();

            button_CheckCard.Focus();
        }
Beispiel #29
0
        private void button_Qry_Click(object sender, EventArgs e)
        {
            string szCard = textBox_Card.Text;

            if (szCard.Length == 15)
            {
                szCard = MyStart.gszCardFirmFirst + textBox_Card.Text;
            }

            MyFunc.WriteToDbLog("刷卡查询销售明细", "", "MSG", MyStart.giUserID);
            dataGridViewRst.Rows.Clear();
            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "销售明细表";
            }
            else
            {
                mszRptTitle = "销售明细表";
            }
            DataSet ds          = new DataSet();
            string  szWhere     = "";
            string  szDetailSql = "select a.sys_id,jy_tim,substring(a.store_card,2),user_card,prod_name,format(prod_up / 100, 2),"
                                  + "format(prod_w / 1000, 3),format(prod_nw / 1000, 3),"
                                  + "format((prod_w - prod_nw) / 1000, 3),format(prod_amount / 100, 2), "
                                  + "concat(format(MKT_BUYER_FEE_RATE/10,1),'%'),format(MKT_BUYER_FEE/ 100, 2), "
                                  + "concat(format(MKT_SELLER_FEE_RATE/10,1),'%'),format(MKT_SELLER_FEE/ 100, 2),"
                                  + "concat(format(YTB_BUYER_FEE_RATE/10,1),'%'),format(YTB_BUYER_FEE/ 100, 2), "
                                  + "concat(format(YTB_SELLER_FEE_RATE/10,1),'%'),format(YTB_SELLER_FEE/ 100, 2),"

                                  /*+ "concat(format((YTB_BUYER_FEE_RATE+YTB_SELLER_FEE_RATE)/10,1),'%'),"
                                   + "format((YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2), "*/
                                  + "format((prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)";

            mszSumSql = "select '合计','-','-','-','-','-',"
                        + "format(sum(prod_w) / 1000, 3),format(sum(prod_nw) / 1000, 3),"
                        + "format(sum(prod_w - prod_nw) / 1000, 3),format(sum(prod_amount) / 100, 2), "
                        + "'-',format(sum(MKT_BUYER_FEE)/ 100, 2), "
                        + "'-',format(sum(MKT_SELLER_FEE)/ 100, 2),"
                        + "'-',format(sum(YTB_BUYER_FEE)/ 100, 2), "
                        + "'-',format(sum(YTB_SELLER_FEE)/ 100, 2), "
                        + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)";

            szWhere = " from rec_trade a, base_prod b,mng_card c,base_store e,sys_msg f  "
                      + " where a.CANCEL_MARK='N' and a.STORE_CARD=c.STORE_CARD and c.STORE_ID=e.STORE_ID"
                      + " and a.PROD_ID = b.PROD_ID and b.PROD_LEVEL=1 and a.MSG_ID=f.MSG_ID";
            szWhere += " and jy_tim>='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value) + "' "; // + " 00:00:00' ";
            szWhere += " and jy_tim<='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value) + "' "; // + " 23:59:59' ";
            //szWhere += " and jy_tim>='" + string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 00:00:00' ";
            //szWhere += " and jy_tim<='" + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value) + " 23:59:59' ";
            //验卡
            string szSql = "select user_card from base_ucard where user_card='" + szCard + "'";
            string szErr = "";

            try
            {
                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("卡片查询失败,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }
                int iNum = ds.Tables[0].Rows.Count;
                if (iNum > 0)//买方卡
                {
                    if (DialogResult.No == MessageBox.Show("是否查询买方卡" + szCard + "的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        goto Eend;
                    }
                    szWhere += " and a.user_card='" + szCard + "' ";
                }
                else
                {
                    szSql = "select a.STORE_ID,CARD_TYPE,STORE_NAME from mng_card a,base_store b "
                            + "where a.STORE_ID=b.STORE_ID and STORE_CARD = '" + szCard + "'";
                    iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst != 0)
                    {
                        MessageBox.Show("卡片查询失败,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    iNum = ds.Tables[0].Rows.Count;
                    if (iNum == 0)
                    {
                        MessageBox.Show("系统中无此卡号,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=系统中无此卡号");
                        goto Eend;
                    }
                    if (iNum > 1)
                    {
                        MessageBox.Show("系统中卡号重复记录,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=系统中卡号重复记录");
                        goto Eend;
                    }
                    DataRow dr         = ds.Tables[0].Rows[0];
                    int     iFirmID    = Convert.ToInt16(dr[0]);
                    int     iCardType  = Convert.ToInt16(dr[1]);
                    string  szFirmName = dr[2].ToString();
                    if (iCardType == 2)//副卡
                    {
                        if (DialogResult.No == MessageBox.Show("是否查询卖方副卡" + textBox_Card.Text + "的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            goto Eend;
                        }
                        szWhere += " and a.STORE_CARD='" + szCard + "' ";
                    }
                    else
                    {
                        szSql = "select STORE_CARD from mng_card where STORE_ID=" + iFirmID + " and CARD_TYPE<3";
                        iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                        if (iRst != 0)
                        {
                            MessageBox.Show("查询卖方副卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MyIniFile.WriteLog("查询卖方副卡信息", "SQL=" + szSql + ",Err=" + szErr);
                            goto Eend;
                        }
                        iNum = ds.Tables[0].Rows.Count;

                        szCard = "";
                        if (iNum > 0)
                        {
                            if (DialogResult.No == MessageBox.Show("是否查询卖方(" + szFirmName + ")的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                            {
                                goto Eend;
                            }
                            szCard = "";
                            for (int i = 0; i < iNum; i++)
                            {
                                dr      = ds.Tables[0].Rows[i];
                                szCard += "'" + dr[0].ToString() + "'";
                                if ((i + 1) < iNum)
                                {
                                    szCard += ",";
                                }
                            }
                        }
                        szWhere += " and a.STORE_CARD in (" + szCard + ") ";
                    }
                }

                szDetailSql = szDetailSql + szWhere + " order by jy_tim desc";
                if (mszSumSql.Length > 0)
                {
                    mszSumSql += szWhere;
                }

                iRst = MyStart.oMyDb.ReadData(szDetailSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询商品交易明细信息", "SQL=" + szDetailSql + ",Err=" + szErr);
                    goto Eend;
                }

                DataTable dt = ds.Tables[0];
                mDt  = dt;
                iNum = dt.Rows.Count;
                if (iNum == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                int iCurNum = (iNum < miDefRows ? miDefRows : iNum);
                MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, 0, miCols, ref iCurNum);
                miRows             = iNum;
                mszRptDate         = string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 至 " + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value);
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }
Beispiel #30
0
        private void button_temp_Click(object sender, EventArgs e)
        {
            MyFunc.WriteToDbLog("旧卡查询销售明细", "", "MSG", MyStart.giUserID);
            dataGridViewRst.Rows.Clear();
            MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true);
            if (MyStart.gszMrktName.Length > 0)
            {
                mszRptTitle = MyStart.gszMrktName + "旧卡销售明细表";
            }
            else
            {
                mszRptTitle = "旧卡销售明细表";
            }

            DataSet ds = new DataSet();
            //查找卖方旧卡
            string szSql = "select substr(log_info,4,16) from sys_log where LOG_RMRK like '%卖方%换卡%' ";

            szSql += " and rec_time>='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value) + "' "; // + " 00:00:00' ";
            szSql += " and rec_time<='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value) + "' "; // + " 23:59:59' ";
            string szFirmCard = "";
            int    iFirmNum   = 0;

            try
            {
                string szErr = "";

                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询卖方换卡记录失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询卖方换卡记录", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }

                DataTable dt = ds.Tables[0];
                mDt      = dt;
                iFirmNum = dt.Rows.Count;
                if (iFirmNum == 0)
                {
                    MessageBox.Show("该时间段没有卖方换卡记录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //goto Eend;
                }
                else
                {
                    for (int i = 0; i < iFirmNum; i++)
                    {
                        DataRow dr = dt.Rows[i];
                        szFirmCard += "'" + dr[0].ToString() + "',";
                    }
                    szFirmCard = szFirmCard.Substring(0, szFirmCard.Length - 1);
                    MessageBox.Show("该时间段有" + iFirmNum + "笔卖方换卡记录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询卖方换卡失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //查找买方旧卡
            szSql  = "select substr(log_info,4,16) from sys_log where LOG_RMRK like '%买方%换卡%' ";
            szSql += " and rec_time>='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value) + "' "; // + " 00:00:00' ";
            szSql += " and rec_time<='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value) + "' "; // + " 23:59:59' ";
            string szUserCard = "";
            int    iUserNum   = 0;

            try
            {
                string szErr = "";

                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询买方换卡记录失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询买方换卡记录", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }

                DataTable dt = ds.Tables[0];
                mDt      = dt;
                iUserNum = dt.Rows.Count;
                if (iUserNum == 0)
                {
                    MessageBox.Show("该时间段没有买方换卡记录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (iFirmNum == 0 && iUserNum == 0)
                    {
                        goto Eend;
                    }
                }
                else
                {
                    for (int i = 0; i < iUserNum; i++)
                    {
                        DataRow dr = dt.Rows[i];
                        szUserCard += "'" + dr[0].ToString() + "',";
                    }
                    szUserCard = szUserCard.Substring(0, szUserCard.Length - 1);
                    MessageBox.Show("该时间段有" + iUserNum + "笔买方换卡记录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询买方换卡失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            szSql = "select JY_ID,jy_tim,substring(a.store_card,2),user_card,prod_name,format(prod_up / 100, 2),"
                    + "format(prod_w / 1000, 3),format(prod_nw / 1000, 3),"
                    + "format((prod_w - prod_nw) / 1000, 3),format(prod_amount / 100, 2), "
                    + "concat(format(MKT_BUYER_FEE_RATE/10,1),'%'),format(MKT_BUYER_FEE/ 100, 2), "
                    + "concat(format(MKT_SELLER_FEE_RATE/10,1),'%'),format(MKT_SELLER_FEE/ 100, 2),"
                    + "concat(format(YTB_BUYER_FEE_RATE/10,1),'%'),format(YTB_BUYER_FEE/ 100, 2), "
                    + "concat(format(YTB_SELLER_FEE_RATE/10,1),'%'),format(YTB_SELLER_FEE/ 100, 2),"

                    /*+ "concat(format((YTB_BUYER_FEE_RATE+YTB_SELLER_FEE_RATE)/10,1),'%'),"
                     + "format((YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2), "*/
                    + "format((prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)";
            string szTemp = "";

            if (radioButton_SysId.Checked)
            {
                szSql += " from rec_trade a, base_prod b where a.CANCEL_MARK='N' and a.PROD_ID = b.PROD_ID "
                         + " and JY_ID=" + textBox_SysId.Text.Trim();
                mszSumSql = "";
            }
            if (radioButton_Other.Checked)
            {
                mszSumSql = "select '合计','-','-','-','-','-',"
                            + "format(sum(prod_w) / 1000, 3),format(sum(prod_nw) / 1000, 3),"
                            + "format(sum(prod_w - prod_nw) / 1000, 3),format(sum(prod_amount) / 100, 2), "
                            + "'-',format(sum(MKT_BUYER_FEE)/ 100, 2), "
                            + "'-',format(sum(MKT_SELLER_FEE)/ 100, 2),"
                            + "'-',format(sum(YTB_BUYER_FEE)/ 100, 2), "
                            + "'-',format(sum(YTB_SELLER_FEE)/ 100, 2), "
                            + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)";

                //szTemp = " from rec_trade a, base_prod b,mng_card c,base_stall d,base_store e,sys_msg f  "
                //    + " where a.CANCEL_MARK='N' and a.STORE_CARD=c.STORE_CARD and c.STALL_ID=d.STALL_ID and d.STORE_ID=e.STORE_ID"
                //    + " and a.PROD_ID = b.PROD_ID and a.MSG_ID=f.MSG_ID";
                szTemp = " from rec_trade a, base_prod b,mng_card c,sys_msg f  "
                         + " where a.CANCEL_MARK='N' and a.STORE_CARD=c.STORE_CARD and c.CARD_TYPE<3 "
                         + " and a.PROD_ID = b.PROD_ID and a.MSG_ID=f.MSG_ID";
                string[] szItem;
                if (comboBox_Firm.SelectedIndex > 0)
                {
                    szItem  = comboBox_Firm.Text.Split('-');
                    szTemp += " and c.STORE_ID = " + szItem[0];
                    //mszRptTitle = "销售明细表(卖方:"+ szItem[1] + ")";
                }
                //else
                //    mszRptTitle = "销售明细表(所有卖方)";

                if (comboBox_User.SelectedIndex > 0)
                {
                    szItem  = comboBox_User.Text.Split('-');
                    szTemp += " and USER_CARD = " + szItem[0];
                }
                if (comboBox_Prod.SelectedIndex > 0)
                {
                    szItem  = comboBox_Prod.Text.Split('-');
                    szTemp += " and a.PROD_ID = " + szItem[0];
                }
                if (comboBox_POS.SelectedIndex > 0)
                {
                    szItem  = comboBox_POS.Text.Split('-');
                    szTemp += " and f.POS_ID = '" + szItem[0] + "' ";
                }
                if (iUserNum > 0)
                {
                    if (iFirmNum > 0)
                    {
                        szTemp += " and (USER_CARD in (" + szUserCard + ") or a.STORE_CARD in (" + szFirmCard + "))";// +
                    }
                    else
                    {
                        szTemp += " and USER_CARD in (" + szUserCard + ") ";// +
                    }
                }
                else
                {
                    if (iFirmNum > 0)
                    {
                        szTemp += " and a.STORE_CARD in (" + szFirmCard + ")";// +
                    }
                    else
                    {
                        ;
                    }
                }

                //"'3352300066109473','3352300066103096','3352300066102296','3352300066106826','3352300066106388')";
                szTemp += " and jy_tim>='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value) + "' "; // + " 00:00:00' ";
                szTemp += " and jy_tim<='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value) + "' "; // + " 23:59:59' ";
            }
            szSql = szSql + szTemp + " order by jy_tim desc";
            if (mszSumSql.Length > 0)
            {
                mszSumSql += szTemp;
            }

            try
            {
                string szErr = "";

                int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                if (iRst != 0)
                {
                    MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("查询商品交易明细信息", "SQL=" + szSql + ",Err=" + szErr);
                    goto Eend;
                }

                DataTable dt = ds.Tables[0];
                mDt = dt;
                int iNum = dt.Rows.Count;
                if (iNum == 0)
                {
                    MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                int iCurNum = (iNum < miDefRows ? miDefRows : iNum);
                MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, 0, miCols, ref iCurNum);
                miRows             = iNum;
                mszRptDate         = string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 至 " + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value);
                button_Rpt.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }