protected void Page_Load(object sender, EventArgs e) { if (Session["BranchUserID"] == null) { Response.Redirect("Login.aspx"); } if (!IsPostBack) { LoadItems(); if (Session["ScrapID"] != null) { hdnid.Value = Session["ScrapID"].ToString(); TblAssestScrap scrap = new TblAssestScrap(hdnid.Value); hdnQuantity.Value = scrap.Quantity.ToString(); ddlItems.SelectedValue = scrap.ItemID.ToString(); txtQuantity.Text = scrap.Quantity.ToString(); txtDescription.Text = scrap.Description.ToString(); ddlItems.Enabled = false; } else { hdnid.Value = ""; hdnQuantity.Value = ""; } } }
protected void btnSave_Click(object sender, EventArgs e) { TblAssestScrap scrap; string msg = "Scrap has been added!"; if (hdnid.Value == "") { scrap = new TblAssestScrap(); scrap.IsNew = true; scrap.DateX = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd"); } else { scrap = new TblAssestScrap(hdnid.Value); scrap.IsNew = false; msg = "Scrap has been updated!"; } scrap.ItemID = Convert.ToInt32(ddlItems.SelectedValue); scrap.Quantity = Convert.ToInt32(txtQuantity.Text); scrap.Description = txtDescription.Text; scrap.BranchID = Convert.ToInt32(Session["BranchID"]); scrap.Save(); UpdateStore(); Session["ScrapID"] = null; lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check"); helper.ClearInputs(this.Controls); ddlItems.Enabled = true; }
protected void btnDelete_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; TblAssestScrap scrap = new TblAssestScrap(btn.CommandArgument); TblAssestStore store = new SubSonic.Select() .From(TblAssestStore.Schema) .Where(TblAssestStore.Columns.ItemID).IsEqualTo(scrap.ItemID) .And(TblAssestStore.Columns.BranchID).IsEqualTo(Session["BranchID"]) .ExecuteSingle <TblAssestStore>(); store.Quantity += scrap.Quantity; store.Save(); TblAssestScrap.Delete(btn.CommandArgument); LoadScrap(); string msg = "Scrap has been deleted!"; lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check"); }