protected void btnsubmit_Click(object sender, EventArgs e) { try { decimal total = 0; OrderMaster ln = new OrderMaster(); total = decimal.Parse(numqty.Text) * decimal.Parse(txtrate.Text.Trim()); if (btnsubmit.Text == "Submit") { if (string.IsNullOrEmpty(numqty.Text)) { ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Plz Enter Quantity..');</Script>", false); numqty.Focus(); return; } else { decimal qt = decimal.Parse(numqty.Text.Trim()); if (qt <= 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Quantity must be greater than zero..');</Script>", false); numqty.Focus(); return; } } ln.OrderId = OrderMaster.GetMaxID() + 1; ln.ITEM_ID = ddlItem.SelectedIndex; ln.QUANTITY = decimal.Parse(numqty.Text); ln.RATE_PER = decimal.Parse(txtrate.Text.Trim()); ln.TOTAL = total; ln.OrderBILL_ID = billid; ln.OrderDate = System.DateTime.Today; ln.PickupID = int.Parse(Session["PickupID"].ToString()); ln.Save(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Submit Successfully...');</Script>", false); } else if (btnsubmit.Text == "Update") { ln = OrderMaster.GetByOrderId(int.Parse(ViewState["id"].ToString())); ln.OrderId = int.Parse(ViewState["id"].ToString()); ln.ITEM_ID = ddlItem.SelectedIndex; ln.QUANTITY = decimal.Parse(numqty.Text); ln.RATE_PER = decimal.Parse(txtrate.Text.Trim()); ln.TOTAL = total; ln.OrderBILL_ID = billid; ln.OrderDate = System.DateTime.Today; ln.PickupID = int.Parse(Session["PickupID"].ToString()); ln.Save(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully...');</Script>", false); } grid(); ClearControls(this); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false); } }
protected void linkbtnEdit_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; GridViewRow gr = (GridViewRow)lb.NamingContainer; ViewState["id"] = ((Label)gr.FindControl("labelNOTICE_ID")).Text; string nid = ViewState["id"].ToString(); OrderMaster dm = OrderMaster.GetByOrderId(int.Parse(nid)); ddlItem.SelectedIndex = dm.ITEM_ID; txtItemCode.Text = ITEM_MASTER.GetByITEM_ID(ddlItem.SelectedIndex).CODE; numqty.Text = dm.QUANTITY.ToString(); txtrate.Text = dm.RATE_PER.ToString(); btnsubmit.Text = "Update"; }