Exemplo n.º 1
0
        public DataTransfer DeleteCustomer(string stCustomerID)
        {
            bool delResult = true;
            DataTransfer dataResult = new DataTransfer();
            try
            {
                string query = string.Format("DELETE FROM CUSTOMER WHERE CUS_ID = @CUS_ID");
                SqlParameter[] sqlParameters = new SqlParameter[1];
                sqlParameters[0] = new SqlParameter("@CUS_ID", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(stCustomerID);
                delResult = m_dbConnection.ExecuteDeleteQuery(query, sqlParameters);
            }
            catch (Exception ex)
            {
                delResult = false;
                dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace;
            }
            if (delResult)
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
            }
            else
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                dataResult.ResponseErrorMsg = SGMText.CUSTOMER_DEL_CUS_ERR;
            }

            return dataResult;
        }
Exemplo n.º 2
0
 public string GetGasStore(string stGasStoreID)
 {
     if (stGasStoreID == null)
         m_dataResponse = m_dalGasStore.GetGasStores();
     else
         m_dataResponse = m_dalGasStore.GetGasStore(stGasStoreID);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 3
0
 public CardService()
 {
     m_dalCard = new CardDAL();
     m_dalRecharge = new RechargeDAL();
     m_dalSaleGas = new SaleGasDAL();
     m_dataRequest = null;
     m_dataResponse = null;
 }
Exemplo n.º 4
0
 public string GetCustomer(string stCustomerID, bool bExactly)
 {
     if (bExactly)
         m_dataResponse = m_dalCustomer.GetCustomer(stCustomerID);
     else
         m_dataResponse = m_dalCustomer.GetCustomers(stCustomerID);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 5
0
 public static string ConvertObjectToJSon(DataTransfer obj)
 {
     DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DataTransfer));
     MemoryStream ms = new MemoryStream();
     ser.WriteObject(ms, obj);
     string jsonString = Encoding.UTF8.GetString(ms.ToArray());
     ms.Close();
     return jsonString;
 }
Exemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text.Equals("&Thêm"))
            {

                btnAdd.Text = "&Lưu";
                UpdateStateControls(true);
                clearInput();
                txtGSCode.Focus();
            }
            else
            {
                if (!ValidateDataInput())
                {
                    return;
                }
                GasStoreDTO gas = new GasStoreDTO();
                gas.GasStoreID = txtGSCode.Text.Trim();
                gas.GasStoreName = txtGSName.Text.Trim();
                gas.GasStoreAddress = txtGSAddress.Text.Trim();
                gas.GasStoreDescription = txtGSDes.Text.Trim();
                gas.GasStoreGas92Total = 0;
                gas.GasStoreGas95Total = 0;
                gas.GasStoreGasDOTotal = 0;

                DataTransfer request = new DataTransfer();
                request.ResponseDataGasStoreDTO = gas;
                string jsRequest = JSonHelper.ConvertObjectToJSon(request);
                Task<String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
                () =>
                {
                    return m_service.SGMManager_AddNewGasStore(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;
                    }
                    btnAdd.Text = "&Thêm";
                    LoadGasStoreList();
                    SelectGSRow(gas.GasStoreID);
                    UpdateStateControls(false);

                }, SynchronizationContext.Current);

            }
        }
Exemplo n.º 7
0
        public DataTransfer AddSaleGas(SaleGasDTO dtoSaleGas)
        {
            bool result = true;
            DataTransfer dataResult = new DataTransfer();
            try
            {
                string query = string.Format("INSERT INTO SALE_GAS (SALEGAS_TYPE, SALEGAS_CURRENT_PRICE, SALEGAS_CARD_PRICE, SALEGAS_CARD_MONEY_BEFORE, SALEGAS_CARD_MONEY_AFTER, SALEGAS_CARD_MONEY_SAVING, SALEGAS_LIT, SALEGAS_DATE, GASSTATION_ID, CARD_ID)" +
                                                               " VALUES (@SALEGAS_TYPE, @SALEGAS_CURRENT_PRICE, @SALEGAS_CARD_PRICE, @SALEGAS_CARD_MONEY_BEFORE, @SALEGAS_CARD_MONEY_AFTER, @SALEGAS_CARD_MONEY_SAVING, @SALEGAS_LIT, @SALEGAS_DATE, @GASSTATION_ID, @CARD_ID)");
                SqlParameter[] sqlParameters = new SqlParameter[10];
                sqlParameters[0] = new SqlParameter("@SALEGAS_TYPE", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(dtoSaleGas.SaleGasType);
                sqlParameters[1] = new SqlParameter("@SALEGAS_CURRENT_PRICE", SqlDbType.Int);
                sqlParameters[1].Value = Convert.ToInt32(dtoSaleGas.SaleGasCurrentPrice);
                sqlParameters[2] = new SqlParameter("@SALEGAS_CARD_PRICE", SqlDbType.Int);
                sqlParameters[2].Value = Convert.ToInt32(dtoSaleGas.SaleGasPriceOnCard);
                sqlParameters[3] = new SqlParameter("@SALEGAS_CARD_MONEY_BEFORE", SqlDbType.Int);
                sqlParameters[3].Value = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneyBefore);
                sqlParameters[4] = new SqlParameter("@SALEGAS_CARD_MONEY_AFTER", SqlDbType.Int);
                sqlParameters[4].Value = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneyAfter);
                sqlParameters[5] = new SqlParameter("@SALEGAS_LIT", SqlDbType.Float);
                sqlParameters[5].Value = Convert.ToDouble(dtoSaleGas.NumberBuyLit);
                sqlParameters[6] = new SqlParameter("@SALEGAS_DATE", SqlDbType.DateTime);
                sqlParameters[6].Value = (dtoSaleGas.SaleGasDate);
                sqlParameters[7] = new SqlParameter("@GASSTATION_ID", SqlDbType.NVarChar);
                sqlParameters[7].Value = Convert.ToString(dtoSaleGas.GasStationID);
                sqlParameters[8] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar);
                sqlParameters[8].Value = Convert.ToString(dtoSaleGas.CardID);

                sqlParameters[9] = new SqlParameter("@SALEGAS_CARD_MONEY_SAVING", SqlDbType.Int);
                sqlParameters[9].Value = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneySaving);

                result = m_dbConnection.ExecuteInsertQuery(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 = 1 + SGMText.CARD_INSERT_ERR;
            }
            return dataResult;
        }
Exemplo n.º 8
0
 public string GetGasStation(string stGasStationID, string stGasStoreID)
 {
     if (stGasStoreID == null)
     {
         if (stGasStationID == null)
             m_dataResponse = m_dalGasStation.GetGasStations();
         else
             m_dataResponse = m_dalGasStation.GetGasStation(stGasStationID);
     }
     else
     {
         m_dataResponse = m_dalGasStation.GetGasStationsOfStore(stGasStoreID);
     }
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 9
0
        public DataTransfer AddNewGasStoreUpdate(GasStoreUpdateDTO dtoGasStoreUpdate)
        {
            DataTransfer dataResult = new DataTransfer();
            bool insertResult = true;
            try
            {

                string query = string.Format("INSERT INTO GAS_STORE_UPDATE (GS_GAS92_TOTAL, GS_GAS95_TOTAL, GS_GASDO_TOTAL, GS_GAS92_ADD, GS_GAS95_ADD, GS_GASDO_ADD, GS_UPDATE_DATE, GS_DESCRIPTION, GASSTORE_ID) VALUES (@GS_GAS92_TOTAL, @GS_GAS95_TOTAL, @GS_GASDO_TOTAL, @GS_GAS92_ADD, @GS_GAS95_ADD, @GS_GASDO_ADD, @GS_UPDATE_DATE, @GS_DESCRIPTION, @GASSTORE_ID)");
                SqlParameter[] sqlParameters = new SqlParameter[9];
                sqlParameters[0] = new SqlParameter("@GS_GAS92_TOTAL", SqlDbType.Float);
                sqlParameters[0].Value = dtoGasStoreUpdate.GSUpdateGas92Total;
                sqlParameters[1] = new SqlParameter("@GS_GAS95_TOTAL", SqlDbType.Float);
                sqlParameters[1].Value = dtoGasStoreUpdate.GSUpdateGas95Total;
                sqlParameters[2] = new SqlParameter("@GS_GASDO_TOTAL", SqlDbType.Float);
                sqlParameters[2].Value = dtoGasStoreUpdate.GSUpdateGasDOTotal;
                sqlParameters[3] = new SqlParameter("@GS_GAS92_ADD", SqlDbType.NVarChar);
                sqlParameters[3].Value = dtoGasStoreUpdate.GSUpdateGas92Add;
                sqlParameters[4] = new SqlParameter("@GS_GAS95_ADD", SqlDbType.Float);
                sqlParameters[4].Value = dtoGasStoreUpdate.GSUpdateGas95Add;
                sqlParameters[5] = new SqlParameter("@GS_GASDO_ADD", SqlDbType.Float);
                sqlParameters[5].Value = dtoGasStoreUpdate.GSUpdateGasDOAdd;
                sqlParameters[6] = new SqlParameter("@GS_UPDATE_DATE", SqlDbType.DateTime);
                sqlParameters[6].Value = Convert.ToDateTime(dtoGasStoreUpdate.GSUpdateDate);
                sqlParameters[7] = new SqlParameter("@GS_DESCRIPTION", SqlDbType.NVarChar);
                sqlParameters[7].Value = Convert.ToString(dtoGasStoreUpdate.GSUpdateDescription);
                sqlParameters[8] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[8].Value = Convert.ToString(dtoGasStoreUpdate.GasStoreID);

                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.GASSTORE_ADD_NEW_GSUPDATE_ERR;
            }
            return dataResult;
        }
Exemplo n.º 10
0
        public string GetGasStationList(string stGasStoreID)
        {
            GasStationDAL dalGasStation = new GasStationDAL();
            DataTransfer response = new DataTransfer();
            DataSet ds = dalGasStation.GetGasStationList(stGasStoreID);
            if (ds != null)
            {
                response.ResponseDataSet = ds;
                response.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
            }
            else
            {
                response.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
            }

            return JSonHelper.ConvertObjectToJSon(response);
        }
Exemplo n.º 11
0
 public string UpdateAdminAccount(string admin, string admin_new, string pwd)
 {
     SystemAdminDAL dalSysAdmin = new SystemAdminDAL();
     DataTransfer response = new DataTransfer();
     bool res = dalSysAdmin.UpdateAdminAccount(admin, admin_new, pwd);
     if (res == true)
     {
         response.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
         response.ResponseErrorMsg = SGMText.SYS_ADMIN_CHANGE_SUCCESS;
     }
     else
     {
         response.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
         response.ResponseErrorMsg = SGMText.SYS_ADMIN_CHANGE_FAIL;
     }
     return JSonHelper.ConvertObjectToJSon(response);
 }
Exemplo n.º 12
0
 public string ValidateAdminLogin(string admin, string pwd)
 {
     SystemAdminDAL dalSysAdmin = new SystemAdminDAL();
     DataTransfer response = new DataTransfer();
     SystemAdminDTO dto = dalSysAdmin.GetSystemAdminInfo(admin, pwd);
     if (dto != null)
     {
         response.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
         response.ResponseDataSystemAdminDTO = dto;
     }
     else
     {
         response.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
         response.ResponseErrorMsg = SGMText.ADMIN_LOGON_ERROR;
     }
     return JSonHelper.ConvertObjectToJSon(response);
 }
Exemplo n.º 13
0
        public DataTransfer AddRecharge(RechargeDTO dtoRecharge)
        {
            DataTransfer dataResult = new DataTransfer();
            bool insertResult = true;
            try
            {
                string query = string.Format("INSERT INTO RECHARGE (RECHARGE_DATE, RECHARGE_GAS92_PRICE, RECHARGE_GAS95_PRICE, RECHARGE_GASDO_PRICE, RECHARGE_MONEY, RECHARGE_MONEY_EX, RECHARGE_NOTE, CARD_ID)" +
                                                           " VALUES (@RECHARGE_DATE, @RECHARGE_GAS92_PRICE, @RECHARGE_GAS95_PRICE, @RECHARGE_GASDO_PRICE, @RECHARGE_MONEY, @RECHARGE_MONEY_EX, @RECHARGE_NOTE, @CARD_ID)");

                SqlParameter[] sqlParameters = new SqlParameter[8];
                sqlParameters[0] = new SqlParameter("@RECHARGE_DATE", SqlDbType.DateTime);
                sqlParameters[0].Value = Convert.ToDateTime(dtoRecharge.RechargeDate);
                sqlParameters[1] = new SqlParameter("@RECHARGE_GAS92_PRICE", SqlDbType.Int);
                sqlParameters[1].Value = Convert.ToInt32(dtoRecharge.RechargeGas92Price);
                sqlParameters[2] = new SqlParameter("@RECHARGE_GAS95_PRICE", SqlDbType.Int);
                sqlParameters[2].Value = Convert.ToInt32(dtoRecharge.RechargeGas95Price);
                sqlParameters[3] = new SqlParameter("@RECHARGE_GASDO_PRICE", SqlDbType.Int);
                sqlParameters[3].Value = Convert.ToInt32(dtoRecharge.RechargeGasDOPrice);
                sqlParameters[4] = new SqlParameter("@RECHARGE_MONEY", SqlDbType.Int);
                sqlParameters[4].Value = Convert.ToInt32(dtoRecharge.RechargeMoney);
                sqlParameters[5] = new SqlParameter("@RECHARGE_MONEY_EX", SqlDbType.Int);
                sqlParameters[5].Value = Convert.ToInt32(dtoRecharge.RechargeMoneyEx);
                sqlParameters[6] = new SqlParameter("@RECHARGE_NOTE", SqlDbType.NVarChar);
                sqlParameters[6].Value = Convert.ToString(dtoRecharge.RechargeNote);
                sqlParameters[7] = new SqlParameter("@CARD_ID", SqlDbType.NVarChar);
                sqlParameters[7].Value = Convert.ToString(dtoRecharge.CardID);

                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_RECHARGE_INSERT_ERR;
            }
            return dataResult;
        }
Exemplo n.º 14
0
        public string ChangeCard(string oldCardID, string jsRechargeDTO)
        {
            m_dataRequest = JSonHelper.ConvertJSonToObject(jsRechargeDTO);
            m_dataResponse = m_dalRecharge.AddRecharge(m_dataRequest.ResponseDataRechargeDTO);
            if (m_dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS)
            {
                DataTransfer dataResponseUpdateCard = m_dalCard.UpdateMoneyForCard(oldCardID, 0);

                if (dataResponseUpdateCard.ResponseCode == DataTransfer.RESPONSE_CODE_FAIL)
                {
                    m_dataResponse.ResponseCode = dataResponseUpdateCard.ResponseCode;
                    m_dataResponse.ResponseErrorMsg = dataResponseUpdateCard.ResponseErrorMsg;
                    m_dataResponse.ResponseErrorMsgDetail = dataResponseUpdateCard.ResponseErrorMsgDetail;
                    //rollback here
                }
            }
            return JSonHelper.ConvertObjectToJSon(m_dataResponse);
        }
Exemplo n.º 15
0
        public DataTransfer AddNewCustomer(CustomerDTO dtoCustomer)
        {
            DataTransfer dataResult = new DataTransfer();
            bool insertResult = true;
            try
            {

                string query = string.Format("INSERT INTO CUSTOMER (CUS_ID, CUS_NAME, CUS_VISA, CUS_BIRTHDATE, CUS_ADDRESS, CUS_PHONE, CUS_NOTE) VALUES (@CUS_ID, @CUS_NAME, @CUS_VISA, @CUS_BIRTHDATE, @CUS_ADDRESS, @CUS_PHONE, @CUS_NOTE)");
                SqlParameter[] sqlParameters = new SqlParameter[7];
                sqlParameters[0] = new SqlParameter("@CUS_ID", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(dtoCustomer.CustomerID);
                sqlParameters[1] = new SqlParameter("@CUS_NAME", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(dtoCustomer.CustomerName);
                sqlParameters[2] = new SqlParameter("@CUS_VISA", SqlDbType.NVarChar);
                sqlParameters[2].Value = Convert.ToString(dtoCustomer.CustomerVisa);
                sqlParameters[3] = new SqlParameter("@CUS_BIRTHDATE", SqlDbType.NVarChar);
                sqlParameters[3].Value = Convert.ToString(dtoCustomer.CustomerBirthDate);
                sqlParameters[4] = new SqlParameter("@CUS_ADDRESS", SqlDbType.NVarChar);
                sqlParameters[4].Value = Convert.ToString(dtoCustomer.CustomerAddress);
                sqlParameters[5] = new SqlParameter("@CUS_PHONE", SqlDbType.NVarChar);
                sqlParameters[5].Value = Convert.ToString(dtoCustomer.CustomerPhone);
                sqlParameters[6] = new SqlParameter("@CUS_NOTE", SqlDbType.NVarChar);
                sqlParameters[6].Value = Convert.ToString(dtoCustomer.CustomerNote);

                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.CUSTOMER_ADD_NEW_CUS_ERR;
            }
            return dataResult;
        }
Exemplo n.º 16
0
 public string ValidateCardId(string strCardId)
 {
     CardDAL dalCard = new CardDAL();
     DataTable tblCard = dalCard.ValidateCardID(strCardId);
     DataTransfer dataResult = new DataTransfer();
     if (tblCard.Rows.Count > 0)
     {
         dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
         DataSet ds = new DataSet();
         ds.Tables.Add(tblCard.Copy());
         dataResult.ResponseDataSet = ds;
     }
     else
     {
         dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
         dataResult.ResponseErrorMsg = SGMText.GAS_STATION_CARD_ID_NOT_EXIST;
     }
     return JSonHelper.ConvertObjectToJSon(dataResult);
 }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
        public DataTransfer AddNewGasStation(GasStationDTO dtoGasStation)
        {
            DataTransfer dataResult = new DataTransfer();
            bool insertResult = true;
            try
            {

                string query = string.Format("INSERT INTO GAS_STATION (GASSTATION_ID, GASSTATION_NAME, GASSTATION_ADDRESS, GASSTATION_DESCRIPTION, GASSTORE_ID) VALUES (@GASSTATION_ID, @GASSTATION_NAME, @GASSTATION_ADDRESS, @GASSTATION_DESCRIPTION, @GASSTORE_ID)");
                SqlParameter[] sqlParameters = new SqlParameter[5];
                sqlParameters[0] = new SqlParameter("@GASSTATION_ID", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(dtoGasStation.GasStationID);
                sqlParameters[1] = new SqlParameter("@GASSTATION_NAME", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(dtoGasStation.GasStationName);
                sqlParameters[2] = new SqlParameter("@GASSTATION_ADDRESS", SqlDbType.NVarChar);
                sqlParameters[2].Value = Convert.ToString(dtoGasStation.GasStationAddress);
                sqlParameters[3] = new SqlParameter("@GASSTATION_DESCRIPTION", SqlDbType.NVarChar);
                sqlParameters[3].Value = Convert.ToString(dtoGasStation.GasStationDescription);
                sqlParameters[4] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[4].Value = Convert.ToString(dtoGasStation.GasStoreID);
                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.GASSTATION_ADD_NEW_GS_ERR;
            }
            return dataResult;
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
 public string UpdateMoneyForCard(string stCardID, int iMoney)
 {
     m_dataResponse = m_dalCard.UpdateMoneyForCard(stCardID, iMoney);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 21
0
 public string UpdateCardState(string stCardID, bool bLocked)
 {
     m_dataResponse = m_dalCard.UpdateCardState(stCardID, bLocked);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 22
0
 public string GetCardsOfCustomer(string stCusID)
 {
     m_dataResponse = m_dalCard.GetCardsOfCustomer(stCusID);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 23
0
 public string CheckCardExist(string stCardID)
 {
     m_dataResponse = m_dalCard.IsCardExisted(stCardID);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 24
0
        public DataTransfer UpdateGasStore(GasStoreDTO dtoGasStore, string stGasStoreID)
        {
            DataTransfer dataResult = new DataTransfer();
            bool updateResult = true;
            try
            {
                string query = string.Format("UPDATE GAS_STORE SET GASSTORE_ID = @GASSTORE_ID_NEW, GASSTORE_NAME = @GASSTORE_NAME, GASSTORE_ADDRESS = @GASSTORE_ADDRESS, GASSTORE_DESCRIPTION = @GASSTORE_DESCRIPTION, GASSTORE_MACADDRESS = @GASSTORE_MACADDRESS, GASSTORE_GAS92_TOTAL = @GASSTORE_GAS92_TOTAL, GASSTORE_GAS95_TOTAL = @GASSTORE_GAS95_TOTAL, GASSTORE_GASDO_TOTAL = @GASSTORE_GASDO_TOTAL WHERE GASSTORE_ID = @GASSTORE_ID_OLD");
                SqlParameter[] sqlParameters = new SqlParameter[9];
                sqlParameters[0] = new SqlParameter("@GASSTORE_ID_NEW", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(dtoGasStore.GasStoreID);
                sqlParameters[1] = new SqlParameter("@GASSTORE_NAME", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(dtoGasStore.GasStoreName);
                sqlParameters[2] = new SqlParameter("@GASSTORE_ADDRESS", SqlDbType.NVarChar);
                sqlParameters[2].Value = Convert.ToString(dtoGasStore.GasStoreAddress);
                sqlParameters[3] = new SqlParameter("@GASSTORE_DESCRIPTION", SqlDbType.NVarChar);
                sqlParameters[3].Value = Convert.ToString(dtoGasStore.GasStoreDescription);
                sqlParameters[4] = new SqlParameter("@GASSTORE_MACADDRESS", SqlDbType.NVarChar);
                if (dtoGasStore.GasStoreMacAddress.Equals(""))
                    sqlParameters[4].Value = DBNull.Value;
                else
                    sqlParameters[4].Value = Convert.ToString(dtoGasStore.GasStoreMacAddress);
                sqlParameters[5] = new SqlParameter("@GASSTORE_GAS92_TOTAL", SqlDbType.Float);
                sqlParameters[5].Value = dtoGasStore.GasStoreGas92Total;
                sqlParameters[6] = new SqlParameter("@GASSTORE_GAS95_TOTAL", SqlDbType.Float);
                sqlParameters[6].Value = dtoGasStore.GasStoreGas95Total;
                sqlParameters[7] = new SqlParameter("@GASSTORE_GASDO_TOTAL", SqlDbType.Float);
                sqlParameters[7].Value = dtoGasStore.GasStoreGasDOTotal;
                sqlParameters[8] = new SqlParameter("@GASSTORE_ID_OLD", SqlDbType.NVarChar);
                sqlParameters[8].Value = Convert.ToString(stGasStoreID);
                updateResult = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters);
            }
            catch (Exception ex)
            {
                updateResult = false;
                dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace;
            }

            if (updateResult)
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
            }
            else
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                dataResult.ResponseErrorMsg = SGMText.GASSTORE_UPDATE_ERR;
            }

            return dataResult;
        }
Exemplo n.º 25
0
 public string AddNewCard(string jsCardDTO)
 {
     m_dataRequest = JSonHelper.ConvertJSonToObject(jsCardDTO);
     m_dataResponse = m_dalCard.AddNewCard(m_dataRequest.ResponseDataCardDTO);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 26
0
 public string UpdateRechargeIDForCard(string stCardID)
 {
     m_dataResponse = m_dalCard.UpdateRechargeIDForCard(stCardID);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 27
0
        public DataTransfer ValidateGasStoreLogin(string stGasStoreID, string stGasStoreMacAddress)
        {
            DataTransfer dataResult = new DataTransfer();
            try
            {
                string query = string.Format("SELECT ISNULL(GASSTORE_MACADDRESS,'NULL') AS RESULT, * FROM GAS_STORE WHERE (GASSTORE_MACADDRESS IS NULL OR GASSTORE_MACADDRESS = @GASSTORE_MACADDRESS) AND GASSTORE_ID = @GASSTORE_ID");
                SqlParameter[] sqlParameters = new SqlParameter[2];
                sqlParameters[0] = new SqlParameter("@GASSTORE_MACADDRESS", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(stGasStoreMacAddress);
                sqlParameters[1] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(stGasStoreID);
                DataTable tblResult = m_dbConnection.ExecuteSelectQuery(query, sqlParameters);
                if (tblResult.Rows.Count > 0)
                {
                    dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
                    DataRow dr = tblResult.Rows[0];

                    GasStoreDTO dtoGasStore = new GasStoreDTO();
                    dtoGasStore.GasStoreID = dr["GASSTORE_ID"].ToString();
                    dtoGasStore.GasStoreName = dr["GASSTORE_NAME"].ToString();
                    dtoGasStore.GasStoreAddress = dr["GASSTORE_ADDRESS"].ToString();
                    dtoGasStore.GasStoreDescription = dr["GASSTORE_DESCRIPTION"].ToString();
                    dtoGasStore.GasStoreMacAddress = dr["GASSTORE_MACADDRESS"].ToString();
                    dtoGasStore.GasStoreGas92Total = float.Parse(dr["GASSTORE_GAS92_TOTAL"].ToString());
                    dtoGasStore.GasStoreGas95Total = float.Parse(dr["GASSTORE_GAS95_TOTAL"].ToString());
                    dtoGasStore.GasStoreGasDOTotal = float.Parse(dr["GASSTORE_GASDO_TOTAL"].ToString());
                    dataResult.ResponseDataGasStoreDTO = dtoGasStore;

                    string result = dr["RESULT"].ToString();
                    if (result.Equals("NULL")) //insert mac address
                    {
                        SqlParameter[] sqlParametersUpdate = new SqlParameter[2];
                        sqlParametersUpdate[0] = new SqlParameter("@GASSTORE_MACADDRESS", SqlDbType.NVarChar);
                        sqlParametersUpdate[0].Value = Convert.ToString(stGasStoreMacAddress);
                        sqlParametersUpdate[1] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                        sqlParametersUpdate[1].Value = Convert.ToString(stGasStoreID);
                        query = string.Format("UPDATE GAS_STORE SET GASSTORE_MACADDRESS = @GASSTORE_MACADDRESS WHERE GASSTORE_ID = @GASSTORE_ID");
                        if (!m_dbConnection.ExecuteUpdateQuery(query, sqlParametersUpdate))
                        {
                            dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                            dataResult.ResponseErrorMsg = SGMText.GAS_STATION_LOGON_UPDATE_MACADR_ERR;
                        }
                    }
                }
                else
                {
                    dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                    dataResult.ResponseErrorMsg = SGMText.GAS_STATION_LOGON_ID_INVALID;
                }
            }
            catch (Exception ex)
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                dataResult.ResponseErrorMsg = SGMText.GAS_STATION_LOGON_ERR;
                dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace;
            }

            return dataResult;
        }
Exemplo n.º 28
0
 public string AddRechargeCard(string jsRechargeDTO)
 {
     m_dataRequest = JSonHelper.ConvertJSonToObject(jsRechargeDTO);
     m_dataResponse = m_dalRecharge.AddRecharge(m_dataRequest.ResponseDataRechargeDTO);
     return JSonHelper.ConvertObjectToJSon(m_dataResponse);
 }
Exemplo n.º 29
0
        public DataTransfer UpdateGasStoreTotal(string stGasStoreID, string stType, float fAmount)
        {
            DataTransfer dataResult = new DataTransfer();
            try
            {
                string query = string.Format("UPDATE GAS_STORE SET XX = XX - @YY WHERE GASSTORE_ID = @GASSTORE_ID");
                SqlParameter[] sqlParameters = new SqlParameter[2];
                sqlParameters[0] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(stGasStoreID);
                sqlParameters[1] = new SqlParameter("@YY", SqlDbType.Float);
                sqlParameters[1].Value = (fAmount);
                if (stType.CompareTo(SaleGasDTO.GAS_TYPE_92) == 0)
                {
                    query = query.Replace("XX", "GASSTORE_GAS92_TOTAL");
                }
                else if (stType.CompareTo(SaleGasDTO.GAS_TYPE_95) == 0)
                {
                    query = query.Replace("XX", "GASSTORE_GAS95_TOTAL");
                }
                else if (stType.CompareTo(SaleGasDTO.GAS_TYPE_DO) == 0)
                {
                    query = query.Replace("XX", "GASSTORE_GASDO_TOTAL");
                }
                dataResult.ResponseDataString = query;
                bool result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters);
                if (result)
                {
                    dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
                    dataResult.ResponseErrorMsg = SGMText.GASSTORE_UPDATE_TOTAL_SUCCESS;
                }
                else
                {
                    dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                    dataResult.ResponseErrorMsg = SGMText.GASSTORE_UPDATE_TOTAL_ERR;
                }
            }
            catch (Exception ex)
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                dataResult.ResponseErrorMsg = SGMText.GASSTORE_UPDATE_TOTAL_ERR;
                dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace;
            }

            return dataResult;
        }
Exemplo n.º 30
0
        public DataTransfer IsGasStoreExisted(string stGasStoreID)
        {
            DataTransfer dataResult = new DataTransfer();
            try
            {
                string query = string.Format("SELECT * FROM GAS_STORE WHERE GASSTORE_ID = @GASSTORE_ID");
                SqlParameter[] sqlParameters = new SqlParameter[1];
                sqlParameters[0] = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[0].Value = Convert.ToString(stGasStoreID);
                DataTable tblResult = m_dbConnection.ExecuteSelectQuery(query, sqlParameters);
                if (tblResult.Rows.Count > 0)
                {
                    dataResult.ResponseDataBool = true;
                }
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_SUCCESS;
            }
            catch (Exception ex)
            {
                dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL;
                dataResult.ResponseErrorMsg = SGMText.GASSTORE_GET_GS_ERR;
                dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace;
            }

            return dataResult;
        }