private void gridView1_RowClick(object sender, RowClickEventArgs e) { if (e.Clicks >= 1) { var custCode = (string)((GridView)sender).GetRowCellValue(e.RowHandle, "CUST_CODE"); _customer = _customerService.GetCustomerByCustCode(custCode); txtCustCode.Text = _customer.CUST_CODE; txtCustName.Text = _customer.CUST_NAME; txtAddress.Text = _customer.ADDRESS; txtTaxCode.Text = _customer.TAX_CODE; txtTel.Text = _customer.TEL; txtFax.Text = _customer.FAX; txtPartName.Text = _customer.NAME_PART; txtBuyerName.Text = _customer.BUYER; txtCusName.Text = _customer.NAME_CUS; txtPayType.Text = _customer.PAY_TYPE; txtPayTerm.Text = _customer.PAY_TERM; txtCodeTax.Text = _customer.CODE_TAX; txtCurrency.Text = _customer.CURRENCY; txtDelTerm.Text = _customer.DEL_TERM; txtDelPlace.Text = _customer.DEL_PLACE; txtNamePart.Text = _customer.NAME_PART1; txtCustCode.Enabled = false; } }
private void gridLookUpEditCustomer_EditValueChanged(object sender, System.EventArgs e) { string custCode = gridLookUpEditCustomer.EditValue.ToString(); if (!string.IsNullOrEmpty(custCode)) { _customer = _customerService.GetCustomerByCustCode(custCode); txtCustCode.Text = _customer.CUST_CODE; txtCustName.Text = _customer.CUST_NAME; txtAddress.Text = _customer.ADDRESS; txtCodeTax.Text = _customer.CODE_TAX; txtTel.Text = _customer.TEL; txtFax.Text = _customer.FAX; txtPartName.Text = _customer.NAME_PART; txtCusName.Text = _customer.NAME_CUS; txtPayType.Text = _customer.PAY_TYPE; txtPayTerm.Text = _customer.PAY_TERM; txtCurrency.Text = _customer.CURRENCY; txtTaxCode.Text = _customer.TAX_CODE; txtDelTerm.Text = _customer.DEL_TERM; txtDelPlace.Text = _customer.DEL_PLACE; txtNamePart.Text = _customer.NAME_PART1; txtBuyerName.Text = _customer.BUYER; btnExportExel.Enabled = true; } }
public void InsertOrUpdate(string custCode, string custName, string address, string taxCode, string tel, string fax, string partName, string buyerName, string cusName, string payType, string payTerm, string currency, string codeTax, string delTerm, string delPlace, string namePart ) { //Add(customer); if (CheckCustCodeExit(custCode)) { var cusInsert= new Customer() { CUST_CODE = custCode, CUST_NAME = custName, ADDRESS = address, TAX_CODE = taxCode, TEL = tel, FAX = fax, NAME_PART = partName, BUYER = buyerName, NAME_CUS = cusName, PAY_TYPE = payType, PAY_TERM = payTerm, CURRENCY = currency, CODE_TAX = codeTax, DEL_TERM = delTerm, DEL_PLACE = delPlace, NAME_PART1 = namePart }; Add(cusInsert); } else { Customer cusUpdate = GetCustomerByCustCode(custCode); cusUpdate.CUST_NAME = custName; cusUpdate.ADDRESS = address; cusUpdate.CODE_TAX = taxCode; cusUpdate.TEL = tel; cusUpdate.FAX = fax; cusUpdate.NAME_PART = partName; cusUpdate.BUYER = buyerName; cusUpdate.NAME_CUS = cusName; cusUpdate.PAY_TYPE = payType; cusUpdate.PAY_TERM = payTerm; cusUpdate.CURRENCY = currency; cusUpdate.TAX_CODE = codeTax; cusUpdate.DEL_TERM = delTerm; cusUpdate.DEL_PLACE = delPlace; cusUpdate.NAME_PART1 = namePart; Update(cusUpdate); } }
private void Update(Customer customer) { _context.Customers.Attach(customer); _context.Entry(customer).State = EntityState.Modified; SaveChanges(); }
private void Add(Customer customer) { _context.Customers.Add(customer); SaveChanges(); }