public DataTransfer() { m_iResponseCode = RESPONSE_CODE_NONE; m_stResponseErrorMsg = ""; m_stResponseErrorMsgDetail = ""; m_stResponseDataString = ""; m_bResponseDataBool = false; m_dtoResponseDataCustomerDTO = null; m_dtoResponseDataCardDTO = null; m_dtoResponseDataGasStationDTO = null; m_dtoResponseDataRechargeDTO = null; m_dtoResponseDataSaleGasDTO = null; m_dtoResponseDataSystemAdminDTO = null; m_dtoResponseDataGasStoreDTO = null; m_dtoResponseDataGasStoreUpdateDTO = null; m_dsResponseDataSet = null; m_iCurrentPriceGas92 = 0; m_iCurrentPriceGas95 = 0; m_iCurrentPriceGasDO = 0; m_fGasStoreGas92Total = 0; m_fGasStoreGas95Total = 0; m_fGasStoreGasDOTotal = 0; }
public frmSGMRechargeCard() { InitializeComponent(); m_bRecharge = false; m_bChangeCard = false; m_stCusID = ""; m_stCardID = ""; m_cardDTO = null; m_iPriceGas95 = 0; m_iPriceGas92 = 0; m_iPriceGasDO = 0; m_service = new SGM_Service.ServiceSoapClient(); frmMsg = new frmSGMMessage(); serialDatahandler = new SerialDataReceivedEventHandler(CardReaderReceivedHandler); RFIDReader.RegistryReaderListener(Program.ReaderPort, serialDatahandler); }
public DataTransfer AddNewCard(CardDTO dtoCard) { DataTransfer dataResult = new DataTransfer(); bool insertResult = true; try { string query = string.Format("INSERT INTO CARD (CARD_ID, CARD_STATE, CARD_MONEY, CARD_MONEY_EX, CARD_BUY_DATE, RECHARGE_ID, CUS_ID) VALUES (@CARD_ID, @CARD_STATE, @CARD_MONEY, @CARD_MONEY_EX, @CARD_BUY_DATE, @RECHARGE_ID, @CUS_ID)"); SqlParameter[] sqlParameters = new SqlParameter[7]; sqlParameters[0] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar); sqlParameters[0].Value = Convert.ToString(dtoCard.CardID); sqlParameters[1] = new SqlParameter("@CARD_STATE", SqlDbType.Bit); sqlParameters[1].Value = Convert.ToBoolean(dtoCard.CardUnlockState); sqlParameters[2] = new SqlParameter("@CARD_MONEY", SqlDbType.Int); sqlParameters[2].Value = Convert.ToInt32(dtoCard.CardRemainingMoney); sqlParameters[3] = new SqlParameter("@CARD_MONEY_EX", SqlDbType.Int); sqlParameters[3].Value = Convert.ToInt32(dtoCard.CardMoneyEx); sqlParameters[4] = new SqlParameter("@CARD_BUY_DATE", SqlDbType.DateTime); sqlParameters[4].Value = Convert.ToDateTime(dtoCard.CardBuyDate); sqlParameters[5] = new SqlParameter("@RECHARGE_ID", SqlDbType.Int); sqlParameters[5].Value = Convert.ToInt32(dtoCard.RechargeID); sqlParameters[6] = new SqlParameter("@CUS_ID", SqlDbType.NVarChar); sqlParameters[6].Value = Convert.ToString(dtoCard.CustomerID); insertResult = m_dbConnection.ExecuteInsertQuery(query, sqlParameters); } catch (Exception ex) { insertResult = false; dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace; } if (insertResult) { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS; } else { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL; dataResult.ResponseErrorMsg = SGMText.CARD_INSERT_ERR; } return dataResult; }
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); }
private void resetForm() { _cardDTO = null; _rechargeDTO = null; txtCardID.Text = ""; txtCardName.Text = ""; txtCardMoney.Text = 0.ToString(MONEY_FORMAT); rbGas92.Checked = true; txtMoney.Text = 0.ToString(MONEY_FORMAT); grBill.Text = SGMText.SALEGAS_MAIN_BILL; txtGasBuying.Text = 0.ToString(MONEY_FORMAT); txtGasType.Text = ""; txtPrice.Text = 0.ToString(MONEY_FORMAT); txtMoneyBefore.Text = 0.ToString(MONEY_FORMAT); txtMoneyBuying.Text = 0.ToString(MONEY_FORMAT); txtMoneyAfter.Text = 0.ToString(MONEY_FORMAT); txtMoneySaving.Text = 0.ToString(MONEY_FORMAT); }
private void frmSGMSaleGas_Load(object sender, EventArgs e) { SGM_WaitingIdicator.WaitingForm.waitingFrm.SetParentForm(this); serailReaderHandler = new SerialDataReceivedEventHandler(CardReaderReceivedHandler); RFIDReader.RegistryReaderListener(Program.ReaderPort, serailReaderHandler); _cardDTO = null; _rechargeDTO = null; txtMoney.Text = _moneyBuying.ToString(MONEY_FORMAT); lblTitle.Text = _gasStationDTO.GasStationName; resetForm(); lblCurrentPrice.Text = SGMText.SALEGAS_CURRENT_PRICE + SGMText.GAS_92_TEXT + " : " + m_iCurrentPriceGas92 + " - " + SGMText.GAS_95_TEXT + " : " + m_iCurrentPriceGas95 + " - " + SGMText.GAS_DO_TEXT + " : " + m_iCurrentPriceGasDO; EnableTransaction(false, true); }
public frmSGMCardDetail(CardDTO cardDTO, RechargeDTO rechargeDTO) { InitializeComponent(); m_dtoCard = cardDTO; m_dtoRecharge = rechargeDTO; }
private void btnUpdateCard_Click(object sender, EventArgs e) { if (ValidateDataInput()) { DataTransfer response = null; DataTransfer request = new DataTransfer(); Task<String> task; if (m_bRecharge) { RechargeDTO dtoRecharge = new RechargeDTO(); dtoRecharge.RechargeDate = dtpRechargeDate.Value; dtoRecharge.RechargeGas92Price = m_iPriceGas92; dtoRecharge.RechargeGas95Price = m_iPriceGas95; dtoRecharge.RechargeGasDOPrice = m_iPriceGasDO; dtoRecharge.RechargeMoney = Int32.Parse(txtCardMoney.Text.Trim()); dtoRecharge.RechargeMoneyEx = Int32.Parse(txtExMoney.Text.Trim()); dtoRecharge.RechargeNote = txtRechargeNote.Text.Trim(); dtoRecharge.CardID = txtCardID.Text.Trim(); request.ResponseDataRechargeDTO = dtoRecharge; task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_AddRechargeCard(JSonHelper.ConvertObjectToJSon(request)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { String stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_UpdateRechargeIDForCard(txtCardID.Text.Trim()); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_UpdateMoneyForCard(txtCardID.Text.Trim(), m_iCurrentCardMoney + Int32.Parse(txtCardMoney.Text.Trim()) + Int32.Parse(txtExMoney.Text.Trim())); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { this.Close(); } }, SynchronizationContext.Current); } }, SynchronizationContext.Current); } }, SynchronizationContext.Current); } else { CardDTO dtoCard = new CardDTO(); dtoCard.CardID = txtCardID.Text.Trim(); dtoCard.CardUnlockState = true; dtoCard.CardRemainingMoney = Int32.Parse(txtCardMoney.Text.Trim()); dtoCard.CardMoneyEx = 0; dtoCard.CardBuyDate = dtpRechargeDate.Value; dtoCard.RechargeID = -1; dtoCard.CustomerID = m_stCusID; request.ResponseDataCardDTO = dtoCard; task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_AddNewCard(JSonHelper.ConvertObjectToJSon(request)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { String stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { RechargeDTO dtoRecharge = new RechargeDTO(); dtoRecharge.RechargeDate = dtpRechargeDate.Value; dtoRecharge.RechargeGas92Price = m_iPriceGas92; dtoRecharge.RechargeGas95Price = m_iPriceGas95; dtoRecharge.RechargeGasDOPrice = m_iPriceGasDO; dtoRecharge.RechargeMoney = Int32.Parse(txtCardMoney.Text.Trim()); dtoRecharge.RechargeNote = txtRechargeNote.Text.Trim(); dtoRecharge.CardID = txtCardID.Text.Trim(); request.ResponseDataRechargeDTO = dtoRecharge; task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { if (m_bChangeCard) return m_service.SGMManager_ChangeCard(m_stCardID, JSonHelper.ConvertObjectToJSon(request)); else return m_service.SGMManager_AddRechargeCard(JSonHelper.ConvertObjectToJSon(request)); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_UpdateRechargeIDForCard(txtCardID.Text.Trim()); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { stResponse = task.Result as String; response = JSonHelper.ConvertJSonToObject(stResponse); if (response.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { this.Close(); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, response.ResponseErrorMsg + " : " + response.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); } }, SynchronizationContext.Current); } }, SynchronizationContext.Current); } } }
private DataTransfer GasBuyingUpdateCard(string strCardId, int money, int moneyEx) { CardDAL dalCard = new CardDAL(); CardDTO dtoCard = new CardDTO(); dtoCard.CardID = strCardId; dtoCard.CardRemainingMoney = money; dtoCard.CardMoneyEx = moneyEx; return dalCard.UpdateSaleGas(dtoCard); }
public CardDTO GetCard(string stCardID) { CardDTO dtoCard = null; string query = string.Format("SELECT * FROM CARD WHERE CARD_ID = @CARD_ID"); SqlParameter[] sqlParameters = new SqlParameter[1]; sqlParameters[0] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar); sqlParameters[0].Value = Convert.ToString(stCardID); DataTable tblResult = m_dbConnection.ExecuteSelectQuery(query, sqlParameters); if (tblResult.Rows.Count > 0) { dtoCard = new CardDTO(); foreach (DataRow dr in tblResult.Rows) { dtoCard.CardID = dr["CARD_ID"].ToString(); ; dtoCard.CardUnlockState = Boolean.Parse(dr["CARD_STATE"].ToString()); dtoCard.CardRemainingMoney = Int32.Parse(dr["CARD_MONEY"].ToString()); dtoCard.CardMoneyEx = Int32.Parse(dr["CARD_MONEY_EX"].ToString()); dtoCard.CardBuyDate = DateTime.Parse(dr["CARD_BUY_DATE"].ToString()); dtoCard.RechargeID = Int32.Parse(dr["RECHARGE_ID"].ToString()); dtoCard.CustomerID = dr["CUS_ID"].ToString(); } } return dtoCard; }
public DataTransfer UpdateSaleGas(CardDTO dtoCard) { DataTransfer dataResult = new DataTransfer(); bool result = true; try { string query = string.Format("UPDATE CARD SET CARD_MONEY = @CARD_MONEY, CARD_MONEY_EX = CARD_MONEY_EX + @CARD_MONEY_EX WHERE CARD_ID = @CARD_ID"); SqlParameter[] sqlParameters = new SqlParameter[3]; sqlParameters[0] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar); sqlParameters[0].Value = Convert.ToString(dtoCard.CardID); sqlParameters[1] = new SqlParameter("@CARD_MONEY", SqlDbType.Int); sqlParameters[1].Value = Convert.ToInt32(dtoCard.CardRemainingMoney); sqlParameters[2] = new SqlParameter("@CARD_MONEY_EX", SqlDbType.Int); sqlParameters[2].Value = Convert.ToInt32(dtoCard.CardMoneyEx); result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters); } catch (Exception ex) { result = false; dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace; } if (result) { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS; } else { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL; dataResult.ResponseErrorMsg = 2 + SGMText.CARD_INSERT_ERR; } return dataResult; }
public bool UpdateCard(CardDTO dtoCard) { bool result = true; string query = string.Format("UPDATE CARD SET CARD_STATE = @CARD_STATE, CARD_MONEY = @CARD_MONEY, CARD_MONEY_EX = @CARD_MONEY_EX, CARD_BUY_DATE = @CARD_BUY_DATE, RECHARGE_ID = @RECHARGE_ID WHERE CARD_ID = @CARD_ID"); SqlParameter[] sqlParameters = new SqlParameter[6]; sqlParameters[0] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar); sqlParameters[0].Value = Convert.ToString(dtoCard.CardID); sqlParameters[1] = new SqlParameter("@CARD_STATE", SqlDbType.Bit); sqlParameters[1].Value = Convert.ToBoolean(dtoCard.CardUnlockState); sqlParameters[2] = new SqlParameter("@CARD_MONEY", SqlDbType.Int); sqlParameters[2].Value = Convert.ToInt32(dtoCard.CardRemainingMoney); sqlParameters[3] = new SqlParameter("@CARD_MONEY_EX", SqlDbType.Int); sqlParameters[3].Value = Convert.ToInt32(dtoCard.CardMoneyEx); sqlParameters[4] = new SqlParameter("@CARD_BUY_DATE", SqlDbType.Int); sqlParameters[4].Value = Convert.ToDateTime(dtoCard.CardBuyDate); sqlParameters[5] = new SqlParameter("@RECHARGE_ID", SqlDbType.Int); sqlParameters[5].Value = Convert.ToInt32(dtoCard.RechargeID); result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters); return result; }