protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     int id = Convert.ToInt32(e.CommandArgument);
     Customer item = new Customer();
     item = customers.FirstOrDefault(P => P.Id == id);
     if (e.CommandName == "Select")
     {
         hfId.Value = item.Id.ToString();
         txtCustomerCode.Text = item.CustomerCode;
         txtCustomerName.Text = item.Name;
         txtCompany.Text = item.Company;
         txtPhoneNo.Text = item.PhoneNo;
         txtFax.Text = item.Fax;
         txtEmail.Text = item.Email;
         txtAddress.Text = item.Address;
         txtPostcode.Text = item.Postcode;
         txtState.Text = item.State;
         txtCountry.Text = item.Country;
         txtWebsite.Text = item.Website;
         txtRemarks.Text = item.Remarks;
         Helper.EnableControls(false,action);
     }
 }
 public Customer Insert(string customerCode, string name, string company
     , string phoneNo, string fax, string email, string address, string postcode
     , string state, string country, string website, DateTime? dateCreated
     , DateTime? dateModified, string createdBy, string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Customer item = new Customer();
         if (!String.IsNullOrEmpty(customerCode))
         {
             item.CustomerCode = customerCode;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(company))
         {
             item.Company = company;
         }
         if (!String.IsNullOrEmpty(phoneNo))
         {
             item.PhoneNo = phoneNo;
         }
         if (!String.IsNullOrEmpty(fax))
         {
             item.Fax = fax;
         }
         if (!String.IsNullOrEmpty(email))
         {
             item.Email = email;
         }
         if (!String.IsNullOrEmpty(address))
         {
             item.Address = address;
         }
         if (!String.IsNullOrEmpty(postcode))
         {
             item.Postcode = postcode;
         }
         if (!String.IsNullOrEmpty(state))
         {
             item.State = state;
         }
         if (!String.IsNullOrEmpty(country))
         {
             item.Country = country;
         }
         if (!String.IsNullOrEmpty(website))
         {
             item.Website = website;
         }
         if (dateCreated != null)
         {
             item.DateCreated = dateCreated;
         }
         if (dateModified != null)
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.AddToCustomer(item);
         ctx.SaveChanges();
         return item;
     }
 }