Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            string        SYS_ADMIN = txtAdmin.Text;
            string        SYS_PWD   = txtPwd.Text;
            Task <String> task      = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () =>
            {
                return(service.SGMManager_UpdateAdminAccount(frmGSMMain.s_currentAdminDTO.SysAdminAccount, SYS_ADMIN, SYS_PWD));
            });

            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)
                {
                    frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.SYS_ADMIN_CHANGE_SUCCESS, SGMMessageType.SGM_MESSAGE_TYPE_INFO);
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }
Example #2
0
        private void Login()
        {
            if (ValidateLoginCode() == false)
            {
                return;
            }

            // request server
            string        SYS_ADMIN = txtAdmin.Text;
            string        SYS_PWD   = txtPwd.Text;
            Task <String> task      = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () => {
                return(service.SGMManager_ValidateAdminLogin(SYS_ADMIN, SYS_PWD));
            });

            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();
                    frmGSMMain.s_currentAdminDTO = dataResponse.ResponseDataSystemAdminDTO;
                    frmGSMMain a = new frmGSMMain();
                    a.ShowDialog();
                    this.Close();
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }
Example #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!ValidateDataInput())
            {
                return;
            }
            frmGSMMain.s_currentAdminDTO.SysApplyDate         = dtpNew.Value;
            frmGSMMain.s_currentAdminDTO.SysGas92CurrentPrice = frmGSMMain.s_currentAdminDTO.SysGas92NewPrice = Int32.Parse(txtGas92NewPrice.Text);
            frmGSMMain.s_currentAdminDTO.SysGas95CurrentPrice = frmGSMMain.s_currentAdminDTO.SysGas95NewPrice = Int32.Parse(txtGas95NewPrice.Text);
            frmGSMMain.s_currentAdminDTO.SysGasDOCurrentPrice = frmGSMMain.s_currentAdminDTO.SysGasDONewPrice = Int32.Parse(txtGasDONewPrice.Text);

            DataTransfer request = new DataTransfer();

            request.ResponseDataSystemAdminDTO = frmGSMMain.s_currentAdminDTO;
            String jsRequest = JSonHelper.ConvertObjectToJSon(request);

            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () =>
            {
                return(m_service.SGMManager_UpdateSystemPrice(jsRequest));
            });

            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)
                {
                    frmMSg.ShowMsg(SGMText.SGM_INFO, SGMText.ADMIN_UPDATE_PRICE_SUCCESS, SGMMessageType.SGM_MESSAGE_TYPE_INFO);
                    DataToUIView();
                }
                else
                {
                    frmMSg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                    frmGSMMain.s_currentAdminDTO.SysGas92CurrentPrice = int.Parse(txtGas92CurrentPrice.Text);
                    frmGSMMain.s_currentAdminDTO.SysGas95CurrentPrice = int.Parse(txtGas95CurrentPrice.Text);
                    frmGSMMain.s_currentAdminDTO.SysGasDOCurrentPrice = int.Parse(txtGasDOCurrentPrice.Text);
                }
            }, SynchronizationContext.Current);
        }
Example #4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (btnAdd.Text.Equals("&Thêm"))
     {
         btnAdd.Text = "&Lưu";
         UpdateStateControls(true);
         clearInput();
         txtCusID.Focus();
     }
     else
     {
         if (!ValidateDataInput())
         {
             return;
         }
         CustomerDTO cus = new CustomerDTO();
         cus.CustomerID        = txtCusID.Text.Trim();
         cus.CustomerName      = txtCusName.Text.Trim();
         cus.CustomerPhone     = txtCusPhone.Text.Trim();
         cus.CustomerBirthDate = txtCusBirthday.Text.Trim();
         cus.CustomerVisa      = txtCusVisa.Text.Trim();
         cus.CustomerAddress   = txtCusAddress.Text.Trim();
         cus.CustomerNote      = txtCusAddress.Text.Trim();
         DataTransfer request = new DataTransfer();
         request.ResponseDataCustomerDTO = cus;
         string        jsRequest = JSonHelper.ConvertObjectToJSon(request);
         Task <String> task      = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
             () =>
         {
             return(m_service.SGMManager_AddNewCustomer(jsRequest));
         });
         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)
             {
                 frmMSg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg + "\n" + dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                 return;
             }
             LoadCustomerList();
             SelectCustomeRow(cus.CustomerID);
             UpdateStateControls(false);
             btnAdd.Text = "&Thêm";
         }, SynchronizationContext.Current);
     }
 }
Example #5
0
 private void frmSGMConfig_Load(object sender, EventArgs e)
 {
     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())
                 {
                     IsReaderConnected = true;
                 }
                 else
                 {
                     frmMsg.ShowMsg(SGMText.SGM_ERROR, SGMText.FRM_CONFIG_CANT_CONNECT_READER, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                 }
             }
         }
     }
     m_stCurrentPortName = cboPorts.Text;
 }
Example #6
0
        private bool ValidateDataInput()
        {
            bool bValidate = true;

            errProvider.Clear();
            if (txtGSCode.Text.Trim().Equals(""))
            {
                errProvider.SetError(txtGSCode, SGMText.GASSTORE_DATA_INPUT_GS_ID_ERR);
                bValidate = false;
            }
            else if (!txtGSCode.Text.Trim().Equals(m_stGSIDEdit))
            {
                Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMManager_CheckGasStoreExist(txtGSCode.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)
                        {
                            errProvider.SetError(txtGSCode, SGMText.GASSTORE_DATA_INPUT_EXIST_GS_ID_ERR);
                            bValidate = false;
                        }
                    }
                    else
                    {
                        errProvider.SetError(txtGSCode, SGMText.GASSTORE_GET_GS_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 (txtGSName.Text.Trim().Equals(""))
            {
                errProvider.SetError(txtGSName, SGMText.GASSTORE_DATA_INPUT_GS_NAME_ERR);
                bValidate = false;
            }
            if (txtGSAddress.Text.Trim().Equals(""))
            {
                errProvider.SetError(txtGSAddress, SGMText.GASSTORE_DATA_INPUT_GS_ADDRESS_ERR);
                bValidate = false;
            }

            return(bValidate);
        }
Example #7
0
        private void LoadGasStoreList()
        {
            cboGasStore.Items.Clear();
            Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () =>
            {
                return(m_service.SGMManager_GetGasStoreList());
            });

            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)
                {
                    DataSet ds          = dataResponse.ResponseDataSet;
                    DataTable tblResult = ds.Tables[0];
                    if (tblResult.Rows.Count > 0)
                    {
                        //ComboboxItem itemAll = new ComboboxItem();
                        //itemAll.Text = SGMText.SGM_ALL;
                        //itemAll.Value = "";
                        //cboGasStore.Items.Add(itemAll);
                        foreach (DataRow dr in tblResult.Rows)
                        {
                            ComboboxItem item = new ComboboxItem();
                            item.Text         = dr["GASSTORE_NAME"].ToString();
                            item.Value        = dr["GASSTORE_ID"].ToString();
                            cboGasStore.Items.Add(item);
                        }
                        if (cboGasStore.Items.Count > 0)
                        {
                            cboGasStore.SelectedIndex = 0;
                        }
                    }
                }
                else
                {
                    frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                }
            }, SynchronizationContext.Current);
        }
Example #8
0
        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);
                }
            }
        }
Example #9
0
        private void btnSaleGasView_Click(object sender, EventArgs e)
        {
            if (!ValidateDataSaleGasInput())
            {
                return;
            }



            DateTime date_begin = new DateTime(dtpSaleGasBegin.Value.Year, dtpSaleGasBegin.Value.Month, dtpSaleGasBegin.Value.Day, 0, 0, 0);

            DateTime date_end     = new DateTime(dtpSaleGasEnd.Value.Date.Year, dtpSaleGasEnd.Value.Month, dtpSaleGasEnd.Value.Day, 23, 59, 59);
            String   gasStationId = (cboGasStation.SelectedItem as ComboboxItem).Value.ToString();
            {
                Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                    () =>
                {
                    return(m_service.SGMSaleGas_GetSaleGasReport(m_stGasStoreID, gasStationId, date_begin, date_end, txtSaleGasCardID.Text.Trim()));
                });

                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)
                    {
                        if (dataResponse.ResponseDataSet != null)
                        {
                            String tableName = dataResponse.ResponseDataSet.Tables[0].TableName;
                            DataTable data   = dataResponse.ResponseDataSet.Tables[0];

                            rptSaleGasReport         = new rptSGMSaleGas();
                            dsSaleGas                = new dsSGMSaleGas();
                            DataTable dtSaleGasTable = dsSaleGas.SGMSaleGas;

                            for (int i = 0; i < data.Rows.Count; i++)
                            {
                                DataRow row            = dtSaleGasTable.NewRow();
                                row["ID"]              = (i + 1);
                                row["CUSTOMER_ID"]     = data.Rows[i]["CUS_ID"];
                                row["CUSTOMER_NAME"]   = data.Rows[i]["CUS_NAME"];
                                row["BUY_LIT"]         =
                                    row["BUY_MONEY"]   = Int32.Parse(data.Rows[i]["SALEGAS_CARD_MONEY_BEFORE"].ToString()) - Int32.Parse(data.Rows[i]["SALEGAS_CARD_MONEY_AFTER"].ToString());
                                row["BUY_DATE"]        = data.Rows[i]["SALEGAS_DATE"];
                                row["GAS_SATION_NAME"] = data.Rows[i]["GASSTATION_NAME"];
                                dtSaleGasTable.Rows.Add(row);
                            }

                            rptSaleGasReport.Refresh();
                            rptSaleGasReport.SetDataSource(dsSaleGas);

                            rptSaleGasReport.SetParameterValue("DateBegin", dtpSaleGasBegin.Value);
                            rptSaleGasReport.SetParameterValue("DateEnd", dtpSaleGasEnd.Value);

                            crvSaleGas.ReportSource = rptSaleGasReport;
                        }
                        else
                        {
                            crvSaleGas.ReportSource = null;
                            frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.REPORT_NO_DATA, SGMMessageType.SGM_MESSAGE_TYPE_INFO);
                        }
                    }
                    else
                    {
                        crvSaleGas.ReportSource = null;
                        frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR);
                    }
                    HideTabs(crvSaleGas);
                }, SynchronizationContext.Current);
            }
        }