Пример #1
0
 private void frmSGMConfig_Load(object sender, EventArgs e)
 {
     if (SGMConfig.Flag_DisableReader)
     {
         openLoginFrm();
     }
     m_stSettingFile     = Application.StartupPath + m_stSettingFile;
     m_stCurrentPortName = RFIDReader.LoadConfig(m_stSettingFile);
     loadPortsName();
     if (!m_stCurrentPortName.Equals(""))
     {
         for (int i = 0; i < cboPorts.Items.Count; i++)
         {
             if (cboPorts.Items[i].ToString().Equals(m_stCurrentPortName))
             {
                 if (InitComPort())
                 {
                     openLoginFrm();
                 }
                 else
                 {
                     frmMsg.ShowMsg(SGMText.SGM_ERROR, SGMText.FRM_CONFIG_CANT_CONNECT_READER, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                 }
             }
         }
     }
     m_stCurrentPortName = cboPorts.Text;
 }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // validate user input
            if (ValidateLoginCode() == false)
            {
                return;
            }

            // request server
            string        GASSTATION_ID         = txtLoginCode.Text;
            string        GASSTATION_MACADDRESS = GetMacAddress();
            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () => {
                return(service.SGMSaleGas_ValidateGasStationLogin(GASSTATION_ID, GASSTATION_MACADDRESS));
            });

            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)
                {
                    this.Hide();
                    if (Program.ReaderPort != null)
                    {
                        Program.ReaderPort.DataReceived -= serialDatahandler;
                    }

                    new frmSGMSaleGas(dataResponse.ResponseDataSystemAdminDTO, dataResponse.ResponseDataGasStationDTO, dataResponse.ResponseCurrentPriceGas92, dataResponse.ResponseCurrentPriceGas95, dataResponse.ResponseCurrentPriceGasDO, dataResponse.ResponseGasStoreGas92Total, dataResponse.ResponseGasStoreGas95Total, dataResponse.ResponseGasStoreGasDOTotal).ShowDialog();
                    this.Close();
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }
Пример #3
0
        private void ScanCard(string cardId)
        {
            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () => {
                return(service.SGMSaleGas_ValidateCardId(cardId));
            });

            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)
                {
                    EnableTransaction(true, true);

                    using (DataSet ds = dataResponse.ResponseDataSet)
                    {
                        DataTable tblCard = ds.Tables[0];
                        if (tblCard.Rows.Count == 1)
                        {
                            clearForm();
                            _cardDTO     = new CardDTO();
                            _rechargeDTO = new RechargeDTO();

                            foreach (DataRow dr in tblCard.Rows)
                            {
                                _cardDTO.CardID             = dr["CARD_ID"].ToString();;
                                _cardDTO.CardUnlockState    = Boolean.Parse(dr["CARD_STATE"].ToString());
                                _cardDTO.CardRemainingMoney = Int32.Parse(dr["CARD_MONEY"].ToString());
                                _cardDTO.CardBuyDate        = DateTime.Parse(dr["CARD_BUY_DATE"].ToString());
                                _cardDTO.RechargeID         = Int32.Parse(dr["RECHARGE_ID"].ToString());
                                _cardDTO.CardMoneyEx        = Int32.Parse(dr["CARD_MONEY_EX"].ToString());
                                _cardDTO.CustomerID         = dr["CUS_ID"].ToString();

                                _rechargeDTO.RechargeID         = Int32.Parse(dr["RECHARGE_ID"].ToString());
                                _rechargeDTO.RechargeDate       = DateTime.Parse(dr["RECHARGE_DATE"].ToString());
                                _rechargeDTO.RechargeGas92Price = Int32.Parse(dr["RECHARGE_GAS92_PRICE"].ToString());
                                _rechargeDTO.RechargeGas95Price = Int32.Parse(dr["RECHARGE_GAS95_PRICE"].ToString());
                                _rechargeDTO.RechargeGasDOPrice = Int32.Parse(dr["RECHARGE_GASDO_PRICE"].ToString());
                                _rechargeDTO.RechargeMoney      = Int32.Parse(dr["RECHARGE_MONEY"].ToString());
                                _rechargeDTO.RechargeNote       = dr["RECHARGE_MONEY"].ToString();
                                _rechargeDTO.CardID             = dr["CARD_ID"].ToString();
                                txtCardName.Text = dr["CUS_NAME"].ToString();
                            }

                            //txtCardID.Text = _cardDTO.CardID;
                            txtCardMoney.Text = _cardDTO.CardRemainingMoney.ToString(MONEY_FORMAT);
                            // get name customer
                            updateGasChoice(rbGas92.Checked ? gasTransactType.gas92 : rbGas95.Checked?gasTransactType.gas95: gasTransactType.gasDO);
                            if (_cardDTO.CardUnlockState == false)
                            {
                                frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.GAS_CARD_LOCK, SGMMessageType.SGM_MESSAGE_TYPE_INFO);
                                //_cardDTO = null;
                                //_rechargeDTO = null;
                                EnableTransaction(false, true);
                            }
                            grBill.Text           = SGMText.SALEGAS_MAIN_BILL;
                            btnCardDetail.Enabled = true;
                            m_bBuy = false;

                            txtMoney.Focus();
                            m_iTimeOutReset = 0;
                        }
                        else
                        {
                            // >>>
                        }
                    }
                }
                else
                {
                    resetForm();
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                    EnableTransaction(false, true);
                }
            }, SynchronizationContext.Current);
        }