protected void ui_save_button_Click(object sender, EventArgs e) { SupplierController supplierController = new SupplierController(); Supplier supplier = new Supplier(); int supplier_id; //getting hidden field id if (int.TryParse(ui_id_hiddenfield.Value, out supplier_id)) { supplier.id = Convert.ToInt32(ui_id_hiddenfield.Value); } //fields validation if (String.IsNullOrEmpty(ui_name_textbox.Text) || String.IsNullOrEmpty(ui_code_textbox.Text)) { Response.Cookies.Add(new HttpCookie("flash_message", "Field(s) marked with * can't be empty.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; //String idstring = (supplier.id > 0) ? ("?id="+supplier.id) : (""); //Response.Redirect("~/StoreClerk/SupplierDetail.aspx"+idstring); } //setting up object supplier.code = ui_code_textbox.Text; supplier.supplier_name = ui_name_textbox.Text; supplier.contact_name = ui_contactname_textbox.Text; supplier.phone_number = ui_phonenumber_textbox.Text; supplier.fax_number = ui_faxnumber_textbox.Text; supplier.email = ui_email_textbox.Text; supplier.address = ui_address_textbox.Text; //updating db; Message message; if (supplier.id > 0) { message = supplierController.actionUpdateSupplier(supplier); } else { message = supplierController.actionCreateSupplier(supplier); } //redirecting if (message.condition) { Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Response.Redirect("~/StoreClerk/SupplierDetail.aspx?id=" + supplier.id); } else { Response.Cookies.Add(new HttpCookie("flash_message", message.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); Response.Redirect("~/StoreClerk/SupplierDetail.aspx?id=" + supplier.id); } }
/// <summary> /// Create a new Supplier object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="code">Initial value of the code property.</param> /// <param name="supplier_name">Initial value of the supplier_name property.</param> public static Supplier CreateSupplier(global::System.Int32 id, global::System.String code, global::System.String supplier_name) { Supplier supplier = new Supplier(); supplier.id = id; supplier.code = code; supplier.supplier_name = supplier_name; return supplier; }
/// <summary> /// Deprecated Method for adding a new object to the Suppliers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSuppliers(Supplier supplier) { base.AddObject("Suppliers", supplier); }