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; }
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(); }