示例#1
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();
        }
示例#2
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;
        }