private void btnReadCard_Click(object sender, EventArgs e) { ResetForm(); IsReadCard = ReadCard(); if (!IsReadCard) { return; } Pub.CardBuzzer(); double CardBTBalance = 0; double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); if (!SystemInfo.AllowRefAllowance) { lbBTget.Visible = false; lbBTNotget.Visible = true; CardBTBalance = 0; }/*ShowBTMoney = 0*/ else { lbBTget.Visible = true; lbBTNotget.Visible = false; CardBTBalance = ShowBTMoney; } double AllBalance = sfData.Balance; double BTBalance = ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtMoney.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtBTBalance.Text = BTBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtMoneyBT.Text = CardBTBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); }
private void btnReadCard_Click(object sender, EventArgs e) { ResetForm(); if (!ReadCard(true)) { return; } Pub.CardBuzzer(); txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); }
private void btnReadCard_Click(object sender, EventArgs e) { ResetForm(0); if (!ReadCard(0)) { return; } Pub.CardBuzzer(); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); }
private void btnReadCard_Click(object sender, EventArgs e) { ResetForm(); IsReadCard = ReadCard(); if (!IsReadCard) { return; } Pub.CardBuzzer(); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); if (SystemInfo.AllowCheckDepositLimit == 3) { string msg = label1.Text + ": " + txtEmpNo.Text + "\r\n"; msg += label2.Text + ": " + txtEmpName.Text + "\r\n"; msg += label4.Text + ": " + txtDepartName.Text + "\r\n"; msg += label3.Text + ": " + txtCardType.Text + "\r\n\r\n"; msg += "本月累计已经充值次数: " + countTimes.ToString() + "\r\n"; msg += "本月累计已经充值金额: " + countMoney.ToString(SystemInfo.CurrencySymbol + "0.00") + "\r\n"; Form frm = new Form(); frm.Text = this.Text; frm.FormBorderStyle = FormBorderStyle.FixedDialog; frm.MaximizeBox = false; frm.MinimizeBox = false; frm.StartPosition = FormStartPosition.CenterScreen; frm.Width = 600; frm.Height = 360; Label lab = new Label(); lab.Text = msg; lab.AutoSize = false; lab.Left = 0; lab.Top = 0; lab.Width = frm.ClientSize.Width; lab.Height = frm.ClientSize.Height - 50; lab.TextAlign = ContentAlignment.MiddleLeft; lab.Font = new Font(Font.Name, 20, FontStyle.Bold); Button btn = new Button(); btn.Text = Pub.GetResText("Public", "btnOk", ""); btn.Width = 100; btn.Height = 40; btn.Left = (lab.Width - btn.Width) / 2; btn.Top = lab.Top + lab.Height; btn.DialogResult = DialogResult.OK; frm.Controls.Add(lab); frm.Controls.Add(btn); frm.ShowDialog(); } }
private void btnReadCard1_Click(object sender, EventArgs e) { ResetForm(1); if (!ReadCard(1)) { return; } Pub.CardBuzzer(); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); if (!SystemInfo.AllowRefAllowance) { ShowBTMoney = 0; } double AllBalance = sfData.Balance + ShowBTMoney; textBox2.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtMoney1.Text = textBox2.Text; }
private void btnReadCard_Click(object sender, EventArgs e) { ResetForm(); if (!ReadCard()) { return; } Pub.CardBuzzer(); double ShowBTMoney = sfData.BtMonery;// db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = ShowBTMoney.ToString(SystemInfo.CurrencySymbol + "0.00"); if (rb1.Checked) { txtMoney.Text = txtCardBalanceCZ.Text; } else { txtMoney.Text = txtCardBalanceBT.Text; } }
private void WriteCard() { if (!IsReadCard) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardReadFirst", "")); return; } string EmpNo = txtEmpNo.Text.Trim(); string EmpName = txtEmpName.Text.Trim(); int CardTypeID = ((TCardType)cbbCardType.Items[cbbCardType.SelectedIndex]).id; string CardSectorNo = txtCardSectorNo.Text.Trim(); DateTime CardStartDate = new DateTime(); DateTime CardEndDate = new DateTime(); string CardPWD = txtCardPWD.Text.Trim(); string CardPWDA = txtCardPWDA.Text.Trim(); if (EmpNo == "") { txtEmpNo.Focus(); ShowErrorEnterCorrect(label1.Text); return; } if (!Pub.CheckTextMaxLength(label1.Text, EmpNo, txtEmpNo.MaxLength)) { txtEmpNo.Focus(); return; } if (!Pub.CheckTextMaxLength(label2.Text, EmpName, txtEmpName.MaxLength)) { txtEmpName.Focus(); return; } if (CardPWD == "") { CardPWD = "000000"; } if (!Pub.IsNumeric(CardPWD)) { txtCardPWD.Focus(); ShowErrorEnterCorrect(label16.Text); return; } if (!Pub.CheckTextMaxLength(label16.Text, CardPWD, txtCardPWD.MaxLength)) { txtCardPWD.Focus(); return; } CardPWD = Convert.ToInt32(CardPWD).ToString("000000"); if (CardPWD != CardPWDA) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorPasswordTwo", "")); return; } if ((txtCardStartDate.Text.Trim() == "") || (!DateTime.TryParse(txtCardStartDate.Text.Trim(), out CardStartDate))) { txtCardStartDate.Focus(); ShowErrorEnterCorrect(label13.Text); return; } if ((txtCardEndDate.Text.Trim() == "") || (!DateTime.TryParse(txtCardEndDate.Text.Trim(), out CardEndDate))) { txtCardEndDate.Focus(); ShowErrorEnterCorrect(label14.Text); return; } DataTableReader dr = null; bool IsOk = true; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "4", SysID, EmpNo })); if (dr.Read()) { txtEmpNo.Focus(); ShowErrorCannotRepeated(label1.Text); IsOk = false; } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { return; } pubData.EmpNo = EmpNo; pubData.EmpName = EmpName; pubData.CardNo = CardSectorNo; pubData.CardTypeID = Convert.ToByte(CardTypeID); pubData.CardPWD = CardPWD; pubData.CardBeginDate = CardStartDate; pubData.CardEndDate = CardEndDate; pubData.IsCheckOrder = Convert.ToByte(CardCheckOrder); int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; string msg = "[" + EmpNo + "]" + EmpName + ": " + CardSectorNo + "/" + txtDepartName.Text; ContinuePub: Application.DoEvents(); CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!DeviceObject.objCPIC.GetCardData(ref CardNo10, ref CardNoH, ref CardNo8)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ReadCardError3", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinuePub; } } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinuePub; } else { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinuePub; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinuePub; } } } } cardRet = Pub.WriteCardInfo(pubData); if (cardRet != 0) { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinuePub; } } ContinueData: Application.DoEvents(); if (!db.EmpCardModify(this.Text, oprt, CardSectorNo, CardTypeID, CardPWD, Convert.ToDateTime(CardStartDate), Convert.ToDateTime(CardEndDate), EmpNo, EmpName)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardModifyFailed", "")); return; } else { goto ContinueData; } } IsChgOk = true; Pub.CardBuzzer(); db.WriteSYLog(this.Text, oprt, msg); db.UpdateEmpRegisterData(SysID, 10, CardPWD); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardModifySuccess", ""), MessageBoxIcon.Information); IsReadCard = false; ResetForm(); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard()) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = ShowBTMoney.ToString(SystemInfo.CurrencySymbol + "0.00"); if (sfData.Balance < money) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.UseDate = dt; sfData.UseTimes += 1; List <string> sql = new List <string>(); sql.Clear(); sfData.Balance -= money; double mm = -money; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money; double ReceivablesAmount = money; double CardBalance = sfData.Balance; string AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private bool WriteCard() { ResetForm(); if (!ReadCard(false)) { return(false); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return(false); } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); if (!SystemInfo.SKDepositTotal) { skData.Money = 0; } if (skData.Money + money > SystemInfo.MaxDepositSK) { lblResult.Text = string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBig", ""), SystemInfo.MaxDeposit); return(false); } List <string> sql = new List <string>(); sql.Clear(); string Title; double Amount; double ReceivablesAmount; double CardBalance; string AmountTitle; skData.Money += money; sql.Add(Pub.GetSQL(DBCode.DB_005001, new string[] { "0", pubData.CardNo, "10", dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString("0.00"), skData.Money.ToString("0.00"), OprtInfo.OprtSysID })); Title = Pub.GetResText(formCode, "DepositTitle", ""); Amount = money; ReceivablesAmount = money; CardBalance = skData.Money; AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return(false); } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; skData.CardTime = dt; ContinueSK: Application.DoEvents(); CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSK; } if (CardNo10 != CardData10) { lblResult.Text = Pub.GetResText(formCode, "MsgCardSame", ""); goto ContinueSK; } cardRet = Pub.WriteCardInfo(skData); if (cardRet != 0) { lblResult.Text = Pub.GetCardMsg(cardRet); goto ContinueSK; } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); db.WriteSYLog(this.Text, Title, sql); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = Title + Pub.GetResText(formCode, "MsgSuccess", ""); Pub.CardBuzzer(); return(true); }
private void WriteCard() { int cardRet = 0; string msg = ""; string info = ""; DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return; } switch (cbbCardType.SelectedIndex) { case 0://制作设置时间卡 msg = "Msg001"; info = dt.ToString(); cardRet = DeviceObject.objCPIC.WriteCardSKTime(dt); break; case 1://制作授权卡 msg = "Msg002"; QHAPI.TCardSKAuth skAuth = new QHAPI.TCardSKAuth(); skAuth.TimeMode = 0; skAuth.UsedFlag = 0; skAuth.TrafficFlag = 0; skAuth.TotalFlag = 0; byte MacMode = 0; if (rbHour.Checked) { skAuth.TimeMode = 1; MacMode = 1; } else if (rbCount.Checked) { skAuth.UsedFlag = 1; MacMode = 2; } else if (rbXHour.Checked) { skAuth.TrafficFlag = 1; MacMode = 3; } else if (rbXCount.Checked) { skAuth.TotalFlag = 1; MacMode = 4; } if (!db.WriteConfig(formCode, "MacMode", MacMode, this.Text, cbbCardType.Text)) { return; } info = string.Format("TimeMode={0},UsedFlag={1},TrafficFlag={2},TotalFlag={3}", skAuth.TimeMode, skAuth.UsedFlag, skAuth.TrafficFlag, skAuth.TotalFlag); skAuth.PassVer = 1; skAuth.UsedMode = 0; cardRet = DeviceObject.objCPIC.WriteCardSKAuth(ref skAuth); break; case 2://制作费率卡 msg = "Msg003"; info = dt.ToString(); int v1 = 0; int v2 = 0; int v3 = 0; int v4 = 0; if (!Pub.IsNumeric(textBox1.Text)) { textBox1.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } int.TryParse(textBox1.Text, out v1); if ((v1 < 0) || (v1 > 255)) { textBox1.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } if (!Pub.IsNumeric(textBox2.Text)) { textBox2.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } int.TryParse(textBox2.Text, out v2); if ((v2 < 0) || (v2 > 255)) { textBox2.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } if (!Pub.IsNumeric(textBox3.Text)) { textBox3.Focus(); if ((rbHour.Checked) || (rbXHour.Checked)) { Pub.MessageBoxShow(Pub.GetResText(formCode, "Error003", "")); } else { Pub.MessageBoxShow(Pub.GetResText(formCode, "Error002", "")); } return; } int.TryParse(textBox3.Text, out v3); if ((rbHour.Checked) || (rbXHour.Checked)) { if ((v3 < 0) || (v3 > 85)) { textBox3.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error003", "")); return; } v3 = v3 * 3; } else { if ((v3 < 0) || (v3 > 127)) { textBox3.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error002", "")); return; } v3 = v3 * 2; } if (!Pub.IsNumeric(textBox4.Text)) { textBox4.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } int.TryParse(textBox4.Text, out v4); if ((v4 < 0) || (v4 > 255)) { textBox4.Focus(); Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", "")); return; } if (!db.WriteConfig(formCode, "Text1", v1, this.Text, cbbCardType.Text)) { return; } if (!db.WriteConfig(formCode, "Text2", v2, this.Text, cbbCardType.Text)) { return; } if (!db.WriteConfig(formCode, "Text3", v3, this.Text, cbbCardType.Text)) { return; } if (!db.WriteConfig(formCode, "Text4", v4, this.Text, cbbCardType.Text)) { return; } info = string.Format("Time={0},Rates1={1},Time1={2},Rates2={3},Time2={4}", dt, v1, v3, v2, v4); QHAPI.TCardSKRates skRates = new QHAPI.TCardSKRates(); skRates.CardTime = dt; skRates.Rates1 = Convert.ToByte(v1); skRates.Time1 = Convert.ToByte(v3); skRates.Rates2 = Convert.ToByte(v2); skRates.Time2 = Convert.ToByte(v4); skRates.BalanceLimit = 0; cardRet = DeviceObject.objCPIC.WriteCardSKRates(ref skRates); break; case 3: msg = "Msg004"; info = dt.ToString(); cardRet = DeviceObject.objCPIC.WriteCardSKClear(dt); break; case 4: msg = "Msg005"; info = dt.ToString(); cardRet = DeviceObject.objCPIC.WriteCardSKInit(dt); break; } if (cardRet == 0) { msg = Pub.GetResText(formCode, msg, ""); db.WriteSYLog(this.Text, cbbCardType.Text, msg + "[" + CardData10 + "]" + info); Pub.CardBuzzer(); Pub.MessageBoxShow(msg, MessageBoxIcon.Information); } else { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet)); } }
private void WriteCard() { if (!IsReadCard) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgEmpFindFirst", "")); return; } string CardNo = txtCardNo.Text.Trim(); string OldCardNo = txtCardSectorNo.Text; if (SystemInfo.AllowCustomerCardNo) { if ((CardNo == "") || (!Pub.IsNumeric(CardNo))) { txtCardNo.Focus(); ShowErrorEnterCorrect(label6.Text); return; } if (!Pub.CheckTextMaxLength(label6.Text, CardNo, txtCardNo.MaxLength)) { txtCardNo.Focus(); return; } CardNo = Convert.ToUInt32(CardNo).ToString("0000000000"); } if ((CardNo == "") || (!Pub.IsNumeric(CardNo))) { txtCardNo.Focus(); ShowErrorEnterCorrect(label6.Text); return; } if (!Pub.CheckTextMaxLength(label6.Text, CardNo, txtCardNo.MaxLength)) { txtCardNo.Focus(); return; } CardNo = Convert.ToUInt32(CardNo).ToString("0000000000"); OldCardNo = Convert.ToUInt32(OldCardNo).ToString("0000000000"); string CardNoDays = ""; string msg = ""; DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } DateTime d = new DateTime(); if (SystemInfo.AllowCustomerCardNo) { if (db.CardSectorNoIsExists(EmpSysID, CardNo, ref CardNoDays)) { if (CardNoDays == " ") { msg = Pub.GetResText(formCode, "MsgCardExistsBlack", ""); } else if (DateTime.TryParse(CardNoDays, out d)) { msg = Pub.GetResText(formCode, "MsgCardExistsUseDays", ""); } else { msg = Pub.GetResText(formCode, "MsgCardExistsUseing", ""); } msg = string.Format(msg, CardNo, CardNoDays); if (Pub.MessageBoxShowQuestion(msg)) { return; } CardNo = db.GetMaxCardSectorNo(); if (CardNo == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", "")); return; } } } int cardRet = 0; if (SystemInfo.HasSF) { cardRet = db.CheckSFAllowance(EmpSysID); if (cardRet == 1) { if (!Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardHasAllowance", ""))) { IsWorking = false; ShowSFAllowance = true; this.Close(); return; } } else if (cardRet == 2) { return; } } string CardData10 = ""; string CardDataH = ""; string CardData8 = ""; string UseEmpNo = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return; } cardRet = db.CheckCardPhysicsNo(EmpSysID, CardData10, ref UseEmpNo); if (cardRet == 1) { Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "MsgCardCheckExistsUseing", ""), CardData10, UseEmpNo)); return; } else if (cardRet == 2) { Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""), CardData10)); return; } else if (cardRet == 3) { return; } if (CardBalance < 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "Msg001", "")); return; } //if (!SystemInfo.AllowCustomerCardNo) CardNo = CardData10; if (CardNo == "") { CardNo = db.GetMaxCardSectorNo(); CardNo = Convert.ToUInt32(CardNo).ToString("0000000000"); } if (CardNo != "") { DataTableReader dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "206", CardNo })); if (dr.Read()) { txtCardNo.Focus(); ShowErrorCannotRepeated(label6.Text); return; } if (db.CardSectorNoIsExists(SysID, CardNo, ref CardNoDays)) { if (CardNoDays == " ") { msg = Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""); } else if (DateTime.TryParse(CardNoDays, out d)) { msg = Pub.GetResText(formCode, "MsgCardExistsUseDaysAgainA", ""); } else { msg = Pub.GetResText(formCode, "MsgCardExistsUseingAgainA", ""); } msg = string.Format(msg, CardNo, CardNoDays); txtCardNo.Focus(); Pub.ShowErrorMsg(msg); return; } } HSUNFK.TCardPubData pubData = new HSUNFK.TCardPubData(); if (!Pub.ReadCardInfo(ref pubData)) { return; } if (pubData.DealersCode != SystemInfo.DealersCode) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorIllegalCard", "")); return; } if ((pubData.CardNo != "") && (Convert.ToUInt32(pubData.CardNo) > 0)) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardFaExists", "")); return; } pubData.EmpNo = txtEmpNo.Text; pubData.EmpName = txtEmpName.Text; pubData.CardNo = CardNo; pubData.CardTypeID = CardTypeID; pubData.CardPWD = CardPWD; pubData.DealersCode = SystemInfo.DealersCode; pubData.CustomersCode = SystemInfo.CustomersCode; pubData.CardBeginDate = CardStartDate.Date; pubData.CardEndDate = CardEndDate.Date; pubData.IsCheckOrder = Convert.ToByte(CardCheckOrder); HSUNFK.TCardSFData sfData = new HSUNFK.TCardSFData(); sfData.Balance = CardBalance; sfData.UseDate = CardUseDate; sfData.UseTimes = CardUseTimes; sfData.BtMonery = BTBalance; if (BTFlag != "") { BTFlag = DeviceObject.objCPIC.NumToHex(BTFlag.Substring(0, 2), 1) + DeviceObject.objCPIC.NumToHex(BTFlag.Substring(2, 2), 1) + DeviceObject.objCPIC.NumToHex(BTFlag.Substring(4, 2), 1); } sfData.BtDate = BTFlag == "" ? "000000" : BTFlag; HSUNFK.TCardSKData skData = new HSUNFK.TCardSKData(); skData.CardID = pubData.CardNo; skData.CardTime = CardUseDate; bool IsError = false; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; string oprtMsg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + CardNo + "/" + txtDepartName.Text; ContinuePS: Application.DoEvents(); if (IsError) { if (!DeviceObject.objCPIC.GetCardData(ref CardNo10, ref CardNoH, ref CardNo8)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinuePS; } if (CardNo10 != CardData10) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinuePS; } } IsError = false; } cardRet = Pub.WriteCardInfo(pubData, sfData, skData); if (cardRet != 0) { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsError = true; goto ContinuePS; } } ContinueData: Application.DoEvents(); if (!db.EmpCardChange(this.Text, oprt, EmpSysID, CardNo, CardData10, CardData8, CardFee, CardData10, DeviceObject.objCPIC.GetMacTAG())) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardChangeFailed", "")); return; } else { goto ContinueData; } } Pub.CardBuzzer(); lblResult.Text = Pub.GetResText(formCode, "MsgCardChangeSuccess", ""); IsChgOk = true; IsReadCard = false; DateTime cdt = new DateTime(); if (!db.GetServerDate(ref cdt)) { return; } db.EmpHistoryCard(this.Text, oprt, EmpSysID, OldCardNo, cdt, 3); db.EmpHistoryCard(this.Text, oprt, EmpSysID, CardNo, cdt, 2); db.WriteSYLog(this.Text, oprt, oprtMsg); db.UpdateEmpRegisterData(EmpSysID, 11, CardData10); Pub.MessageBoxShow(lblResult.Text, MessageBoxIcon.Information); ResetForm(); }
private void btnReadCard_Click(object sender, EventArgs e) { IsReadCard = false; HSUNFK.TCardPubData pubData = new HSUNFK.TCardPubData(); HSUNFK.TCardSFData sfData = new HSUNFK.TCardSFData(); if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return; } if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { ResetForm(); return; } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { ResetForm(); return; } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { ResetForm(); return; } MacTag = pubData.MacTAG; BTMoney = sfData.BtMonery; ShowBTMoney = db.GetBTMoney(sfData.BtDate, BTMoney); CardBalance = sfData.Balance; if (!SystemInfo.AllowRefAllowance) { lbBTget.Visible = false; lbBTNotget.Visible = true; ReFee = sfData.Balance; ShowBTMoney = 0; }/**/ else { lbBTget.Visible = true; lbBTNotget.Visible = false; ReFee = sfData.Balance + ShowBTMoney; } CardUseTimes = sfData.UseTimes + 1; DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo, CardData10 })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardRetirNotNormal", "")); } else if (!Convert.ToBoolean(dr["CardRetirement"].ToString())) { Pub.ShowErrorMsg(string.Format(Pub.GetResText("", "ErrorCardRetirement", ""), dr["CardTypeName"].ToString())); } else { txtEmpNo.Text = dr["EmpNo"].ToString(); txtEmpName.Text = dr["EmpName"].ToString(); txtDepartName.Text = dr["DepartName"].ToString(); txtCardSectorNo.Text = dr["CardSectorNo"].ToString(); txtCardStatusName.Text = dr["CardStatusName"].ToString(); txtCardUseDate.Text = dr["CardUseDate"].ToString(); txtCardType.Text = dr["CardTypeName"].ToString(); txtCardBalanceBT.Text = CardBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtBT.Text = BTMoney.ToString(SystemInfo.CurrencySymbol + "0.00"); CardFee = 0; double.TryParse(dr["CardFee"].ToString(), out CardFee); txtCardFee.Text = CardFee.ToString(SystemInfo.CurrencySymbol + "0.00"); EmpSysID = dr["EmpSysID"].ToString(); txtReFee.Text = ReFee.ToString(SystemInfo.CurrencySymbol + "0.00"); IsOk = true; } } else { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorIllegalCard", "")); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { ResetForm(); return; } ReFee = ReFee + CardFee; txtReFee.Text = ReFee.ToString(SystemInfo.CurrencySymbol + "0.00"); IsReadCard = true; Pub.CardBuzzer(); ResetForm(); btnOk.Focus(); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; string RefundmentType = "20"; string AmountTitle = label6.Text; double dtm = 0; if (ExistsRefundmentType) { RefundmentType = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).id; AmountTitle = cbbType.Text; } double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); double moneyBT = 0; double.TryParse(CurrencyToStringEx(txtMoneyBT.Text), out moneyBT); if (money <= 0 && moneyBT <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (SystemInfo.AllowCheckDepositLimit == 3) { if (!IsReadCard) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardReadFirst", "")); return; } if (textBox1.Enabled) { int.TryParse(textBox1.Text.Trim(), out Discount); } } else { if (!ReadCard()) { return; } } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); if (!SystemInfo.AllowRefAllowance) { ShowBTMoney = 0; } double AllBalance = sfData.Balance; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); double BTBalance = ShowBTMoney; txtBTBalance.Text = BTBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); if (AllBalance < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } if (BTBalance < moneyBT) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.UseDate = dt; sfData.UseTimes += 1; List <string> sql = new List <string>(); sql.Clear(); DataTableReader dr = null; string OpterStartDate = ""; string OpterEndDate = ""; DateTime StartDt = new DateTime(); DateTime EndDt = new DateTime(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "251", pubData.CardNo })); while (dr.Read()) { OpterStartDate = ""; OpterEndDate = ""; OpterStartDate = dr["OpterStartDate"].ToString(); OpterEndDate = dr["OpterEndDate"].ToString(); if (OpterStartDate != "") { StartDt = Convert.ToDateTime(OpterStartDate); } if (OpterEndDate != "") { EndDt = Convert.ToDateTime(OpterEndDate); } if (OpterStartDate != "" && OpterEndDate != "") { if (dt > StartDt && dt < EndDt) { break; } } else if (OpterStartDate != "" && OpterEndDate == "") { if (dt > StartDt) { OpterEndDate = dt.ToString(SystemInfo.SQLDateTimeFMT); break; } } } if (OpterStartDate != "") { OpterStartDate = Convert.ToDateTime(OpterStartDate).ToString(SystemInfo.SQLDateTimeFMT); } if (OpterEndDate != "") { OpterEndDate = Convert.ToDateTime(OpterEndDate).ToString(SystemInfo.SQLDateTimeFMT); } if (ShowBTMoney == 0) { sfData.Balance -= money; if (sfData.BtMonery > 0 && SystemInfo.AllowRefAllowance) { double m = -sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), "0", sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", sfData.BtMonery.ToString(), m.ToString(), "0", "0", OpterStartDate, OpterEndDate })); sfData.UseTimes += 1; sfData.BtMonery = 0; } } else { //double olddtm = sfData.BtMonery; //sfData.BtMonery -= money; //dtm = -money; //if (sfData.BtMonery < 0) //{ // sfData.Balance += sfData.BtMonery; // sfData.BtMonery = 0; // dtm = -olddtm; //} dtm = -moneyBT; sfData.BtMonery -= moneyBT; } double DiscountMoney = 0; double mm = 0; if (SystemInfo.AllowCheckDepositLimit == 2 || SystemInfo.AllowCheckDepositLimit == 3) { if (Discount > 0 && Discount != 100) { DiscountMoney = money * Discount / 100; double x = sfData.Balance + money - DiscountMoney /*+ sfData.BtMonery*/; double xx = -DiscountMoney; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "21", dt.AddSeconds(-1).ToString(SystemInfo.SQLDateTimeFMT), xx.ToString(), x.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", dtm.ToString(), sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate })); sfData.UseTimes += 1; mm = -(money - DiscountMoney); } } else { mm = -money; // sfData.Balance -= money; } AllBalance = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, RefundmentType, dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", dtm.ToString(), sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money + moneyBT; double ReceivablesAmount = money + moneyBT; double CardBalance = AllBalance; if (SystemInfo.AllowCheckDepositLimit == 3) { string msgX = string.Format("本初取出款总金额,其中,\r\n\r\n退款:{0}元\r\n扣除:{1}元", Math.Abs(mm).ToString(SystemInfo.CurrencySymbol + "0.00"), Math.Abs(DiscountMoney).ToString(SystemInfo.CurrencySymbol + "0.00")); Form frm = new Form(); frm.FormBorderStyle = FormBorderStyle.FixedDialog; frm.MaximizeBox = false; frm.MinimizeBox = false; frm.StartPosition = FormStartPosition.CenterScreen; frm.Width = 600; frm.Height = 360; Label lab = new Label(); lab.Left = 10; lab.Top = 14; lab.Text = msgX; lab.AutoSize = false; lab.Left = 0; lab.Top = 0; lab.Width = frm.ClientSize.Width; lab.Height = frm.ClientSize.Height - 50; lab.TextAlign = ContentAlignment.MiddleCenter; lab.Font = new Font(Font.Name, 20, FontStyle.Bold); int BtnLeft = (lab.Width - 100 * 2 - 20) / 2; Button btnOkX = new Button(); btnOkX.Text = Pub.GetResText("Public", "btnOk", ""); btnOkX.Width = 100; btnOkX.Height = 40; btnOkX.Left = BtnLeft; btnOkX.Top = lab.Top + lab.Height; btnOkX.DialogResult = DialogResult.OK; Button btnCancelX = new Button(); btnCancelX.Text = Pub.GetResText("Public", "btnCancel", ""); btnCancelX.Width = 100; btnCancelX.Height = 40; btnCancelX.Left = BtnLeft + 120; btnCancelX.Top = lab.Top + lab.Height; btnCancelX.DialogResult = DialogResult.Cancel; frm.Controls.Add(lab); frm.Controls.Add(btnOkX); frm.Controls.Add(btnCancelX); if (frm.ShowDialog() != DialogResult.OK) { return; } } if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double tempBalance = sfData.Balance; double tempBT = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalance.Text = tempBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtBTBalance.Text = tempBT.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentOprt, msg); DispExtScreen(Amount, temp, 1, 2); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; string AmountTitle = label6.Text; string DepositType = "10"; if (ExistsDepositType) { DepositType = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).id; AmountTitle = cbbType.Text; } double money = 0; double Fact = 0; double DiscountMoney = 0; int DiscountType = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } double MobileMoney = money; if (DepositType == "100" || DepositType == "101") { money -= MobileInfo.RateMoney(DepositType == "100", MobileMoney); } Fact = money; if (!ReadCard()) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); double tmpMoney = 0; byte DiscFlag = db.GetDiscDiscount(money, pubData.CardTypeID, ref tmpMoney); if (DiscFlag == 2) { return; } if (DiscFlag == 1) { DiscountMoney = tmpMoney; Fact = money + DiscountMoney; DiscountType = 80; } else if ((Discount > 0) && (Discount != 100)) { DiscountMoney = money * Discount / 100; DiscountMoney = DiscountMoney - money; Fact = money + DiscountMoney; if (DiscountMoney > 0) { DiscountType = 80; } else { DiscountType = 70; } } if (AllBalance + Fact > SystemInfo.MaxDeposit) { Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBig", ""), SystemInfo.MaxDeposit)); return; } if (DepositType == "100" || DepositType == "101") { int h = SystemInfo.MainHandle.ToInt32(); bool IsWeiXin = DepositType == "100", ret; string ErrMsg = ""; if (chkPayCode.Checked) { DeviceObject.objCard.MobilePayCodeSet(cbbCommPort.Text); ret = DeviceObject.objCard.MobilePayCode(h, chkPayCodeUSB.Checked, CardData10, pubData.CardNo, MobileMoney, ref IsWeiXin, true, ref ErrMsg); } else { ret = DeviceObject.objCard.MobileShow(h, CardData10, pubData.CardNo, MobileMoney, ref IsWeiXin, true, ref ErrMsg); } if (!ret) { Pub.MessageBoxShow(ErrMsg); return; } DepositType = IsWeiXin ? "100" : "101"; } List <string> sql = new List <string>(); sql.Clear(); string Title = Pub.GetResText(formCode, "DepositTitle", ""); double Amount = money; double ReceivablesAmount = Fact; double CardBalance = AllBalance + Fact; sfData.Balance = sfData.Balance + money; sfData.UseTimes = sfData.UseTimes + 1; sfData.UseDate = dt; double mm = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DepositType, dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); if (DiscountMoney != 0) { sfData.Balance = sfData.Balance + DiscountMoney; sfData.UseTimes = sfData.UseTimes + 1; mm = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DiscountType.ToString(), dt.AddSeconds(1).ToString(SystemInfo.SQLDateTimeFMT), DiscountMoney.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); } if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalance.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); DispExtScreen(Amount, temp, 0, 1); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void FaCard(bool IsBatch, string Oprt) { frmAppMain frm = Pub.GetAppMainForm(); if (SystemInfo.CardKey == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorCardkey", "")); if (frm != null) { frm.ExecModule("SYOption", ""); } return; } if (SystemInfo.DealersCode == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorDealersCode", "")); if (frm != null) { frm.ExecModule("SYOption", ""); } return; } if (SystemInfo.CustomersCode == 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorCustomersCode", "")); if (frm != null) { frm.ExecModule("SYOption", ""); } return; } if (!DeviceObject.objCPIC.IsOnline()) { lblMsg.Text = Pub.GetResText(formCode, "ReadCardError1", ""); return; } DateTime d = new DateTime(); DateTime Fad = new DateTime(); if (!db.GetServerDate(ref d)) { return; } Fad = d; if (Pub.MessageBoxShowQuestion(string.Format(Pub.GetResText(formCode, "MsgServerDate", ""), d))) { return; } double DepositMoney = 0; double.TryParse(CurrencyToStringEx(ItemMoneyText.Text), out DepositMoney); if (DepositMoney < 0) { DepositMoney = 0.00; } DataTable dt = (DataTable)bindingSource.DataSource; DataRow dr = null; IsFaCard = true; RefreshForm(true); string EmpSysID = ""; string CardSectorNo = ""; int CardStatusID = 0; string msg = ""; int DepositDiscount = 0; int UseTimes = 0; int reStatus = 0; DateTime CardStartDate = new DateTime(); DateTime CardEndDate = new DateTime(); bool IsFirst = true; long CardDays = 0; string CardPWD = ""; string EmpNo = ""; string EmpName = ""; byte CardTypeID = 0; double CardStored = 0.00; double DiscountM = 0.00; bool CardCheckOrder = false; string CardNoDays = ""; int cardRet = 0; string CardData10; string CardDataH; string CardData8; string CardNo10; string CardNoH; string CardNo8; string UseEmpNo = ""; string ErrMsg = ""; double CardFee = 0; bool IsLock = false; string LockOprtNo = ""; string LockComputerName = ""; int currRow = bindingSource.Position; string MacTAG = DeviceObject.objCPIC.GetMacTAG(); HSUNFK.TCardPubData pubData = new HSUNFK.TCardPubData(); HSUNFK.TCardSFData sfData = new HSUNFK.TCardSFData(); HSUNFK.TCardSKData skData = new HSUNFK.TCardSKData(); bool IsError = false; bool IsValidCard = false; while (IsFaCard) { for (int i = currRow; i < dt.Rows.Count; i++) { AgainCard: bindingSource.Position = i; dataGrid.CurrentCell = dataGrid.SelectedRows[0].Cells[0]; Application.DoEvents(); dr = dt.Rows[i]; EmpSysID = dr["EmpSysID"].ToString(); if (!db.EmpGetCardStatusIDByEmpSysID(EmpSysID, ref CardStatusID, ref IsLock, ref LockOprtNo, ref LockComputerName)) { continue; } if (IsLock || ((CardStatusID != 10) && (CardStatusID != 60))) { continue; } CardSectorNo = dr["CardSectorNo"].ToString(); CardStartDate = (DateTime)dr["CardStartDate"]; CardEndDate = (DateTime)dr["CardEndDate"]; CardPWD = dr["CardPWD"].ToString(); if ((CardPWD == "") || (!Pub.IsNumeric(CardPWD))) { CardPWD = "000000"; } if (Convert.ToInt32(CardPWD) > 999999) { CardPWD = "000000"; } EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); CardTypeID = Convert.ToByte(dr["CardTypeID"]); DepositDiscount = 0; if (!dr.IsNull("DepositDiscount")) { DepositDiscount = Convert.ToInt32(dr["DepositDiscount"].ToString()); } CardFee = 0; if (!dr.IsNull("CardFee")) { CardFee = Convert.ToDouble(dr["CardFee"].ToString()); } UseTimes = 0; if (!dr.IsNull("CardUseTimes")) { UseTimes = Convert.ToInt32(dr["CardUseTimes"].ToString()); } CardStored = 0.00; if (!dr.IsNull("CardStored")) { CardStored = Convert.ToDouble(dr["CardStored"]); } if (!IsBatch && (DepositMoney > 0)) { CardStored = DepositMoney; if (SystemInfo.FaCardFee) { CardStored -= CardFee; } if (CardStored < 0) { CardFee = 0; CardStored = 0; } } DiscountM = CardStored; double tmpMoney = 0; byte discFlag = db.GetDiscDiscount(CardStored, CardTypeID, ref tmpMoney); if (discFlag == 2) { break; } if (discFlag == 1) { DiscountM = DiscountM + tmpMoney; } else if (DepositDiscount > 0) { DiscountM = CardStored * DepositDiscount / 100; } CardCheckOrder = false; if (!dr.IsNull("CardCheckOrder")) { CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"]); } if (IsFirst) { IsFirst = false; CardDays = Pub.DateDiff(DateInterval.Day, CardStartDate, CardEndDate); if (CardDays <= 30) { msg = Pub.GetResText(formCode, "MsgCardDaySmall", ""); msg = string.Format(msg, CardDays); if (Pub.MessageBoxShowQuestion(msg)) { ItemStop_Click(null, null); return; } } } if (SystemInfo.AllowCustomerCardNo) { if ((CardSectorNo == "") || (!Pub.IsNumeric(CardSectorNo))) { CardSectorNo = db.GetMaxCardSectorNo(EmpSysID); if (CardSectorNo == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", "")); ItemStop_Click(null, null); return; } } else if ((CardStatusID == 60) && db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays)) { if (CardNoDays == " ") { msg = Pub.GetResText(formCode, "MsgCardExistsBlack", ""); } else if (DateTime.TryParse(CardNoDays, out d)) { msg = Pub.GetResText(formCode, "MsgCardExistsUseDays", ""); } else { msg = Pub.GetResText(formCode, "MsgCardExistsUseing", ""); } msg = string.Format(msg, CardSectorNo, CardNoDays); if (Pub.MessageBoxShowQuestion(msg)) { ItemStop_Click(null, null); return; } CardSectorNo = db.GetMaxCardSectorNo(EmpSysID); if (CardSectorNo == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", "")); ItemStop_Click(null, null); return; } } msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", ""); msg = string.Format(msg, EmpNo, EmpName, CardSectorNo); } else { //CardSectorNo = ""; msg = Pub.GetResText(formCode, "MsgCardFaInfo", ""); msg = string.Format(msg, EmpNo, EmpName); } RefreshMsg(msg); LoopCard: Application.DoEvents(); if (!IsFaCard) { ItemStop_Click(null, null); return; } CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8, ref ErrMsg)) { lblResult.Text = ErrMsg; goto LoopCard; } cardRet = db.CheckCardPhysicsNo(EmpSysID, CardData10, ref UseEmpNo); if (cardRet == 1) { lblResult.Text = string.Format(Pub.GetResText(formCode, "MsgCardCheckExistsUseing", ""), CardData10, UseEmpNo); goto LoopCard; } else if (cardRet == 2) { lblResult.Text = string.Format(Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""), CardData10); goto LoopCard; } else if (cardRet == 3) { goto LoopCard; } pubData = new HSUNFK.TCardPubData(); cardRet = DeviceObject.objCPIC.ReadCardInfoPub(SystemInfo.IsLongEmpID, ref pubData); if (cardRet != 0) { lblResult.Text = Pub.GetCardMsg(cardRet); goto LoopCard; } if (pubData.DealersCode != SystemInfo.DealersCode) { lblResult.Text = Pub.GetResText(formCode, "ErrorIllegalCard", ""); goto LoopCard; } if ((pubData.CardNo != "") && (Convert.ToUInt32(pubData.CardNo) > 0)) { lblResult.Text = Pub.GetResText(formCode, "MsgCardFaExists", ""); goto LoopCard; } lblResult.Text = Pub.GetResText(formCode, "MsgCardFaing", ""); if (CardSectorNo == "") { CardSectorNo = db.GetMaxCardSectorNo(); } //CardSectorNo = CardData10; Application.DoEvents(); IsValidCard = true; LoopCardExists: pubData.EmpNo = EmpNo; pubData.EmpName = EmpName; pubData.CardNo = CardSectorNo; pubData.CardTypeID = CardTypeID; pubData.CardPWD = CardPWD; pubData.DealersCode = SystemInfo.DealersCode; pubData.CustomersCode = SystemInfo.CustomersCode; pubData.CardBeginDate = CardStartDate; pubData.CardEndDate = CardEndDate; pubData.IsCheckOrder = Convert.ToByte(CardCheckOrder); if (!db.GetServerDate(ref d)) { ItemStop_Click(null, null); return; } sfData = new HSUNFK.TCardSFData(); sfData.Balance = DiscountM; sfData.UseDate = d; if (sfData.Balance > 0) { sfData.UseTimes = UseTimes + 1; } else { sfData.UseTimes = UseTimes; } if (DiscountM != CardStored) { sfData.UseTimes = sfData.UseTimes + 1; } sfData.BtMonery = 0; sfData.BtDate = "000000"; skData = new HSUNFK.TCardSKData(); skData.CardID = pubData.CardNo; skData.CardTime = d; IsError = false; ContinuePS: Application.DoEvents(); if (IsError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinuePS; } if (CardNo10 != CardData10) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { if (IsValidCard) { db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored, sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 70, 80, CardData10, MacTAG, ref reStatus); if (reStatus == 0) { Pub.ClearCardInfo(); goto AgainCard; } else { db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1); } } IsFaOk = true; ItemStop_Click(null, null); return; } else { goto ContinuePS; } } else { if (SystemInfo.AllowCustomerCardNo) { if (db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays)) { IsValidCard = false; if (CardNoDays == " ") { msg = Pub.GetResText(formCode, "MsgCardExistsBlackAgain", ""); } else if (DateTime.TryParse(CardNoDays, out d)) { msg = Pub.GetResText(formCode, "MsgCardExistsUseDaysAgain", ""); } else { msg = Pub.GetResText(formCode, "MsgCardExistsUseingAgain", ""); } msg = string.Format(msg, CardSectorNo, CardNoDays); Pub.ClearCardInfo(); Pub.ShowErrorMsg(msg); CardSectorNo = db.GetMaxCardSectorNo(EmpSysID); if (CardSectorNo == "") { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", "")); ItemStop_Click(null, null); return; } msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", ""); msg = string.Format(msg, EmpNo, EmpName, CardSectorNo); RefreshMsg(msg); goto LoopCardExists; } } else { if (db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays)) { IsValidCard = false; if (CardNoDays == " ") { msg = Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""); } else if (DateTime.TryParse(CardNoDays, out d)) { msg = Pub.GetResText(formCode, "MsgCardExistsUseDaysAgainA", ""); } else { msg = Pub.GetResText(formCode, "MsgCardExistsUseingAgainA", ""); } msg = string.Format(msg, CardSectorNo, CardNoDays); Pub.ClearCardInfo(); Pub.ShowErrorMsg(msg); msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", ""); msg = string.Format(msg, EmpNo, EmpName, CardSectorNo); RefreshMsg(msg); goto LoopCardExists; } } } IsError = false; IsValidCard = true; } cardRet = Pub.WriteCardInfo(pubData, sfData, skData); if (cardRet != 0) { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { if (IsValidCard) { db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored, sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 70, 80, CardData10, MacTAG, ref reStatus); if (reStatus == 0) { Pub.ClearCardInfo(); goto AgainCard; } else { db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1); } } IsFaOk = true; Pub.ClearCardInfo(); ItemStop_Click(null, null); return; } else { IsError = true; goto ContinuePS; } } IsValidCard = true; ContinueData: Application.DoEvents(); if (!db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored, sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 20, 10, CardData10, MacTAG, ref reStatus)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { Pub.ClearCardInfo(); Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardFaFailed", "")); ItemStop_Click(null, null); return; } else { goto ContinueData; } } if (reStatus == 0) { Pub.ClearCardInfo(); goto AgainCard; } db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1); lblResult.Text = Pub.GetResText(formCode, "MsgCardFaSuccess", ""); IsFaOk = true; Pub.CardBuzzer(); dr["CardSectorNo"] = CardSectorNo; dr["CardStatusName"] = CardStatusNormal; db.UpdateEmpRegisterData(EmpSysID, 11, CardData10); LoopNoCard: Application.DoEvents(); if (!IsBatch || !IsFaCard || (i + 1 == dt.Rows.Count)) { break; } if (DeviceObject.objCPIC.CardIsExists()) { goto LoopNoCard; } } IsFaCard = false; Application.DoEvents(); } ItemStop_Click(null, null); lblResult.Text = ""; lblMsg.Text = Pub.GetResText(formCode, "MsgOprtComplete", ""); }
private void btnReadCard_Click(object sender, EventArgs e) { IsReadCard = false; pubData = new QHAPI.TCardPubData(); sfData = new QHAPI.TCardSFData(); CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return; } if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { ResetForm(); return; } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { ResetForm(); return; } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { ResetForm(); return; } DataTableReader dr = null; bool IsOk = false; string EmpNo = ""; string EmpName = ""; string CardPWD = ""; string DepartName = ""; string CardStatusName = ""; string FaDate = ""; CardCheckOrder = false; SysID = ""; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardModifyNotNormal", "")); } else { SysID = dr["EmpSysID"].ToString(); EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); CardPWD = dr["CardPWD"].ToString(); DepartName = dr["DepartName"].ToString(); CardStatusName = dr["CardStatusName"].ToString(); FaDate = dr["FaDate"].ToString(); CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"].ToString()); IsOk = true; } } else { Pub.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (!IsOk) { ResetForm(); return; } double BTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + BTMoney; txtEmpNo.Text = EmpNo; txtEmpName.Text = EmpName; txtCardPWD.Text = CardPWD; txtCardPWDA.Text = CardPWD; txtCardSectorNo.Text = pubData.CardNo; cbbCardType.SelectedIndex = -1; for (int i = 0; i < cbbCardType.Items.Count; i++) { if (((TCardType)cbbCardType.Items[i]).id == pubData.CardTypeID) { cbbCardType.SelectedIndex = i; break; } } txtCardStartDate.Text = pubData.CardBeginDate.ToShortDateString(); txtCardEndDate.Text = pubData.CardEndDate.ToShortDateString(); txtDepartName.Text = DepartName; txtCardStatusName.Text = CardStatusName; txtFaDate.Text = FaDate; txtSFCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); IsReadCard = true; Pub.CardBuzzer(); ResetForm(); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard()) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = sfData.BtMonery;// db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = ShowBTMoney.ToString(SystemInfo.CurrencySymbol + "0.00"); List <string> sql = new List <string>(); sql.Clear(); double mm = -money; double mmCZ = 0; double mmBT = 0; sfData.UseDate = dt; sfData.UseTimes += 1; if (rb1.Checked) { if (sfData.Balance < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.Balance -= money; mmCZ = -money; } else { if (sfData.BtMonery < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.BtMonery -= money; mmBT = -money; } double x = sfData.Balance + sfData.BtMonery; DataTableReader dr = null; string OpterStartDate = ""; string OpterEndDate = ""; DateTime StartDt = new DateTime(); DateTime EndDt = new DateTime(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "251", pubData.CardNo })); while (dr.Read()) { OpterStartDate = ""; OpterEndDate = ""; OpterStartDate = dr["OpterStartDate"].ToString(); OpterEndDate = dr["OpterEndDate"].ToString(); if (OpterStartDate != "") { StartDt = Convert.ToDateTime(OpterStartDate); } if (OpterEndDate != "") { EndDt = Convert.ToDateTime(OpterEndDate); } if (OpterStartDate != "" && OpterEndDate != "") { if (dt > StartDt && dt < EndDt) { break; } } else if (OpterStartDate != "" && OpterEndDate == "") { if (dt > StartDt) { OpterEndDate = dt.ToString(SystemInfo.SQLDateTimeFMT); break; } } } if (OpterStartDate != "") { OpterStartDate = Convert.ToDateTime(OpterStartDate).ToString(SystemInfo.SQLDateTimeFMT); } if (OpterEndDate != "") { OpterEndDate = Convert.ToDateTime(OpterEndDate).ToString(SystemInfo.SQLDateTimeFMT); } sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), mmCZ.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", mmBT.ToString(), sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money; double ReceivablesAmount = money; double CardBalance = x; string AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = sfData.BtMonery.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, CardBalance); db.WriteSYLog(this.Text, CurrentOprt, msg); DispExtScreen(Amount, CardBalance, 0, 0); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void ItemCardFill_Click(object sender, EventArgs e) { if (!DeviceObject.objCPIC.IsOnline()) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ReadCardError1", "")); return; } IsFilling = true; RefreshForm(false); DataTable dt = (DataTable)bindingSource.DataSource; DataRow dr = null; string msg = ""; string EmpSysID = ""; string EmpNo = ""; string EmpName = ""; string CardData10; string CardDataH; string CardData8; string CardInfo; string ErrMsg = ""; int pos = bindingSource.Position; while (IsFilling) { for (int i = pos; i < dt.Rows.Count; i++) { bindingSource.Position = i; dataGrid.CurrentCell = dataGrid.SelectedRows[0].Cells[0]; dr = dt.Rows[i]; EmpSysID = dr["EmpSysID"].ToString(); EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); msg = Pub.GetResText(formCode, "MsgCardFillPhysicsInfo", ""); msg = string.Format(msg, EmpNo, EmpName); RefreshMsg(StrFilling + msg); LoopCard: Application.DoEvents(); if (!IsFilling) { ItemCardStop_Click(null, null); return; } CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8, ref ErrMsg)) { lblMsg.Text = ErrMsg; goto LoopCard; } CardInfo = ""; if (db.CardPhysicsNoIsExists(EmpSysID, CardData10, ref CardInfo)) { if (CardInfo == " ") { msg = Pub.GetResText(formCode, "MsgCardFillPhysicsInfo", ""); } else { msg = Pub.GetResText(formCode, "MsgCardPhysicsExistsUseing", ""); } msg = string.Format(msg, CardData10, CardInfo); if (Pub.MessageBoxShowQuestion(msg)) { IsFilling = false; break; } else { goto LoopCard; } } ContinueData: Application.DoEvents(); if (!IsFilling) { break; } if (!db.EmpCardFillPhysics(this.Text, ItemCardFill.Text, EmpSysID, CardData10, CardData8)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { break; } else { goto ContinueData; } } lblMsg.Text = Pub.GetResText(formCode, "MsgCardFillPhysicsSuccess", ""); IsFillOk = true; Pub.CardBuzzer(); dr["CardPhysicsNo10"] = CardData10; LoopNoCard: Application.DoEvents(); if (DeviceObject.objCPIC.CardIsExists()) { goto LoopNoCard; } } IsFilling = false; } ItemCardStop_Click(null, null); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard(false)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); if (skData.Money - money < 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorBalanceIsZero", "")); return; } List <string> sql = new List <string>(); sql.Clear(); string Title; double Amount; double ReceivablesAmount; double CardBalance; string AmountTitle; skData.Money -= money; double m = -money; sql.Add(Pub.GetSQL(DBCode.DB_005001, new string[] { "0", pubData.CardNo, "30", dt.ToString(SystemInfo.SQLDateTimeFMT), m.ToString("0.00"), skData.Money.ToString("0.00"), OprtInfo.OprtSysID })); Title = Pub.GetResText(formCode, "RefundmentTitle", ""); Amount = money; ReceivablesAmount = money; CardBalance = skData.Money; AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; skData.CardTime = dt; ContinueSK: Application.DoEvents(); CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSK; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSK; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSK; } } } cardRet = Pub.WriteCardInfo(skData); if (cardRet != 0) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSK; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinueSK; } } } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); db.WriteSYLog(this.Text, Title, sql); Pub.CardBuzzer(); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = Title + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; string cap = tabControl1.SelectedTab.Text; if (tabControl1.SelectedIndex == 0) { double.TryParse(CurrencyToStringEx(txtDepositMoney.Text), out money); } else { double.TryParse(CurrencyToStringEx(txtTransferAmount.Text), out money); } if (money <= 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard(false)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (tabControl1.SelectedIndex == 1) { if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); if (!SystemInfo.SKDepositTotal) { skData.Money = 0; } if (skData.Money + money > SystemInfo.MaxDepositSK) { Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBig", ""), SystemInfo.MaxDeposit)); return; } List <string> sql = new List <string>(); double AllBalance = 0; sql.Clear(); string[] Title; double[] Amount; double[] ReceivablesAmount; double[] CardBalance; string[] AmountTitle; if (tabControl1.SelectedIndex == 0) { skData.Money += money; sql.Add(Pub.GetSQL(DBCode.DB_005001, new string[] { "0", pubData.CardNo, "10", dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString("0.00"), skData.Money.ToString("0.00"), OprtInfo.OprtSysID })); Title = new string[1] { Pub.GetResText(formCode, "DepositTitle", "") }; Amount = new double[1] { money }; ReceivablesAmount = new double[1] { money }; CardBalance = new double[1] { skData.Money }; AmountTitle = new string[1] { label6.Text }; } else { double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); AllBalance = sfData.Balance + ShowBTMoney; txtSKCardBalanceSF.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); if (AllBalance < money) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } skData.Money += money; sfData.UseDate = dt; sfData.UseTimes += 1; sql.Add(Pub.GetSQL(DBCode.DB_005001, new string[] { "0", pubData.CardNo, "20", dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString(), skData.Money.ToString(), OprtInfo.OprtSysID })); if (ShowBTMoney == 0) { sfData.Balance -= money; if (sfData.BtMonery > 0) { double m = -sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), m.ToString(), AllBalance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); sfData.UseTimes += 1; sfData.BtMonery = 0; } } else { sfData.BtMonery -= money; if (sfData.BtMonery < 0) { sfData.Balance += sfData.BtMonery; sfData.BtMonery = 0; } } AllBalance -= money; double mm = -money; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "20", dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(SystemInfo.SQLDateTimeFMT), AllBalance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); Title = new string[2] { Pub.GetResText(formCode, "DepositTitle", ""), Pub.GetResText(formCode, "RefundmentTitle", "") }; Amount = new double[2] { money, money }; ReceivablesAmount = new double[2] { money, money }; CardBalance = new double[2] { skData.Money, AllBalance }; AmountTitle = new string[2] { label6.Text, Pub.GetResText(formCode, "RefundmentMoney", "") }; } if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; skData.CardTime = dt; ContinueSK: Application.DoEvents(); CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSK; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSK; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSK; } } } cardRet = Pub.WriteCardInfo(skData); if (cardRet != 0) { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ContinueSK; } } if (tabControl1.SelectedIndex == 1) { bool IsSFError = false; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } } txtSKCardBalanceSK.Text = skData.Money.ToString(SystemInfo.CurrencySymbol + "0.00"); txtSKCardBalanceSF.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); db.WriteSYLog(this.Text, cap, sql); Pub.CardBuzzer(); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = cap + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void WriteCard1() { ResetForm(1); double money = 0; double.TryParse(CurrencyToStringEx(txtMoney1.Text), out money); if (money <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard(1)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); if (!SystemInfo.AllowRefAllowance) { ShowBTMoney = 0; } double AllBalance = sfData.Balance + ShowBTMoney; textBox2.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); if (AllBalance < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.UseDate = dt; sfData.UseTimes += 1; List <string> sql = new List <string>(); sql.Clear(); if (ShowBTMoney == 0) { sfData.Balance -= money; if (sfData.BtMonery > 0 && SystemInfo.AllowRefAllowance) { double m = -sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), m.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); sfData.UseTimes += 1; sfData.BtMonery = 0; } } else { sfData.BtMonery -= money; if (sfData.BtMonery < 0) { sfData.Balance += sfData.BtMonery; sfData.BtMonery = 0; } } double mm = -money; AllBalance = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "20", dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(), AllBalance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money; double ReceivablesAmount = money; double CardBalance = AllBalance; string AmountTitle = label14.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + textBox8.Text + "]" + textBox9.Text + ": " + textBox5.Text + "/" + textBox7.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); textBox2.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentTool, msg); DispExtScreen(Amount, temp, 1, 2); if (checkBox1.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult1.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void WriteCard() { string DepositType = "120"; double money = 0; double BTmoney = 0; double Fact = 0; double.TryParse(CurrencyToStringEx(GetSFAmount()), out money); double.TryParse(CurrencyToStringEx(GetBTAmount()), out BTmoney); money = Math.Abs(money); BTmoney = Math.Abs(BTmoney); frmPubCorrection frm = new frmPubCorrection(money, BTmoney); if (frm.ShowDialog() == DialogResult.OK) { money = frm.Money; BTmoney = frm.MoneyBT; } else { return; } if (money <= 0 && BTmoney <= 0) { IsReadCard = false; Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard()) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { IsReadCard = false; return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { IsReadCard = false; return; } Pub.ClearCardLimitInfo(dt, ref sfData); double AllBalance = sfData.Balance; List <string> sql = new List <string>(); sql.Clear(); string Title = Pub.GetResText(formCode, "DepositTitle", ""); double Amount = money + BTmoney; double ReceivablesAmount = Fact; double CardBalance = AllBalance + Fact; sfData.Balance = sfData.Balance + money; sfData.BtMonery = sfData.BtMonery + BTmoney; sfData.UseTimes = sfData.UseTimes + 1; sfData.UseDate = dt; double mm = sfData.Balance; double BTmm = sfData.BtMonery; string OpterStartDate = ""; string OpterEndDate = ""; DataTableReader dr = null; DateTime StartDt = new DateTime(); DateTime EndDt = new DateTime(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "251", pubData.CardNo })); while (dr.Read()) { OpterStartDate = ""; OpterEndDate = ""; OpterStartDate = dr["OpterStartDate"].ToString(); OpterEndDate = dr["OpterEndDate"].ToString(); if (OpterStartDate != "") { StartDt = Convert.ToDateTime(OpterStartDate); } if (OpterEndDate != "") { EndDt = Convert.ToDateTime(OpterEndDate); } if (OpterStartDate != "" && OpterEndDate != "") { if (dt > StartDt && dt < EndDt) { break; } } else if (OpterStartDate != "" && OpterEndDate == "") { if (dt > StartDt) { OpterEndDate = dt.ToString(SystemInfo.SQLDateTimeFMT); break; } } } if (OpterStartDate != "") { OpterStartDate = Convert.ToDateTime(OpterStartDate).ToString(SystemInfo.SQLDateTimeFMT); } if (OpterEndDate != "") { OpterEndDate = Convert.ToDateTime(OpterEndDate).ToString(SystemInfo.SQLDateTimeFMT); } sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DepositType, dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", BTmoney.ToString(), BTmm.ToString(), "0", OpterStartDate, OpterEndDate })); if (db.ExecSQL(sql) != 0) { IsReadCard = false; return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ReadCardError3", "")); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { IsReadCard = false; return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { IsReadCard = false; return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance; Pub.CardBuzzer(); string CurrentOprt = Pub.GetResText(formCode, "ItemEdit", ""); string msg = string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentOprt, msg); DispExtScreen(Amount, temp, 0, 1); Pub.MessageBoxShow(CurrentOprt + Pub.GetResText(formCode, "MsgSuccess", ""), MessageBoxIcon.Asterisk); IsReadCard = false; }
private void WriteCard() { int RetirementFlag = 0; string msg = ""; DateTime CardUseDate = new DateTime(); CardUseDate = Convert.ToDateTime(txtCardUseDate.Text); DateTime NowDate = new DateTime(); if (!db.GetServerDate(ref NowDate)) { return; } if (CardUseDate > NowDate.AddDays(360) || CardUseDate.AddDays(360) < NowDate) { string mmg = string.Format(Pub.GetResText(formCode, "MsgCardUseDate", ""), txtCardUseDate.Text); Pub.ShowErrorMsg(mmg); return; } if (rbNormal.Checked) { RetirementFlag = 2; msg = rbNormal.Text; } else { RetirementFlag = 1; msg = rbLoss.Text; } msg = msg + "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; if (!IsReadCard) { if (rbNormal.Checked) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardReadFirst", "")); } else { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgEmpFindFirst", "")); } return; } int cardRet = 0; if (SystemInfo.HasSF) { cardRet = db.CheckSFAllowance(EmpSysID); if (cardRet == 1) { if (!Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardHasAllowance", ""))) { IsWorking = false; ShowSFAllowance = true; this.Close(); return; } } else if (cardRet == 2) { return; } } if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardRetirementContinue", ""))) { return; } ContinueData: Application.DoEvents(); if (!db.EmpCardRetirement(this.Text, oprt, EmpSysID, RetirementFlag, BTMoney, ShowBTMoney, CardBalance, CardFee, CardUseTimes, CardData10, MacTag)) { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", ""))) { return; } else { goto ContinueData; } } if (RetirementFlag == 2) { string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; ClearCard: if (!DeviceObject.objCPIC.GetCardData(ref CardNo10, ref CardNoH, ref CardNo8)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ClearCard; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ClearCard; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ClearCard; } } } cardRet = Pub.ClearCardInfo(); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ClearCard; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { goto ClearCard; } } } Pub.CardBuzzer(); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } db.EmpHistoryCard(this.Text, oprt, EmpSysID, txtCardSectorNo.Text, dt, 3); lblResult.Text = Pub.GetResText(formCode, "MsgCardRetirementSuccess", ""); IsChgOk = true; IsReadCard = false; msg = msg + string.Format("[{0:f2},{1:f2},{0:f2}]", CardBalance, ShowBTMoney, CardFee); if (chkPrint.Checked) { double Amount = CardBalance + ShowBTMoney + CardFee; string Title = Pub.GetResText(formCode, "RetirementTitle", ""); string AmountTitle = label7.Text; PrintCardBillByEmpSysID(Title, Amount, Amount, 0, AmountTitle, EmpSysID); } db.WriteSYLog(this.Text, oprt, msg); db.UpdateEmpRegisterData(EmpSysID, 11, ""); Pub.MessageBoxShow(lblResult.Text, MessageBoxIcon.Information); ResetForm(); }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; string AmountTitle = label6.Text; string DepositType = "10"; if (ExistsDepositType) { DepositType = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).id; AmountTitle = cbbType.Text; } double money = 0; double Fact = 0; string TradeNo = ""; double DiscountMoney = 0; int DiscountType = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { IsReadCard = false; Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } double MobileMoney = money; if (!SystemInfo.IgnoreMobile && (DepositType == "100" || DepositType == "101")) { money -= MobileInfo.RateMoney(DepositType == "100", MobileMoney); } Fact = money; if (SystemInfo.AllowCheckDepositLimit == 3) { if (!IsReadCard) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardReadFirst", "")); return; } } else { if (!ReadCard()) { return; } } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { IsReadCard = false; return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { IsReadCard = false; return; } Pub.ClearCardLimitInfo(dt, ref sfData); double AllBalance = sfData.Balance; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); double tmpMoney = 0; byte discFlag = db.GetDiscDiscount(money, pubData.CardTypeID, ref tmpMoney); if (discFlag == 2) { IsReadCard = false; return; } if (discFlag == 1) { DiscountMoney = tmpMoney; Fact = money + DiscountMoney; DiscountType = 80; } else if ((Discount > 0) && (Discount != 100)) { DiscountMoney = money * Discount / 100; DiscountMoney = DiscountMoney - money; Fact = money + DiscountMoney; if (DiscountMoney > 0) { DiscountType = 80; } else { DiscountType = 70; } } if (AllBalance + Fact > SystemInfo.MaxDeposit) { IsReadCard = false; Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBig", ""), SystemInfo.MaxDeposit)); return; } if (SystemInfo.AllowCheckDepositLimit == 1) { if (CardDepositLimit > 0 && sfData.Balance + Fact >= CardDepositLimit) { IsReadCard = false; Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBigA", ""), CardDepositLimit)); return; } } else if (SystemInfo.AllowCheckDepositLimit == 2) { if (!db.CheckDepositLimit(EmpSysID, CardDepositLimit, CardDepositTimes, Fact)) { IsReadCard = false; return; } } if (!SystemInfo.IgnoreMobile && (DepositType == "100" || DepositType == "101")) { int h = SystemInfo.MainHandle.ToInt32(); bool IsWeiXin = DepositType == "100", ret; bool IsPayM = false; string ErrMsg = ""; TradeNo = ""; if (chkPayCode.Checked) { DeviceObject.objCard.MobilePayCodeSet(cbbCommPort.Text); ret = DeviceObject.objCard.MobilePayCode(h, chkPayCodeUSB.Checked, CardData10, pubData.CardNo, MobileMoney, ref IsWeiXin, ref IsPayM, true, ref TradeNo, ref ErrMsg); } else { ret = DeviceObject.objCard.MobileShow(h, CardData10, pubData.CardNo, MobileMoney, ref IsWeiXin, ref IsPayM, true, ref TradeNo, ref ErrMsg); } if (!ret) { IsReadCard = false; Pub.ShowErrorMsg(ErrMsg); return; } DepositType = IsWeiXin ? "100" : "101"; } List <string> sql = new List <string>(); sql.Clear(); string Title = Pub.GetResText(formCode, "DepositTitle", ""); double Amount = money; double ReceivablesAmount = Fact; double CardBalance = AllBalance + Fact; sfData.Balance = sfData.Balance + money; sfData.UseTimes = sfData.UseTimes + 1; sfData.UseDate = dt; double mm = sfData.Balance; string OpterStartDate = ""; string OpterEndDate = ""; string OpterEndDate0 = ""; DataTableReader dr = null; DateTime StartDt = new DateTime(); DateTime EndDt = new DateTime(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "251", pubData.CardNo })); while (dr.Read()) { OpterStartDate = ""; OpterEndDate = ""; OpterStartDate = dr["OpterStartDate"].ToString(); OpterEndDate = dr["OpterEndDate"].ToString(); if (OpterStartDate != "") { StartDt = Convert.ToDateTime(OpterStartDate); } if (OpterEndDate != "") { EndDt = Convert.ToDateTime(OpterEndDate); } if (OpterStartDate != "" && OpterEndDate != "") { if (dt > StartDt && dt < EndDt) { break; } } else if (OpterStartDate != "" && OpterEndDate == "") { if (dt > StartDt) { OpterEndDate = dt.ToString(SystemInfo.SQLDateTimeFMT); OpterEndDate0 = dt.AddSeconds(1).ToString(SystemInfo.SQLDateTimeFMT); break; } } } if (OpterStartDate != "") { OpterStartDate = Convert.ToDateTime(OpterStartDate).ToString(SystemInfo.SQLDateTimeFMT); } if (OpterEndDate != "") { OpterEndDate = Convert.ToDateTime(OpterEndDate).ToString(SystemInfo.SQLDateTimeFMT); } sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DepositType, dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, TradeNo, "0", sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate })); if (DiscountMoney != 0) { sfData.Balance = sfData.Balance + DiscountMoney; sfData.UseTimes = sfData.UseTimes + 1; mm = sfData.Balance; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DiscountType.ToString(), dt.AddSeconds(1).ToString(SystemInfo.SQLDateTimeFMT), DiscountMoney.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, TradeNo, "0", sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate0 })); } if (db.ExecSQL(sql) != 0) { IsReadCard = false; return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { IsReadCard = false; return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { IsReadCard = false; return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + sfData.BtMonery; txtCardBalance.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentOprt, msg); DispExtScreen(Amount, temp, 0, 1); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); IsReadCard = false; }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard(true)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); List <string> sql = new List <string>(); sql.Clear(); string cap = ((TCommonType)cbbSFType.Items[cbbSFType.SelectedIndex]).name; string SFType = ((TCommonType)cbbSFType.Items[cbbSFType.SelectedIndex]).id; byte flag = 0; if (SFType == "2") { flag = 4; } string MealType = ((TCommonType)cbbMealType.Items[cbbMealType.SelectedIndex]).id; bool DecMoney = (SFType == "1") || (SFType == "60"); if (DecMoney) { if (AllBalance < money) { Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } } sfData.UseDate = dt; if ((ShowBTMoney == 0) && (sfData.BtMonery > 0)) { sfData.UseTimes += 1; double m = -sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), m.ToString(), AllBalance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); sfData.BtMonery = 0; } else { if (DecMoney) { sfData.UseTimes += 1; sfData.BtMonery -= money; if (sfData.BtMonery < 0) { sfData.Balance += sfData.BtMonery; sfData.BtMonery = 0; } } AllBalance -= money; } double mm = -money; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, SFType, dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(), AllBalance.ToString(), MealType, "255", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); string Title = cap; double Amount = money; double ReceivablesAmount = money; double CardBalance = AllBalance; string AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.MessageBoxShow(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalance.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); DispExtScreen(Amount, temp, 1, flag); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }