public frmSGMUpdateStore(GasStoreDTO dto) { InitializeComponent(); m_service = new SGM_Service.ServiceSoapClient(); frmMsg = new frmSGMMessage(); _storeDTO = dto; }
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 GasStoreDTO(GasStoreDTO other) { GasStoreID = other.GasStoreID; GasStoreName = other.GasStoreName; GasStoreAddress = other.GasStoreAddress; GasStoreMacAddress = other.GasStoreMacAddress; GasStoreDescription = other.GasStoreDescription; GasStoreGas92Total = other.GasStoreGas92Total; GasStoreGas95Total = other.GasStoreGas95Total; GasStoreGasDOTotal = other.GasStoreGasDOTotal; }
public GasStoreDTO(GasStoreDTO other) { GasStoreID = other.GasStoreID ; GasStoreName = other.GasStoreName; GasStoreAddress = other.GasStoreAddress; GasStoreMacAddress = other.GasStoreMacAddress; GasStoreDescription = other.GasStoreDescription ; GasStoreGas92Total = other.GasStoreGas92Total; GasStoreGas95Total = other.GasStoreGas95Total; GasStoreGasDOTotal = other.GasStoreGasDOTotal; }
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); } }
public DataTransfer AddNewGasStore(GasStoreDTO dtoGasStore) { DataTransfer dataResult = new DataTransfer(); bool insertResult = true; try { string query = string.Format("INSERT INTO GAS_STORE (GASSTORE_ID, GASSTORE_NAME, GASSTORE_ADDRESS, GASSTORE_DESCRIPTION, GASSTORE_GAS92_TOTAL, GASSTORE_GAS95_TOTAL, GASSTORE_GASDO_TOTAL) VALUES (@GASSTORE_ID, @GASSTORE_NAME, @GASSTORE_ADDRESS, @GASSTORE_DESCRIPTION, @GASSTORE_GAS92_TOTAL, @GASSTORE_GAS95_TOTAL, @GASSTORE_GASDO_TOTAL)"); SqlParameter[] sqlParameters = new SqlParameter[7]; sqlParameters[0] = new SqlParameter("@GASSTORE_ID", 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_GAS92_TOTAL", SqlDbType.Float); sqlParameters[4].Value = dtoGasStore.GasStoreGas92Total; sqlParameters[5] = new SqlParameter("@GASSTORE_GAS95_TOTAL", SqlDbType.Float); sqlParameters[5].Value = dtoGasStore.GasStoreGas95Total; sqlParameters[6] = new SqlParameter("@GASSTORE_GASDO_TOTAL", SqlDbType.Float); sqlParameters[6].Value = dtoGasStore.GasStoreGasDOTotal; 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_GS_ERR; } return dataResult; }
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; }
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; }
public DataTransfer GetGasStoreFromGasStation(string stGasStationID) { DataTransfer dataResult = new DataTransfer(); try { GasStoreDTO dtoGasStore = null; string query = string.Format("SELECT GAS_STORE.* FROM GAS_STORE, GAS_STATION WHERE GAS_STORE.GASSTORE_ID = GAS_STATION.GASSTORE_ID AND GASSTATION_ID = @GASSTATION_ID"); SqlParameter[] sqlParameters = new SqlParameter[1]; sqlParameters[0] = new SqlParameter("@GASSTATION_ID", SqlDbType.NVarChar); sqlParameters[0].Value = Convert.ToString(stGasStationID); DataTable tblResult = m_dbConnection.ExecuteSelectQuery(query, sqlParameters); if (tblResult.Rows.Count > 0) { dtoGasStore = new GasStoreDTO(); foreach (DataRow dr in tblResult.Rows) { 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; } catch (Exception ex) { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL; dataResult.ResponseErrorMsg = SGMText.GASSTORE_GET_GS_ERR; dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace; } return dataResult; }
private void btnEdit_Click(object sender, EventArgs e) { if (m_iCurrentGSIndex >= 0) { if (btnEdit.Text.Equals("&Sửa")) { m_stGSIDEdit = m_dsGasStore.Tables[0].Rows[m_iCurrentGSIndex]["GASSTORE_ID"].ToString(); btnEdit.Text = "&Lưu"; UpdateStateControls(true); btnReset.Enabled = true; 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.GasStoreMacAddress = txtMacAddress.Text.Trim(); gas.GasStoreGas92Total = float.Parse(txtTotalGas92.Text); gas.GasStoreGas95Total = float.Parse(txtTotalGas95.Text); gas.GasStoreGasDOTotal = float.Parse(txtTotalGasDO.Text); 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_UpdateGasStore(jsRequest, m_stGSIDEdit); }); 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; } m_stGSIDEdit = ""; btnEdit.Text = "&Sửa"; btnReset.Enabled = false; LoadGasStoreList(); SelectGSRow(gas.GasStoreID); UpdateStateControls(false); }, SynchronizationContext.Current); } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (_storeDTO == null) { //frmMsg.ShowMsg(SGMText.SGM_ERROR, "DTO NULL", SGMMessageType.SGM_MESSAGE_TYPE_ERROR); return; } if (!ValidateDataInput()) { return; } float gas92Add = float.Parse(txtGas92New.Text); float gas95Add = float.Parse(txtGas95New.Text); float gasDOAdd = float.Parse(txtGasDONew.Text); DataTransfer request = new DataTransfer(); GasStoreDTO cloneStoreDTO = new GasStoreDTO(_storeDTO); cloneStoreDTO.GasStoreGas92Total = _storeDTO.GasStoreGas92Total + gas92Add; cloneStoreDTO.GasStoreGas95Total = _storeDTO.GasStoreGas95Total + gas95Add; cloneStoreDTO.GasStoreGasDOTotal = _storeDTO.GasStoreGasDOTotal + gasDOAdd; request.ResponseDataGasStoreDTO = cloneStoreDTO; string jsRequest = JSonHelper.ConvertObjectToJSon(request); Task<String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_UpdateGasStore(jsRequest, cloneStoreDTO.GasStoreID); }); 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) { DataTransfer request2 = new DataTransfer(); GasStoreUpdateDTO dto = new GasStoreUpdateDTO(); dto.GasStoreID = _storeDTO.GasStoreID; dto.GSUpdateDate = DateTime.Now; dto.GSUpdateDescription = txtNote.Text; dto.GSUpdateGas92Add = gas92Add; dto.GSUpdateGas95Add = gas95Add; dto.GSUpdateGasDOAdd = gasDOAdd; dto.GSUpdateGas92Total = _storeDTO.GasStoreGas92Total; dto.GSUpdateGas95Total = _storeDTO.GasStoreGas95Total; dto.GSUpdateGasDOTotal = _storeDTO.GasStoreGasDOTotal; request2.ResponseDataGasStoreUpdateDTO = dto; string jsRequest2 = JSonHelper.ConvertObjectToJSon(request2); Task<String> task2 = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return m_service.SGMManager_AddNewGasStoreUpdate(jsRequest2); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task2, () => { String stResponse2 = task2.Result as String; DataTransfer dataResponse2 = JSonHelper.ConvertJSonToObject(stResponse); if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.GASSTORE_UPDATE_TOTAL_SUCCESS, SGMMessageType.SGM_MESSAGE_TYPE_INFO); _storeDTO.GasStoreGas92Total += gas92Add; _storeDTO.GasStoreGas95Total += gas95Add; _storeDTO.GasStoreGasDOTotal += gasDOAdd; DataToUIView(); RefreshUpdateHistory(); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsgDetail, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); }