Example #1
0
        private bool ReadCard(bool ReadAll)
        {
            CardData10 = "";
            CardDataH  = "";
            CardData8  = "";
            if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8))
            {
                return(false);
            }
            pubData = new QHAPI.TCardPubData();
            sfData  = new QHAPI.TCardSFData();
            skData  = new QHAPI.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.MessageBoxShow(Pub.GetResText(formCode, "MsgCardDepositNotNormal", ""));
                    }
                    else if (tabControl1.SelectedIndex != 0 && !Convert.ToBoolean(dr["CardRefundment"].ToString()))
                    {
                        Pub.MessageBoxShow(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.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", ""));
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            return(IsOk);
        }
Example #2
0
        private bool ReadCard()
        {
            CardData10 = "";
            CardDataH  = "";
            CardData8  = "";
            if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8))
            {
                return(false);
            }
            pubData = new QHAPI.TCardPubData();
            sfData  = new QHAPI.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.MessageBoxShow(Pub.GetResText(formCode, "MsgCardRefunNotNormal", ""));
                    }
                    else
                    {
                        IsOk = true;
                        if (SystemInfo.HasMoreDepositType)
                        {
                            string SFTypeName = "";
                            double SFAmount   = 0;
                            IsOk = db.SFGetLastSFType(dr["EmpSysID"].ToString(), ref SFTypeName, ref SFAmount);
                            if (IsOk && (SFTypeName != ""))
                            {
                                txtCardBalanceBT.Text = SFTypeName + ":" + SFAmount.ToString(SystemInfo.CurrencySymbol + "0.00");
                            }
                        }
                        if (IsOk)
                        {
                            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();
                        }
                    }
                }
                else
                {
                    Pub.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", ""));
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            return(IsOk);
        }
Example #3
0
        private void btnReadCard_Click(object sender, EventArgs e)
        {
            IsReadCard = false;
            pubData    = new QHAPI.TCardPubData();
            sfData     = new QHAPI.TCardSFData();
            CardData10 = "";
            CardDataH  = "";
            CardData8  = "";
            if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8))
            {
                return;
            }
            if (!Pub.ReadCardInfo(ref pubData, ref sfData))
            {
                ResetForm();
                return;
            }
            if (!db.CheckCardExists(pubData.CardNo, CardData10))
            {
                ResetForm();
                return;
            }
            if (!db.CheckDepartPowerByCard(pubData.CardNo))
            {
                ResetForm();
                return;
            }
            DataTableReader dr             = null;
            bool            IsOk           = false;
            string          EmpNo          = "";
            string          EmpName        = "";
            string          CardPWD        = "";
            string          DepartName     = "";
            string          CardStatusName = "";
            string          FaDate         = "";

            CardCheckOrder = false;
            SysID          = "";
            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo }));
                if (dr.Read())
                {
                    if (Convert.ToInt32(dr["CardStatusID"]) != 20)
                    {
                        Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardModifyNotNormal", ""));
                    }
                    else
                    {
                        SysID          = dr["EmpSysID"].ToString();
                        EmpNo          = dr["EmpNo"].ToString();
                        EmpName        = dr["EmpName"].ToString();
                        CardPWD        = dr["CardPWD"].ToString();
                        DepartName     = dr["DepartName"].ToString();
                        CardStatusName = dr["CardStatusName"].ToString();
                        FaDate         = dr["FaDate"].ToString();
                        CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"].ToString());
                        IsOk           = true;
                    }
                }
                else
                {
                    Pub.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", ""));
                }
            }
            catch (Exception E)
            {
                IsOk = false;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (!IsOk)
            {
                ResetForm();
                return;
            }
            double BTMoney    = db.GetBTMoney(sfData.BtDate, sfData.BtMonery);
            double AllBalance = sfData.Balance + BTMoney;

            txtEmpNo.Text             = EmpNo;
            txtEmpName.Text           = EmpName;
            txtCardPWD.Text           = CardPWD;
            txtCardPWDA.Text          = CardPWD;
            txtCardSectorNo.Text      = pubData.CardNo;
            cbbCardType.SelectedIndex = -1;
            for (int i = 0; i < cbbCardType.Items.Count; i++)
            {
                if (((TCardType)cbbCardType.Items[i]).id == pubData.CardTypeID)
                {
                    cbbCardType.SelectedIndex = i;
                    break;
                }
            }
            txtCardStartDate.Text  = pubData.CardBeginDate.ToShortDateString();
            txtCardEndDate.Text    = pubData.CardEndDate.ToShortDateString();
            txtDepartName.Text     = DepartName;
            txtCardStatusName.Text = CardStatusName;
            txtFaDate.Text         = FaDate;
            txtSFCardBalance.Text  = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00");
            IsReadCard             = true;
            Pub.CardBuzzer();
            ResetForm();
        }
Example #4
0
        private bool ReadCard(bool ReadAll)
        {
            CardData10 = "";
            CardDataH  = "";
            CardData8  = "";
            string ErrorMsg = "";

            if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8, false))
            {
                lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", "");
                return(false);
            }
            pubData = new QHAPI.TCardPubData();
            skData  = new QHAPI.TCardSKData();
            if (!Pub.ReadCardInfo(ref pubData, ref ErrorMsg))
            {
                lblResult.Text = ErrorMsg;
                return(false);
            }
            if (!db.CheckCardExists(pubData.CardNo, CardData10))
            {
                return(false);
            }
            if (!Pub.ReadCardInfo(ref skData, ref ErrorMsg))
            {
                lblResult.Text = ErrorMsg;
                return(false);
            }
            DataTableReader dr   = null;
            bool            IsOk = false;

            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                if (!db.CheckDepartPowerByCard(pubData.CardNo, ref ErrorMsg))
                {
                    lblResult.Text = ErrorMsg;
                    return(false);
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo }));
                if (dr.Read())
                {
                    if (Convert.ToInt32(dr["CardStatusID"]) != 20)
                    {
                        lblResult.Text = Pub.GetResText(formCode, "MsgCardDepositNotNormal", "");
                    }
                    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
                {
                    lblResult.Text = Pub.GetResText("", "ErrorIllegalCard", "");
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            return(IsOk);
        }
Example #5
0
        private bool ReadCard()
        {
            CardData10 = "";
            CardDataH  = "";
            CardData8  = "";
            if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8))
            {
                return(false);
            }
            pubData = new QHAPI.TCardPubData();
            sfData  = new QHAPI.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.MessageBoxShow(Pub.GetResText(formCode, "MsgCardDepositNotNormal", ""));
                    }
                    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();
                        int.TryParse(dr["DepositDiscount"].ToString(), out Discount);
                        txtDepositDiscount.Text = Discount.ToString();
                        IsOk = true;
                    }
                }
                else
                {
                    Pub.MessageBoxShow(Pub.GetResText("", "ErrorIllegalCard", ""));
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            return(IsOk);
        }
Example #6
0
        private void FaCard(bool IsBatch, string Oprt)
        {
            frmAppMain frm = Pub.GetAppMainForm();

            if (SystemInfo.CardKey == "")
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorCardkey", ""));
                if (frm != null)
                {
                    frm.ExecModule("SYOption", "");
                }
                return;
            }
            if (SystemInfo.DealersCode == "")
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorDealersCode", ""));
                if (frm != null)
                {
                    frm.ExecModule("SYOption", "");
                }
                return;
            }
            if (SystemInfo.CustomersCode == 0)
            {
                Pub.MessageBoxShow(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();

            if (!db.GetServerDate(ref d))
            {
                return;
            }
            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;
            DateTime CardStartDate   = new DateTime();
            DateTime CardEndDate     = new DateTime();
            bool     IsFirst         = true;
            long     CardDays        = 0;
            string   CardPWD         = "";
            string   EmpNo           = "";
            string   EmpName         = "";
            int      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();

            QHAPI.TCardPubData pubData = new QHAPI.TCardPubData();
            QHAPI.TCardSFData  sfData  = new QHAPI.TCardSFData();
            QHAPI.TCardSKData  skData  = new QHAPI.TCardSKData();
            bool IsError = false;

            while (IsFaCard)
            {
                for (int i = currRow; i < dt.Rows.Count; i++)
                {
                    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.MessageBoxShow(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.MessageBoxShow(Pub.GetResText(formCode, "ErrorBuildCardFailed", ""));
                                ItemStop_Click(null, null);
                                return;
                            }
                        }
                        msg = Pub.GetResText(formCode, "MsgCardFaInfo", "");
                        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 QHAPI.TCardPubData();
                    cardRet = DeviceObject.objCPIC.ReadCardInfoPub(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 (!SystemInfo.AllowCustomerCardNo)
                    {
                        CardSectorNo = CardData10;
                    }
                    Application.DoEvents();
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.Date;
                    pubData.CardEndDate   = CardEndDate.Date;
                    pubData.IsCheckOrder  = Convert.ToByte(CardCheckOrder);
                    if (!db.GetServerDate(ref d))
                    {
                        ItemStop_Click(null, null);
                        return;
                    }
                    sfData         = new QHAPI.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 QHAPI.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", "")))
                            {
                                db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                             Convert.ToDateTime(sfData.UseDate), sfData.UseTimes, CardStored, DiscountM, 70, 80,
                                             CardData10, MacTAG);
                                IsFaOk = true;
                                ItemStop_Click(null, null);
                                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", "")))
                        {
                            db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                         Convert.ToDateTime(sfData.UseDate), sfData.UseTimes, CardStored, DiscountM, 70, 80,
                                         CardData10, MacTAG);
                            IsFaOk = true;
                            Pub.ClearCardInfo();
                            ItemStop_Click(null, null);
                            return;
                        }
                        else
                        {
                            IsError = true;
                            goto ContinuePS;
                        }
                    }
ContinueData:
                    Application.DoEvents();
                    if (db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays))
                    {
                        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.MessageBoxShow(msg);
                        CardSectorNo = db.GetMaxCardSectorNo(EmpSysID);
                        if (CardSectorNo == "")
                        {
                            Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorBuildCardFailed", ""));
                            ItemStop_Click(null, null);
                            return;
                        }
                        msg = Pub.GetResText(formCode, "MsgCardFaInfo", "");
                        msg = string.Format(msg, EmpNo, EmpName, CardSectorNo);
                        RefreshMsg(msg);
                        goto LoopCardExists;
                    }
                    if (!db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                      Convert.ToDateTime(sfData.UseDate), sfData.UseTimes, CardStored, DiscountM, 20, 10,
                                      CardData10, MacTAG))
                    {
                        if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", "")))
                        {
                            Pub.ClearCardInfo();
                            Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgCardFaFailed", ""));
                            ItemStop_Click(null, null);
                            return;
                        }
                        else
                        {
                            goto ContinueData;
                        }
                    }
                    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", "");
        }
Example #7
0
        private void btnReadCard_Click(object sender, EventArgs e)
        {
            IsReadCard = false;
            QHAPI.TCardPubData pubData = new QHAPI.TCardPubData();
            QHAPI.TCardSFData  sfData  = new QHAPI.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 + 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.MessageBoxShow(Pub.GetResText(formCode, "MsgCardRetirNotNormal", ""));
                    }
                    else if (!Convert.ToBoolean(dr["CardRetirement"].ToString()))
                    {
                        Pub.MessageBoxShow(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");
                        CardFee = 0;
                        double.TryParse(dr["CardFee"].ToString(), out CardFee);
                        txtCardFee.Text = CardFee.ToString(SystemInfo.CurrencySymbol + "0.00");
                        EmpSysID        = dr["EmpSysID"].ToString();
                        ReFee           = CardBalance + CardFee;
                        txtReFee.Text   = ReFee.ToString(SystemInfo.CurrencySymbol + "0.00");
                        IsOk            = true;
                    }
                }
                else
                {
                    Pub.MessageBoxShow(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         = CardBalance + CardFee;
            txtReFee.Text = ReFee.ToString(SystemInfo.CurrencySymbol + "0.00");
            IsReadCard    = true;
            Pub.CardBuzzer();
            ResetForm();
        }
Example #8
0
        private void WriteCard()
        {
            if (!IsReadCard)
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgEmpFindFirst", ""));
                return;
            }
            string CardNo = txtCardNo.Text.Trim();

            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");
            }
            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.MessageBoxShow(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.MessageBoxShow(string.Format(Pub.GetResText(formCode, "MsgCardCheckExistsUseing", ""), CardData10, UseEmpNo));
                return;
            }
            else if (cardRet == 2)
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""), CardData10));
                return;
            }
            else if (cardRet == 3)
            {
                return;
            }
            if (CardBalance < 0)
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "Msg001", ""));
                return;
            }
            if (!SystemInfo.AllowCustomerCardNo)
            {
                CardNo = CardData10;
            }
            QHAPI.TCardPubData pubData = new QHAPI.TCardPubData();
            if (!Pub.ReadCardInfo(ref pubData))
            {
                return;
            }
            if (pubData.DealersCode != SystemInfo.DealersCode)
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorIllegalCard", ""));
                return;
            }
            if ((pubData.CardNo != "") && (Convert.ToUInt32(pubData.CardNo) > 0))
            {
                Pub.MessageBoxShow(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);
            QHAPI.TCardSFData sfData = new QHAPI.TCardSFData();
            sfData.Balance  = CardBalance;
            sfData.UseDate  = CardUseDate;
            sfData.UseTimes = CardUseTimes;
            sfData.BtMonery = 0;
            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;
            QHAPI.TCardSKData skData = new QHAPI.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.MessageBoxShow(Pub.GetResText(formCode, "MsgCardChangeFailed", ""));
                    return;
                }
                else
                {
                    goto ContinueData;
                }
            }
            Pub.CardBuzzer();
            lblResult.Text = Pub.GetResText(formCode, "MsgCardChangeSuccess", "");
            IsChgOk        = true;
            IsReadCard     = false;
            db.WriteSYLog(this.Text, oprt, oprtMsg);
            db.UpdateEmpRegisterData(EmpSysID, 11, CardData10);
            Pub.MessageBoxShow(lblResult.Text, MessageBoxIcon.Information);
            ResetForm();
        }