protected void Page_Load(object sender, EventArgs e) { int category_id; if (int.TryParse(Request.QueryString["id"], out category_id)) { category_id = Convert.ToInt16(Request.QueryString["id"].ToString()); if (category_id < 1) { Response.Redirect("~/StoreClerk/CategoryList.aspx"); } if (!Page.IsPostBack) { StationeryController categoryController = new StationeryController(); StationeryCategory category = categoryController.actionGetStationeryCategoryByID(category_id); ui_id_hiddenfield.Value = category.id.ToString(); ui_catname_textbox.Text = category.category_name; ui_content_title_label.Text = category.category_name; } } else { } }
public Message actionCreateStationeryCategory(StationeryCategory objIn) { try { data.StationeryCategories.AddObject(objIn); return this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1); } catch (Exception e) { return this.getNewDefaultMessageForException(e); } }
public Message actionCreateStationeryCategory(StationeryCategory objIn) { try { data.StationeryCategories.AddObject(objIn); return(this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1)); } catch (Exception e) { return(this.getNewDefaultMessageForException(e)); } }
public Message actionUpdateStationeryCategory(StationeryCategory objIn) { try { StationeryCategory category = data.StationeryCategories.Where(o => o.id == objIn.id).Single(); objIn.EntityKey = category.EntityKey; data.StationeryCategories.ApplyCurrentValues(objIn); data.SaveChanges(); return(this.getNewDefaultMessageForDBOperations(true)); } catch (Exception e) { return(this.getNewDefaultMessageForException(e)); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { StationeryController stationeryController = new StationeryController(); List <Supplier> suppliers = new SupplierController().actionGetSuppliers(); int stationery_id; if (int.TryParse(Request.QueryString["id"], out stationery_id)) { stationery_id = Convert.ToInt16(Request.QueryString["id"].ToString()); if (stationery_id < 1) { Response.Redirect("~/m/DepartmentEmplyoee/Stationeries.aspx"); } if (!Page.IsPostBack) { Stationery stationery = stationeryController.actionGetStationeryByID(stationery_id); StationeryCategory category = stationeryController.actionGetStationeryCategoryByID(stationery.category); ui_stationery_name.Text = stationery.stationery_name; ui_category.Text = category.category_name; ui_id_hidden.Value = stationery.id.ToString(); ui_uom.Text = stationery.unit_of_measure; ui_price.Text = stationery.price.ToString(); ui_total.Text = stationery.price.ToString(); ui_price_hidden_forjscalculation.Value = stationery.price.ToString(); } } else { } } }
public Message actionUpdateStationeryCategory(StationeryCategory objIn) { try { StationeryCategory category = data.StationeryCategories.Where(o => o.id == objIn.id).Single(); objIn.EntityKey = category.EntityKey; data.StationeryCategories.ApplyCurrentValues(objIn); data.SaveChanges(); return this.getNewDefaultMessageForDBOperations(true); } catch (Exception e) { return this.getNewDefaultMessageForException(e); } }
protected void ui_save_button_Click(object sender, EventArgs e) { StationeryController sationeryController = new StationeryController(); StationeryCategory category = new StationeryCategory(); int category_id; //getting hidden field id if (int.TryParse(ui_id_hiddenfield.Value, out category_id)) { category.id = Convert.ToInt32(ui_id_hiddenfield.Value); } //fields validation if (String.IsNullOrEmpty(ui_catname_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 category.category_name = ui_catname_textbox.Text; //updating db; Message message; if (category.id > 0) { message = sationeryController.actionUpdateStationeryCategory(category); } else { message = sationeryController.actionCreateStationeryCategory(category); } //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/CategoryDetail.aspx?id=" + category.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/CategoryDetail.aspx?id=" + category.id); } }