Ejemplo n.º 1
0
        public bool UpdateSystemAdmin(SystemAdminDTO dtoSysAdmin)
        {
            bool   result = true;
            string query  = string.Format("UPDATE SYSTEM_ADMIN SET SYS_PWD = @SYS_PWD, SYS_GAS92_CURRENT_PRICE = @SYS_GAS92_CURRENT_PRICE, SYS_GAS95_CURRENT_PRICE = @SYS_GAS95_CURRENT_PRICE, SYS_GASDO_CURRENT_PRICE = @SYS_GASDO_CURRENT_PRICE " +
                                          "SYS_GAS92_NEW_PRICE = @SYS_GAS92_NEW_PRICE, SYS_GAS95_NEW_PRICE = @SYS_GAS95_NEW_PRICE, SYS_GASDO_NEW_PRICE = @SYS_GASDO_NEW_PRICE, SYS_APPLY_DATE = @SYS_APPLY_DATE " +
                                          " WHERE SYS_ADMIN = @SYS_ADMIN");

            SqlParameter[] sqlParameters = new SqlParameter[9];
            sqlParameters[0]       = new SqlParameter("@SYS_ADMIN", SqlDbType.NVarChar);
            sqlParameters[0].Value = Convert.ToString(dtoSysAdmin.SysAdminAccount);
            sqlParameters[1]       = new SqlParameter("@SYS_PWD", SqlDbType.NVarChar);
            sqlParameters[1].Value = Convert.ToString(dtoSysAdmin.SysAdminPwd);
            sqlParameters[2]       = new SqlParameter("@SYS_GAS92_CURRENT_PRICE", SqlDbType.Int);
            sqlParameters[2].Value = Convert.ToInt32(dtoSysAdmin.SysGas92CurrentPrice);
            sqlParameters[3]       = new SqlParameter("@SYS_GAS95_CURRENT_PRICE", SqlDbType.Int);
            sqlParameters[3].Value = Convert.ToInt32(dtoSysAdmin.SysGas95CurrentPrice);
            sqlParameters[4]       = new SqlParameter("@SYS_GASDO_CURRENT_PRICE", SqlDbType.Int);
            sqlParameters[4].Value = Convert.ToInt32(dtoSysAdmin.SysGasDOCurrentPrice);
            sqlParameters[5]       = new SqlParameter("@SYS_GAS92_NEW_PRICE", SqlDbType.Int);
            sqlParameters[5].Value = Convert.ToInt32(dtoSysAdmin.SysGas92NewPrice);
            sqlParameters[6]       = new SqlParameter("@SYS_GAS95_NEW_PRICE", SqlDbType.Int);
            sqlParameters[6].Value = Convert.ToInt32(dtoSysAdmin.SysGas95NewPrice);
            sqlParameters[7]       = new SqlParameter("@SYS_GASDO_NEW_PRICE", SqlDbType.Int);
            sqlParameters[7].Value = Convert.ToInt32(dtoSysAdmin.SysGasDONewPrice);
            sqlParameters[8]       = new SqlParameter("@SYS_APPLY_DATE", SqlDbType.DateTime);
            sqlParameters[8].Value = Convert.ToDateTime(dtoSysAdmin.SysApplyDate);

            result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters);
            return(result);
        }
Ejemplo n.º 2
0
        public DataTransfer UpdateGasStation(GasStationDTO dtoGasStation, string stGasStationID)
        {
            DataTransfer dataResult   = new DataTransfer();
            bool         updateResult = true;

            try
            {
                string         query         = string.Format("UPDATE GAS_STATION SET GASSTATION_ID = @GASSTATION_ID_NEW, GASSTATION_NAME = @GASSTATION_NAME, GASSTATION_ADDRESS = @GASSTATION_ADDRESS, GASSTATION_DESCRIPTION = @GASSTATION_DESCRIPTION, GASSTATION_MACADDRESS = @GASSTATION_MACADDRESS, GASSTORE_ID = @GASSTORE_ID WHERE GASSTATION_ID = @GASSTATION_ID_OLD");
                SqlParameter[] sqlParameters = new SqlParameter[7];
                sqlParameters[0]       = new SqlParameter("@GASSTATION_ID_NEW", 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("@GASSTATION_MACADDRESS", SqlDbType.NVarChar);
                if (dtoGasStation.GasStationMacAddress.Equals(""))
                {
                    sqlParameters[4].Value = DBNull.Value;
                }
                else
                {
                    sqlParameters[4].Value = Convert.ToString(dtoGasStation.GasStationMacAddress);
                }
                sqlParameters[5]       = new SqlParameter("@GASSTORE_ID", SqlDbType.NVarChar);
                sqlParameters[5].Value = Convert.ToString(dtoGasStation.GasStoreID);
                sqlParameters[6]       = new SqlParameter("@GASSTATION_ID_OLD", SqlDbType.NVarChar);
                sqlParameters[6].Value = Convert.ToString(stGasStationID);
                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.GASSTATION_UPDATE_ERR;
            }

            return(dataResult);
        }
Ejemplo n.º 3
0
        public bool UpdateSaleGas(SaleGasDTO dtoSaleGas)
        {
            bool   result = true;
            string query  = string.Format("UPDATE SALE_GAS SET SALEGAS_TYPE = @SALEGAS_TYPE, SALEGAS_CURRENT_PRICE = @SALEGAS_CURRENT_PRICE, SALEGAS_CARD_PRICE = @SALEGAS_CARD_PRICE, " +
                                          " SALEGAS_CARD_MONEY_BEFORE = @SALEGAS_CARD_MONEY_BEFORE, SALEGAS_CARD_MONEY_AFTER = @SALEGAS_CARD_MONEY_AFTER, SALEGAS_CARD_MONEY_SAVING = @SALEGAS_CARD_MONEY_SAVING, SALEGAS_LIT = @SALEGAS_LIT, SALEGAS_DATE = @SALEGAS_DATE, GASSTATION_ID = @GASSTATION_ID, CARD_ID = @CARD_ID " +
                                          " WHERE SALEGAS_ID = @SALEGAS_ID");

            SqlParameter[] sqlParameters = new SqlParameter[11];
            sqlParameters[0]        = new SqlParameter("@SALEGAS_ID", SqlDbType.Int);
            sqlParameters[0].Value  = Convert.ToInt32(dtoSaleGas.SaleGasID);
            sqlParameters[1]        = new SqlParameter("@SALEGAS_TYPE", SqlDbType.NVarChar);
            sqlParameters[1].Value  = Convert.ToString(dtoSaleGas.SaleGasType);
            sqlParameters[2]        = new SqlParameter("@SALEGAS_CURRENT_PRICE", SqlDbType.Int);
            sqlParameters[2].Value  = Convert.ToInt32(dtoSaleGas.SaleGasCurrentPrice);
            sqlParameters[3]        = new SqlParameter("@SALEGAS_CARD_PRICE", SqlDbType.Int);
            sqlParameters[3].Value  = Convert.ToInt32(dtoSaleGas.SaleGasPriceOnCard);
            sqlParameters[4]        = new SqlParameter("@SALEGAS_CARD_MONEY_BEFORE", SqlDbType.Int);
            sqlParameters[4].Value  = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneyBefore);
            sqlParameters[5]        = new SqlParameter("@SALEGAS_CARD_MONEY_AFTER", SqlDbType.Int);
            sqlParameters[5].Value  = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneyAfter);
            sqlParameters[6]        = new SqlParameter("@SALEGAS_LIT", SqlDbType.Float);
            sqlParameters[6].Value  = Convert.ToDouble(dtoSaleGas.NumberBuyLit);
            sqlParameters[7]        = new SqlParameter("@SALEGAS_DATE", SqlDbType.DateTime);
            sqlParameters[7].Value  = Convert.ToDateTime(dtoSaleGas.GasStationID);
            sqlParameters[8]        = new SqlParameter("@GASSTATION_ID", SqlDbType.NVarChar);
            sqlParameters[8].Value  = Convert.ToString(dtoSaleGas.GasStationID);
            sqlParameters[9]        = new SqlParameter("@CARD_ID", SqlDbType.NVarChar);
            sqlParameters[9].Value  = Convert.ToString(dtoSaleGas.CardID);
            sqlParameters[10]       = new SqlParameter("@SALEGAS_CARD_MONEY_SAVING", SqlDbType.NVarChar);
            sqlParameters[10].Value = Convert.ToInt32(dtoSaleGas.SaleGasCardMoneySaving);

            result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters);
            return(result);
        }
Ejemplo n.º 4
0
        public bool UpdateRecharge(RechargeDTO dtoRecharge)
        {
            bool   result = true;
            string query  = string.Format("UPDATE RECHARGE SET RECHARGE_DATE = @RECHARGE_DATE, RECHARGE_MONEY = @RECHARGE_MONEY, RECHARGE_MONEY_EX = @RECHARGE_MONEY_EX, RECHARGE_NOTE = @RECHARGE_NOTE, " +
                                          " RECHARGE_GAS92_PRICE = @RECHARGE_GAS92_PRICE, RECHARGE_GAS95_PRICE = @RECHARGE_GAS95_PRICE, RECHARGE_GASDO_PRICE = @RECHARGE_GASDO_PRICE, CARD_ID = @CARD_ID " +
                                          " WHERE RECHARGE_ID = @RECHARGE_ID"
                                          );

            SqlParameter[] sqlParameters = new SqlParameter[9];
            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("@RECHARGE_ID", SqlDbType.NVarChar);
            sqlParameters[7].Value = Convert.ToString(dtoRecharge.RechargeID);
            result = m_dbConnection.ExecuteUpdateQuery(query, sqlParameters);
            return(result);
        }
Ejemplo n.º 5
0
        public DataTransfer UpdateCustomer(CustomerDTO dtoCustomer, string cusID)
        {
            DataTransfer dataResult   = new DataTransfer();
            bool         updateResult = true;

            try
            {
                string         query         = string.Format("UPDATE CUSTOMER SET CUS_ID = @CUS_ID_NEW, CUS_NAME = @CUS_NAME, CUS_VISA = @CUS_VISA, CUS_BIRTHDATE = @CUS_BIRTHDATE, CUS_ADDRESS = @CUS_ADDRESS, CUS_PHONE = @CUS_PHONE, CUS_NOTE = @CUS_NOTE WHERE CUS_ID = @CUS_ID_OLD");
                SqlParameter[] sqlParameters = new SqlParameter[8];
                sqlParameters[0]       = new SqlParameter("@CUS_ID_NEW", 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);
                sqlParameters[7]       = new SqlParameter("@CUS_ID_OLD", SqlDbType.NVarChar);
                sqlParameters[7].Value = Convert.ToString(cusID);
                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.CUSTOMER_UPDATE_CUS_ERR;
            }

            return(dataResult);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
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);
        }