protected void btnDelete_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(hfId.Value)) { try { CustomerFacade facade = new CustomerFacade(); int id = Convert.ToInt32(hfId.Value); facade.Delete(id); gvCustomers.DataBind(); lblErrorMessage.Text = Helper.DeleteRecordMessage(true); } catch (Exception exception) { lblErrorMessage.Text = Helper.DeleteRecordMessage(false); } } }
protected void btnSave_Click(object sender, EventArgs e) { CustomerFacade facade = new CustomerFacade(); int? id = null; try { id = (!String.IsNullOrEmpty(hfId.Value)) ? Convert.ToInt32(hfId.Value) : id; facade.Save(id, txtCustomerCode.Text, txtCustomerName.Text, txtCompany.Text, txtPhoneNo.Text , txtFax.Text, txtEmail.Text, txtAddress.Text, txtPostcode.Text, txtState.Text, txtCountry.Text, txtWebsite.Text , DateTime.Now, DateTime.Now, user, user, txtRemarks.Text); lblErrorMessage.Text = Helper.SaveRecordMessage(true); } catch (Exception ex) { lblErrorMessage.Text = Helper.SaveRecordMessage(false); } gvCustomers.DataBind(); Helper.EnableControls(false, action); }