/// <summary> /// Bind Edit Datas /// </summary> public void BindEditDatas() { SupplierAdmin supplierAdmin = new SupplierAdmin(); ZNode.Libraries.DataAccess.Entities.Supplier supplier = supplierAdmin.GetBySupplierID(ItemId); if (supplier != null) { Name.Text = supplier.Name; Description.Text = supplier.Description; ContactFirstName.Text = supplier.ContactFirstName; ContactLastName.Text = supplier.ContactLastName; ContactPhone.Text = supplier.ContactPhone; EmailId.Text = supplier.ContactEmail; NotifyEmail.Text = supplier.NotificationEmailID; NotificationTemplate.Text = supplier.EmailNotificationTemplate; ChkEmailNotify.Checked = supplier.EnableEmailNotification; DisplayOrder.Text = supplier.DisplayOrder.ToString(); CheckActiveInd.Checked = supplier.ActiveInd; txtCustom1.Text = supplier.Custom1; txtCustom2.Text = supplier.Custom2; txtCustom3.Text = supplier.Custom3; txtCustom4.Text = supplier.Custom4; txtCustom5.Text = supplier.Custom5; ddlSupplierTypes.SelectedValue = supplier.SupplierTypeID.GetValueOrDefault().ToString(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { SupplierAdmin supplierAdmin = new SupplierAdmin(); Supplier supplier = new Supplier(); if (ItemId > 0) { supplier = supplierAdmin.GetBySupplierID(ItemId); } supplier.Name = Name.Text; supplier.Description = Description.Text; supplier.ContactFirstName = ContactFirstName.Text; supplier.ContactLastName = ContactLastName.Text; supplier.ContactPhone = ContactPhone.Text; supplier.ContactEmail = EmailId.Text; supplier.NotificationEmailID = NotifyEmail.Text; supplier.EmailNotificationTemplate = NotificationTemplate.Text; supplier.EnableEmailNotification = ChkEmailNotify.Checked; supplier.DisplayOrder = int.Parse(DisplayOrder.Text.Trim()); supplier.ActiveInd = CheckActiveInd.Checked; supplier.Custom1 = txtCustom1.Text; supplier.Custom2 = txtCustom2.Text; supplier.Custom3 = txtCustom3.Text; supplier.Custom4 = txtCustom4.Text; supplier.Custom5 = txtCustom5.Text; if (ddlSupplierTypes.SelectedIndex != -1) { supplier.SupplierTypeID = int.Parse(ddlSupplierTypes.SelectedValue); } bool check = false; if (ItemId > 0) { check = supplierAdmin.Update(supplier); } else { check = supplierAdmin.Insert(supplier); } if (check) { // redirect to main page Response.Redirect("list.aspx"); } else { // display error message lblError.Text = "An error occurred while updating. Please try again."; } }