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(); PaymentMaster dm = PaymentMaster.GetByPaymemt_ID(int.Parse(nid)); ddlUserName.SelectedItem.Text = dm.User_Name; txtamount.Text = dm.Amount.ToString(); txtremark.Text = dm.Remark; btnPayment.Text = "Update"; }
protected void btnPayment_Click(object sender, EventArgs e) { try { PaymentMaster um = new PaymentMaster(); if (btnPayment.Text == "Submit") { um.Paymemt_ID = PaymentMaster.GetMaxID() + 1; um.User_Name = ddlUserName.SelectedItem.Text; um.User_ID = USERPROFILEMASTER.GetByUser_Name(um.User_Name).User_Name;// lblUSerId.Text.Trim(); um.Amount = decimal.Parse(txtamount.Text); um.Remark = txtremark.Text.Trim(); um.Save(); grid(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Submit Successfully....');</Script>", false); } else if (btnPayment.Text == "Update") { um = PaymentMaster.GetByPaymemt_ID(int.Parse(ViewState["id"].ToString())); um.Paymemt_ID = int.Parse(ViewState["id"].ToString()); um.User_Name = ddlUserName.SelectedItem.Text; um.User_ID = USERPROFILEMASTER.GetByUser_Name(um.User_Name).User_Name;// lblUSerId.Text.Trim(); um.Amount = decimal.Parse(txtamount.Text); um.Remark = txtremark.Text.Trim(); um.Save(); btnPayment.Text = "Submit"; grid(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully..');</Script>", false); } ClearInputs(Page.Controls); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false); } }