protected void gvCommon_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "edt") { int index = int.Parse(e.CommandArgument.ToString()); hid.Value = "Update"; // int key = Convert.ToInt32(gvDept.DataKeys[index].Value.ToString()); GSS_SalesTbl estf = GasSalesBLL.GetGasSale(index); dvID.Visible = true; dvMsg.InnerText = "Update Sales Data:"; btnSubmit.Text = "Update"; btnSubmit.Enabled = true; //GridViewRow row = gvCommon.SelectedRow; string recID = ""; //recID = (row.FindControl("lbRecID") as Label).Text; GSS_SalesTbl ast = GasSalesBLL.GetGasSale(index); //GSS_SalesTbl ast = GasSalesBLL.GetGasSale(int.Parse(recID)); if (ast != null) { txtID.Text = index.ToString(); ddlDir.SelectedValue = ast.CustomerID.Value.ToString(); txtCap.Text = ast.CapturedVolumeSale.Value.ToString(); ddlDir.Enabled = false; //ddlDir.SelectedValue = (row.FindControl("lbDir") as Label).Text; ; //ddlDir.SelectedItem.Text = HttpUtility.HtmlDecode(row.Cells[2].Text).ToLower(); } } } catch (Exception ex) { } }
protected void gvCommon_SelectedIndexChanged(object sender, EventArgs e) { try { hid.Value = "Update"; dvID.Visible = true; dvMsg.InnerText = "Update Sales Data:"; btnSubmit.Text = "Update"; GridViewRow row = gvCommon.SelectedRow; string recID = ""; recID = (row.FindControl("lbRecID") as Label).Text; GSS_SalesTbl ast = GasSalesBLL.GetGasSale(int.Parse(recID)); if (ast != null) { txtID.Text = recID; ddlDir.SelectedValue = ast.CustomerID.Value.ToString(); txtVol.Text = ast.CapturedVolumeSale.Value.ToString(); txtDate.Text = ast.DateCaptured.Value.ToString(culture); //ddlDir.SelectedValue = (row.FindControl("lbDir") as Label).Text; ; //ddlDir.SelectedItem.Text = HttpUtility.HtmlDecode(row.Cells[2].Text).ToLower(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
protected void btnApprv_Click(object sender, EventArgs e) { try { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } bool isset = false; foreach (GridViewRow row in gvCommon.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); GSS_SalesTbl expPro = GasSalesBLL.GetGasSale(recID); if (expPro != null && expPro.Status == (int)Utility.SalesStatus.Pending_Capture_Approval) { expPro.Status = (int)Utility.SalesStatus.Captured_Volume_Approved; expPro.CapturedVolumeApprovedBy = usr.ID; GasSalesBLL.UpdateSalesData(expPro); isset = true; } } } if (isset) { BindGrid(DateTime.Now.AddDays(40)); success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully approved."; return; } else { BindGrid(DateTime.Now.AddDays(40)); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured some of selected record(s) could not be approved.If error persist contact Administrator!!."; } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } } catch (Exception ex) { } }
private void BindGrid(DateTime from, DateTime to, int cust = 0) { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } gvCommon.DataSource = GasSalesBLL.GetAggregateSalesList(from, to, cust); gvCommon.DataBind(); }
private void BindGrid(DateTime filter, int cust = 0) { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } gvCommon.DataSource = GasSalesBLL.GetGasSalesList((int)Utility.SalesStatus.Captured_Volume_Approved, filter, cust); gvCommon.DataBind(); }
protected void gvCommon_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "del") { int index = int.Parse(e.CommandArgument.ToString()); // int key = Convert.ToInt32(gvDept.DataKeys[index].Value.ToString()); GSS_SalesTbl estf = GasSalesBLL.GetGasSale(index); GasSalesBLL.DeleteGasSales(estf); BindGrid(DateTime.Now.AddDays(40)); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record deleted successfully!!."; return; } }catch (Exception ex) { } }
protected void btnSubmit_Click(object sender, EventArgs e) { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } try { decimal totVol = 0; DateTime sdate; if (hid.Value == "Update") { GSS_SalesTbl ast = null; bool rst = false; ast = GasSalesBLL.GetGasSale(Convert.ToInt32(txtID.Text)); if (ast != null) { //ast.CustomerID = int.Parse(ddlDir.SelectedValue); if (!decimal.TryParse(txtVol.Text, out totVol)) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Volume must be numeric!!."; return; } ast.CertifiedVolumeSale = totVol; if (!DateTime.TryParseExact(txtDate.Text, "dd/MM/yyyy", culture, DateTimeStyles.None, out sdate)) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Invalid date!!."; return; } ast.DateCertified = sdate; ast.CertifiedBy = usr.ID; ast.Status = (int)Utility.SalesStatus.Pending_Certified_Approval; //ast.RecoveryTypeID = int.Parse(ddlDir.SelectedValue); rst = GasSalesBLL.UpdateSalesData(ast); if (rst != false) { txtCap.Text = ""; txtDate.Text = ""; txtID.Text = ""; ddlDir.SelectedValue = ""; txtVol.Text = ""; BindGrid(DateTime.Now.AddDays(40)); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.Message); } }