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)
            {
            }
        }
Esempio n. 2
0
        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'>&times;</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'>&times;</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'>&times;</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'>&times;</button> An error occured. Kindly try again. If error persist contact Administrator!!.";
                    Utility.WriteError("Error: " + ex.InnerException);
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 4
0
 public static bool AddSalesData(GSS_SalesTbl byr)
 {
     try
     {
         using (BudgetCaptureDBEntities db = new BudgetCaptureDBEntities())
         {
             db.GSS_SalesTbl.Add(byr);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
Esempio n. 5
0
 public static bool DeleteGasSales(GSS_SalesTbl staff)
 {
     try
     {
         bool rst = false;
         using (var db = new BudgetCaptureDBEntities())
         {
             db.Entry(staff).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
             rst = true;
         }
         return(rst);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 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'>&times;</button> Record deleted successfully!!.";
             return;
         }
     }catch (Exception ex) {
     }
 }
Esempio n. 7
0
 public static bool UpdateSalesData(GSS_SalesTbl byr)
 {
     try
     {
         bool rst = false;
         using (var db = new BudgetCaptureDBEntities())
         {
             db.GSS_SalesTbl.Attach(byr);
             db.Entry(byr).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             rst = true;
         }
         return(rst);
     }
     catch (Exception ex)
     {
         //Utility.WriteError("Error Msg: " + ex.InnerException);
         throw 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'>&times;</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'>&times;</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'>&times;</button> Record updated successfully!!.";
                            return;
                        }
                    }

                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</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'>&times;</button> An error occured. Kindly try again. If error persist contact Administrator!!.";
                Utility.WriteError("Error: " + ex.Message);
            }
        }