Example #1
0
        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;
        }
Example #2
0
        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 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;
        }
Example #4
0
        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", "");
        }
Example #5
0
        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", "");
        }
Example #6
0
        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", "");
        }
Example #7
0
        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", "");
        }
Example #8
0
        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", "");
        }