public void createNewDiscrepancy(HttpContext context) { int stationeryId = Convert.ToInt32(context.Request.Form["stationeryId"]); int quantity = Convert.ToInt32(context.Request.Form["quantity"]); string remark = context.Request.Form["remark"]; Discrepancy d = new Discrepancy(); d.stationery = stationeryId; d.quantity = quantity; d.remark = remark; new DiscrepencyController().actionCreateNewDiscrepancy(d); context.Response.ContentType = "text/plain"; context.Response.Write("Successfully recorded as discrepancy item."); context.Response.End(); }
/// <summary> /// Deprecated Method for adding a new object to the Discrepancies EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDiscrepancies(Discrepancy discrepancy) { base.AddObject("Discrepancies", discrepancy); }
/// <summary> /// Create a new Discrepancy object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="stationery">Initial value of the stationery property.</param> /// <param name="quantity">Initial value of the quantity property.</param> /// <param name="status">Initial value of the status property.</param> public static Discrepancy CreateDiscrepancy(global::System.Int32 id, global::System.Int32 stationery, global::System.Int32 quantity, global::System.Int32 status) { Discrepancy discrepancy = new Discrepancy(); discrepancy.id = id; discrepancy.stationery = stationery; discrepancy.quantity = quantity; discrepancy.status = status; return discrepancy; }
protected void ui_save_button_Click(object sender, EventArgs e) { DiscrepencyController discrepancyController = new DiscrepencyController(); Discrepancy discrepancy = new Discrepancy(); if (String.IsNullOrEmpty(ui_stationery_hidden.Value) || String.IsNullOrEmpty(ui_quantity_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; } discrepancy.stationery = Convert.ToInt32(ui_stationery_hidden.Value); try { discrepancy.quantity = Convert.ToInt32(ui_quantity_textbox.Text); if (discrepancy.quantity < 0) { throw new Exception(); } } catch (Exception ex) { Response.Cookies.Add(new HttpCookie("flash_message", "Quantity should be only number.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); Response.Redirect(Request.RawUrl); } discrepancy.remark = ui_remark_textboxt.Text; discrepancyController.actionCreateNewDiscrepancy(discrepancy); Response.Redirect("DiscrepancyList.aspx"); }