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 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; }
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); } }
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; }
public DataTransfer GetCustomer(string stCusID) { DataTransfer dataResult = new DataTransfer(); try { CustomerDTO dtoCustomer = null; string query = query = string.Format("SELECT * 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(stCusID); DataTable tblResult = m_dbConnection.ExecuteSelectQuery(query, sqlParameters); if (tblResult.Rows.Count > 0) { dtoCustomer = new CustomerDTO(); foreach (DataRow dr in tblResult.Rows) { dtoCustomer.CustomerID = dr["CUS_ID"].ToString(); ; dtoCustomer.CustomerName = dr["CUS_NAME"].ToString(); ; dtoCustomer.CustomerVisa = dr["CUS_VISA"].ToString(); ; dtoCustomer.CustomerBirthDate = dr["CUS_BIRTHDATE"].ToString(); ; dtoCustomer.CustomerAddress = dr["CUS_ADDRESS"].ToString(); ; dtoCustomer.CustomerPhone = dr["CUS_PHONE"].ToString(); ; dtoCustomer.CustomerNote = dr["CUS_NOTE"].ToString(); ; } } dataResult.ResponseDataCustomerDTO = dtoCustomer; } catch (Exception ex) { dataResult.ResponseCode = DataTransfer.RESPONSE_CODE_FAIL; dataResult.ResponseErrorMsg = SGMText.CUSTOMER_GET_CUS_ERR; dataResult.ResponseErrorMsgDetail = ex.Message + " : " + ex.StackTrace; } return dataResult; }