Beispiel #1
0
        private bool ValidateLoginCode()
        {
            bool check = true;

            if (string.IsNullOrEmpty(txtAdmin.Text))
            {
                SGMHelper.ShowToolTip(txtAdmin, "Tên Admin ?");
                check = false;
            }
            else
            {
                SGMHelper.HideTooltip(txtAdmin);
            }

            if (string.IsNullOrEmpty(txtPwd.Text))
            {
                SGMHelper.ShowToolTip(txtPwd, "Mật khẩu ?");
                check = false;
            }
            else
            {
                SGMHelper.HideTooltip(txtPwd);
            }
            return(check);
        }
Beispiel #2
0
        private bool ValidateDataInput()
        {
            bool bValidate = true;

            Control[] f = { txtGas92New,
                            txtGas95New,
                            txtGasDONew };
            for (int i = 0; i < f.Length; i++)
            {
                SGMHelper.ShowToolTip(f[i], "");
                String txt = f[i].Text.Trim();
                if (txt.Equals(""))
                {
                    SGMHelper.ShowToolTip(f[i], SGMText.UPDATE_TOTAL_INPUT_NULL);
                    bValidate = false;
                    break;
                }
                float tmp;
                if (float.TryParse(txt, out tmp) == false || tmp < 0)
                {
                    SGMHelper.ShowToolTip(f[i], SGMText.UPDATE_TOTAL_INPUT_ERR);
                    bValidate = false;
                    break;
                }
            }
            return(bValidate);
        }
Beispiel #3
0
        private bool ValidateDataInput()
        {
            bool bValidate = true;

            Control[] f = { txtGas92NewPrice,
                            txtGas95NewPrice,
                            txtGasDONewPrice };
            for (int i = 0; i < f.Length; i++)
            {
                String txt = f[i].Text.Trim();
                SGMHelper.ShowToolTip(f[i], "");
                if (txt.Equals(""))
                {
                    SGMHelper.ShowToolTip(f[i], SGMText.UPDATE_PRICE_INPUT_NULL);
                    bValidate = false;
                    break;
                }
                if (!txt.All(Char.IsDigit) || Int32.Parse(txt) < 0)
                {
                    SGMHelper.ShowToolTip(f[i], SGMText.UPDATE_PRICE_INPUT_ERR);
                    bValidate = false;
                    break;
                }
            }
            return(bValidate);
        }
Beispiel #4
0
        private void btnBuy_Click(object sender, EventArgs e)
        {
            m_iTimeOutReset = 0;
            if (txtMoney.Text == "0")
            {
                SGMHelper.ShowToolTip(txtMoney, SGMText.GAS_BUYING_INPUT_MONEY_INVALID);
                return;
            }
            SaleGasDTO dto = new SaleGasDTO();

            dto.CardID                 = _cardDTO.CardID;
            dto.GasStationID           = _gasStationDTO.GasStationID;
            dto.SaleGasType            = rbGas92.Checked ? SaleGasDTO.GAS_TYPE_92 : rbGas95.Checked ? SaleGasDTO.GAS_TYPE_95 : SaleGasDTO.GAS_TYPE_DO;
            dto.SaleGasPriceOnCard     = Int32.Parse(txtPrice.Text, System.Globalization.NumberStyles.Currency);
            dto.SaleGasCardMoneyBefore = Int32.Parse(txtMoneyBefore.Text, System.Globalization.NumberStyles.Currency);
            dto.SaleGasCardMoneyAfter  = Int32.Parse(txtMoneyAfter.Text, System.Globalization.NumberStyles.Currency);
            dto.SaleGasCardMoneySaving = Int32.Parse(txtMoneySaving.Text, System.Globalization.NumberStyles.Currency);
            dto.SaleGasCurrentPrice    = m_iCurrentPrice;
            dto.NumberBuyLit           = float.Parse(txtGasBuying.Text, System.Globalization.NumberStyles.Currency);
            dto.GasStoreID             = _gasStationDTO.GasStoreID;
            DataTransfer df = new DataTransfer();

            df.ResponseDataSaleGasDTO = dto;

            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () =>
            {
                return(service.SGMSaleGas_GasBuying(JSonHelper.ConvertObjectToJSon(df)));
            });

            SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
            {
                String stResponse         = task.Result as String;
                DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse);
                if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
                {
                    m_bBuy = true;
                    //frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.GAS_BUYING_SUCCESS, SGMMessageType.SGM_MESSAGE_TYPE_INFO);
                    // _cardDTO.CardRemainingMoney = _cardDTO.CardRemainingMoney - _moneyBuying;
                    // txtCardMoney.Text = _cardDTO.CardRemainingMoney.ToString(MONEY_FORMAT);
                    // calculatePay();
                    EnableTransaction(false, false);
                    grBill.Text       = SGMText.SALEGAS_MAIN_BILL + txtCardName.Text;
                    txtCardID.Text    = "";
                    txtCardMoney.Text = "";
                    txtMoney.Text     = "0";
                    txtCardName.Text  = "";
                    //rbGas92.Enabled = false;
                    //rbGas95.Enabled = false;
                    //rbGasDO.Enabled = false;
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg + "\n" + dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }
Beispiel #5
0
        private bool ValidateDataInput()
        {
            bool bValidate = true;

            SGMHelper.Clear();
            if (txtCusID.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCusID, SGMText.CUSTOMER_DATA_INPUT_CUS_ID_ERR);
                bValidate = false;
            }
            else if (!txtCusID.Text.Trim().Equals(m_stCusIDEdit))
            {
                Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMManager_CheckCustomerExist(txtCusID.Text.Trim()));
                });
                SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
                {
                    String stResponse     = task.Result as String;
                    DataTransfer response = JSonHelper.ConvertJSonToObject(stResponse);
                    if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
                    {
                        if (response.ResponseDataBool)
                        {
                            SGMHelper.ShowToolTip(txtCusID, SGMText.CUSTOMER_DATA_INPUT_EXIST_CUS_ID_ERR);
                            bValidate = false;
                        }
                    }
                    else
                    {
                        SGMHelper.ShowToolTip(txtCusID, SGMText.CUSTOMER_GET_CUS_ERR);
                        frmMSg.ShowMsg(SGMText.SGM_ERROR, SGMText.CUSTOMER_GET_CUS_ERR + "\n" + response.ResponseErrorMsg + ":\n" + response.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                        bValidate = false;
                    }
                }, SynchronizationContext.Current);
            }
            if (txtCusName.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCusName, SGMText.CUSTOMER_DATA_INPUT_CUS_NAME_ERR);
                bValidate = false;
            }
            if (txtCusBirthday.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCusBirthday, SGMText.CUSTOMER_DATA_INPUT_CUS_BIRTHDAY_ERR);
                bValidate = false;
            }
            if (txtCusVisa.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCusVisa, SGMText.CUSTOMER_DATA_INPUT_CUS_VISA_ERR);
                bValidate = false;
            }
            return(bValidate);
        }
Beispiel #6
0
        private bool ValidateInput()
        {
            bool check = true;

            if (txtAdmin.Text == string.Empty)
            {
                check = false;
                SGMHelper.ShowToolTip(txtAdmin, "Tài khoản ?");
            }
            else
            {
                SGMHelper.ShowToolTip(txtAdmin, "");
            }

            if (txtPwd.Text == string.Empty)
            {
                check = false;
                SGMHelper.ShowToolTip(txtPwd, "Mật khẩu ?");
            }
            else
            {
                SGMHelper.ShowToolTip(txtPwd, "");
            }

            if (txtPwdRepeat.Text == string.Empty)
            {
                check = false;
                SGMHelper.ShowToolTip(txtPwdRepeat, "Nhập lại mật khẩu.");
            }
            else
            {
                SGMHelper.ShowToolTip(txtPwdRepeat, "");
            }

            if (txtPwd.Text != txtPwdRepeat.Text)
            {
                check = false;
                SGMHelper.ShowToolTip(txtPwdRepeat, "Mật khẩu không khớp.");
            }
            else
            {
                SGMHelper.ShowToolTip(txtPwdRepeat, "");
            }

            return(check);
        }
Beispiel #7
0
        private void calculatePay()
        {
            //EnableTransaction(true, false);
            SGMHelper.Clear();
            btnBuy.Enabled = true;
            try
            {
                if (m_iCurrentPrice > 0)
                {
                    _moneyBuying = Int32.Parse(txtMoney.Text, System.Globalization.NumberStyles.Currency);
                    float _totalBuying = (float)_moneyBuying / m_iCurrentPrice;
                    if (_totalBuying <= m_iCurrentTotal)
                    {
                        float _moneyRealBuying = _totalBuying * m_iApplyPrice;
                        float moneyAfter       = _cardDTO.CardRemainingMoney - _moneyRealBuying;
                        if (moneyAfter >= 0)
                        {
                            txtMoneyBefore.Text = _cardDTO.CardRemainingMoney.ToString(MONEY_FORMAT);
                            txtGasBuying.Text   = Math.Round(_totalBuying, 1).ToString();
                            txtMoneyAfter.Text  = moneyAfter.ToString(MONEY_FORMAT);

                            txtMoneySaving.Text = (m_iSavingMoney * _totalBuying).ToString(MONEY_FORMAT);
                            txtMoneyBuying.Text = _moneyRealBuying.ToString(MONEY_FORMAT);
                        }
                        else
                        {
                            SGMHelper.ShowToolTip(txtMoney, SGMText.GAS_BUYING_INPUT_MONEY_FAIL);
                            btnBuy.Enabled = false;
                        }
                    }
                    else
                    {
                        SGMHelper.ShowToolTip(txtMoney, SGMText.GAS_BUYING_INPUT_TOTAL_GAS_FAIL);
                        btnBuy.Enabled = false;
                    }
                }
            }
            catch (Exception)
            {
                txtMoneyBefore.Text = "";
                txtGasBuying.Text   = "";
                txtMoneyAfter.Text  = "";
                txtMoneyBuying.Text = "";
                txtMoneySaving.Text = "";
            }
        }
Beispiel #8
0
        private bool ValidateLoginCode()
        {
            bool check = true;

            if (string.IsNullOrEmpty(txtLoginCode.Text))
            {
                SGMHelper.ShowToolTip(txtLoginCode, SGMText.SALEGAS_LOGIN_INPUT_ERROR);
                check = false;
            }
            //else if (!Regex.IsMatch(txtLoginCode.Text, @"[A-Za-z][A-Za-z0-9]{2,7}"))
            //{
            //    SGMHelper.ShowToolTip(txtLoginCode, "Invalid format!");
            //}
            else
            {
                SGMHelper.ShowToolTip(txtLoginCode, "");
            }
            return(check);
        }
Beispiel #9
0
        private bool ValidateDataInput()
        {
            bool bValidate = true;

            SGMHelper.ShowToolTip(txtCardID, "");
            SGMHelper.ShowToolTip(txtCardMoney, "");
            SGMHelper.ShowToolTip(txtExMoney, "");
            SGMHelper.ShowToolTip(dtpRechargeDate, "");

            if (txtCardID.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCardID, SGMText.CARD_DATA_INPUT_CARD_ID_ERR);
                bValidate = false;
            }
            else if (!m_bRecharge)
            {
                Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMManager_CheckCardExist(txtCardID.Text.Trim()));
                });
                SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
                {
                    String stResponse     = task.Result as String;
                    DataTransfer response = JSonHelper.ConvertJSonToObject(stResponse);
                    if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
                    {
                        if (response.ResponseDataBool)
                        {
                            SGMHelper.ShowToolTip(txtCardID, SGMText.CARD_DATA_INPUT_EXIST_CARD_ID_ERR);
                            bValidate = false;
                        }
                    }
                    else
                    {
                        SGMHelper.ShowToolTip(txtCardID, SGMText.CARD_GET_CARD_ERR);
                        frmMsg.ShowMsg(SGMText.SGM_ERROR, SGMText.CARD_GET_CARD_ERR + "\n" + response.ResponseErrorMsg + ":\n" + response.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                        bValidate = false;
                    }
                }, SynchronizationContext.Current);
            }
            if (txtCardMoney.Text.Trim().Equals(""))
            {
                SGMHelper.ShowToolTip(txtCardMoney, SGMText.CARD_DATA_INPUT_CARD_MONEY_ERR);
                bValidate = false;
            }
            //else if (txtRechargeMoney.Text.Trim().Equals(""))
            //{
            //    SGMHelper.ShowToolTip(txtRechargeMoney, SGMText.CARD_DATA_INPUT_CARD_PRICE_ERR);
            //    bValidate = false;
            //}
            //else if (Int32.Parse(txtCardMoney.Text.Trim()) < Int32.Parse(txtExMoney.Text.Trim()))
            //{
            //    SGMHelper.ShowToolTip(txtExMoney, SGMText.CARD_DATA_INPUT_CARD_MONEY_PRICE_ERR);
            //    bValidate = false;
            //}
            //if (!m_bStateUpdate)
            {
                if (dtpRechargeDate.Value.Date < DateTime.Now.Date)
                {
                    SGMHelper.ShowToolTip(dtpRechargeDate, SGMText.CARD_DATA_INPUT_DATE_ERR);
                    bValidate = false;
                }
            }

            return(bValidate);
        }