private void btnCardNo_Click(object sender, EventArgs e) { HSUNFK.TCardPubData pubData = new HSUNFK.TCardPubData(); HSUNFK.TCardSFData sfData = new HSUNFK.TCardSFData(); if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return; } txtCardNo.Text = pubData.CardNo; ExecItemRefresh(); }
public void ClearCardLimitInfo(DateTime dt, ref HSUNFK.TCardSFData sfData) { DateTime d1 = new DateTime(dt.Year, dt.Month, dt.Day); DateTime d2 = Convert.ToDateTime(sfData.UseDate); DateTime d3 = new DateTime(d2.Year, d2.Month, d2.Day); if (d1 != d3) { sfData.LimitMoney1 = "000000"; sfData.LimitTimes1 = 0; sfData.LimitMoney2 = "000000"; sfData.LimitTimes2 = 0; sfData.LimitMoney3 = "000000"; sfData.LimitTimes3 = 0; sfData.LimitMoney4 = "000000"; sfData.LimitTimes4 = 0; } if (d1.ToString(SystemInfo.YMFormatCard) != d3.ToString(SystemInfo.YMFormatCard)) { sfData.LimitMoneyMonth = "000000"; sfData.LimitTimesMonth = 0; } }
private bool ReadCard() { countTimes = 0; countMoney = 0; CardDepositLimit = 0; CardDepositTimes = 0; CardData10 = ""; CardDataH = ""; CardData8 = ""; EmpSysID = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return(false); } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return(false); } if (!Pub.CheckCardValidDate(dt, pubData.CardBeginDate, pubData.CardEndDate)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardDepositNotNormal", "")); } else { EmpSysID = dr["EmpSysID"].ToString(); 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(); txtCardType.Text = dr["CardTypeName"].ToString(); int.TryParse(dr["DepositDiscount"].ToString(), out Discount); txtDepositDiscount.Text = Discount.ToString(); double.TryParse(dr["CardDepositLimit"].ToString(), out CardDepositLimit); int.TryParse(dr["CardDepositTimes"].ToString(), out CardDepositTimes); IsOk = true; } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk && SystemInfo.AllowCheckDepositLimit == 3) { IsOk = false; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004013, new string[] { "200", EmpSysID })); if (dr.Read()) { double.TryParse(dr["SFAmount"].ToString(), out countMoney); int.TryParse(dr["Times"].ToString(), out countTimes); IsOk = true; } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } } return(IsOk); }
private bool ReadCard() { CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return(false); } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return(false); } if (!Pub.CheckCardValidDate(dt, pubData.CardBeginDate, pubData.CardEndDate)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } if (pubData.CardNo != GetCardNo()) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorCard", "")); return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardRefunNotNormal", "")); } else if (!Convert.ToBoolean(dr["CardRefundment"].ToString())) { Pub.ShowErrorMsg(string.Format(Pub.GetResText("", "ErrorCardRefundment", ""), dr["CardTypeName"].ToString())); } else { IsOk = true; } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(IsOk); }
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 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 bool ReadCard(byte flag) { CardDepositLimit = 0; CardDepositTimes = 0; CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return(false); } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return(false); } if (!Pub.CheckCardValidDate(dt, pubData.CardBeginDate, pubData.CardEndDate)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { if (flag == 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardDepositNotNormal", "")); } else { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardRefunNotNormal", "")); } } else if (flag != 0 && !Convert.ToBoolean(dr["CardRefundment"].ToString())) { Pub.ShowErrorMsg(string.Format(Pub.GetResText("", "ErrorCardRefundment", ""), dr["CardTypeName"].ToString())); } else { IsOk = true; if (flag == 0) { 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(); txtCardType.Text = dr["CardTypeName"].ToString(); int.TryParse(dr["DepositDiscount"].ToString(), out Discount); txtDepositDiscount.Text = Discount.ToString(); double.TryParse(dr["CardDepositLimit"].ToString(), out CardDepositLimit); int.TryParse(dr["CardDepositTimes"].ToString(), out CardDepositTimes); } else { if (ExistsDepositType) { string SFTypeName = ""; double SFAmount = 0; IsOk = db.SFGetLastSFType(dr["EmpSysID"].ToString(), ref SFTypeName, ref SFAmount); if (IsOk && (SFTypeName != "")) { txtUpDepositType.Text = SFTypeName + ":" + SFAmount.ToString(SystemInfo.CurrencySymbol + "0.00"); } } if (IsOk) { textBox8.Text = dr["EmpNo"].ToString(); textBox9.Text = dr["EmpName"].ToString(); textBox7.Text = dr["DepartName"].ToString(); textBox5.Text = dr["CardSectorNo"].ToString(); textBox6.Text = dr["CardStatusName"].ToString(); textBox4.Text = dr["CardTypeName"].ToString(); } } } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(IsOk); }
private bool ReadCard(bool ReadAll) { CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); skData = new HSUNFK.TCardSKData(); if ((tabControl1.SelectedIndex == 0) && !ReadAll) { if (!Pub.ReadCardInfo(ref pubData)) { return(false); } if (!Pub.ReadCardInfo(ref skData)) { return(false); } } else { if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return(false); } if (!Pub.ReadCardInfo(ref skData)) { return(false); } } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardDepositNotNormal", "")); } else if (tabControl1.SelectedIndex != 0 && !Convert.ToBoolean(dr["CardRefundment"].ToString())) { Pub.ShowErrorMsg(string.Format(Pub.GetResText("", "ErrorCardRefundment", ""), 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(); txtCardType.Text = dr["CardTypeName"].ToString(); IsOk = true; } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(IsOk); }
private void btnReadCard_Click(object sender, EventArgs e) { IsReadCard = false; pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.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 DepartID = ""; 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.ShowErrorMsg(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(); DepartID = dr["DepartSysID"].ToString(); CardStatusName = dr["CardStatusName"].ToString(); FaDate = dr["FaDate"].ToString(); CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"].ToString()); IsOk = true; } } else { Pub.ShowErrorMsg(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; txtDepartName.Tag = DepartID; txtCardStatusName.Text = CardStatusName; txtFaDate.Text = FaDate; txtSFCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); IsReadCard = true; Pub.CardBuzzer(); ResetForm(); txtEmpNo.Focus(); }