Ejemplo n.º 1
0
 protected void GrdBillsCancelEdit(object sender, GridViewCancelEditEventArgs e)
 {
     GrdViewDetails.EditIndex = -1;
     if (Session["BillData"] != null)
     {
         GrdViewDetails.DataSource = (DataSet)Session["BillData"];
         GrdViewDetails.DataBind();
         checkPendingBills((DataSet)Session["BillData"]);
     }
 }
Ejemplo n.º 2
0
    protected void EditBill(object sender, GridViewEditEventArgs e)
    {
        GrdViewDetails.EditIndex = e.NewEditIndex;
        DataRow row = ((DataSet)Session["BillData"]).Tables[0].Rows[e.NewEditIndex];

        Session["EditedRow"]      = e.NewEditIndex.ToString();
        Session["EditedAmount"]   = row["Amount"].ToString();
        GrdViewDetails.DataSource = (DataSet)Session["BillData"];
        GrdViewDetails.DataBind();
    }
Ejemplo n.º 3
0
 protected void GrdViewDetails_RowUpdated(object sender, GridViewUpdatedEventArgs e)
 {
     try
     {
         System.Threading.Thread.Sleep(1000);
         GrdViewDetails.DataBind();
         lnkAddBills.Visible = true;
         //checkPendingBills();
     }
     catch (Exception ex)
     {
         TroyLiteExceptionManager.HandleException(ex);
     }
 }
Ejemplo n.º 4
0
 private void ClearPanel()
 {
     //txtRefNo.Text = "";
     //txtTransDate.Text = "";
     //txtNarration.Text = "";
     //txtChequeNo.Text = "";
     //txtAmount.Text = "";
     //ddledger.SelectedValue = "0";
     //txtMobile.Text = "";
     //ddBanks.SelectedValue = "0";
     GrdViewDetails.DataSource = null;
     GrdViewDetails.DataBind();
     Session["BillData"] = null;
 }
Ejemplo n.º 5
0
    protected void lnkAddBills_Click(object sender, EventArgs e)
    {
        try
        {
            pnlEdit.Visible = false;
            BusinessLogic bl   = new BusinessLogic();
            string        conn = GetConnectionString();
            ModalPopupExtender2.Show();
            pnlEdit.Visible = true;
            //if (txtAmount.Text == "")
            //{

            //    //ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Please enter the Receipt Amount before Adding BillNo')", true);
            //    //CnrfmDel.ConfirmText = "Please enter the Receipt Amount before Adding BillNo";
            //    //CnrfmDel.TargetControlID = "lnkAddBills";
            //    txtAmount.Focus();
            //    return;
            //}

            //if (ddledger.SelectedValue == "0")
            //{
            //    //ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Please Select the Customer before Adding Bills')", true);
            //    //pnlEdit.Visible = true;
            //    txtAmount.Focus();
            //    return;
            //}

            if (GrdViewDetails.Rows.Count == 0)
            {
                var ds = bl.GetReceivedAmountId(conn, 0);
                GrdViewDetails.DataSource = ds;
                GrdViewDetails.DataBind();
                GrdViewDetails.Rows[0].Visible = false;
                checkPendingBills(ds);
            }
            pnlEdit.Visible = true;
            GrdViewDetails.FooterRow.Visible = true;
            lnkAddBills.Visible = true;
            Session["RMode"]    = "Add";
            //lnkBtnAdd.Visible = false;
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Ejemplo n.º 6
0
    protected void GrdViewSales_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try

        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GridView gv = e.Row.FindControl("GrdViewDetails") as GridView;

                String BillNo = GrdViewSales.DataKeys[e.Row.RowIndex].Value.ToString();

                string connStr = string.Empty;

                if (Request.Cookies["Company"] != null)
                {
                    connStr = System.Configuration.ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString();
                }
                else
                {
                    Response.Redirect("~/Login.aspx");
                }

                BusinessLogic bl = new BusinessLogic();

                DataSet receivedData = bl.GetCustReceivedAmount(connStr, BillNo);

                Session["BillData"] = receivedData;


                if (receivedData.Tables[0].Rows.Count > 0)
                {
                    GrdViewDetails.DataSource = receivedData;
                    GrdViewDetails.DataBind();
                }
                else
                {
                }
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Ejemplo n.º 7
0
    protected void GrdViewDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DataSet ds;

        try
        {
            if (Session["BillData"] != null)
            {
                GridViewRow row = GrdViewDetails.Rows[e.RowIndex];
                ds = (DataSet)Session["BillData"];
                ds.Tables[0].Rows[GrdViewDetails.Rows[e.RowIndex].DataItemIndex].Delete();
                ds.Tables[0].AcceptChanges();
                GrdViewDetails.DataSource = ds;
                GrdViewDetails.DataBind();
                Session["BillData"] = ds;
                ModalPopupExtender2.Show();
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Ejemplo n.º 8
0
    protected void GrdViewDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Cancel")
            {
                GrdViewDetails.FooterRow.Visible = false;
                var ds = (DataSet)Session["BillData"];
                GrdViewDetails.EditIndex = -1;
                if (ds != null)
                {
                    GrdViewDetails.DataSource = ds;
                }
                GrdViewDetails.DataBind();
                lnkAddBills.Visible = true;
                ModalPopupExtender2.Show();
                pnlEdit.Visible = true;
                Error.Text      = "";
            }
            else if (e.CommandName == "Edit")
            {
                ModalPopupExtender2.Show();
                lnkAddBills.Visible = false;
            }
            else if (e.CommandName == "Insert")
            {
                try
                {
                    ModalPopupExtender2.Show();
                    DataTable     dt;
                    DataRow       drNew;
                    DataColumn    dc;
                    DataSet       ds;
                    BusinessLogic bl = new BusinessLogic(GetConnectionString());

                    string billNo     = ((TextBox)GrdViewDetails.FooterRow.FindControl("txtAddBillNo")).Text;
                    string amount     = ((TextBox)GrdViewDetails.FooterRow.FindControl("txtAddBillAmount")).Text;
                    string CustomerID = ddledger.SelectedValue.ToString().Trim();
                    string TransNo    = string.Empty;

                    //if (GrdViewReceipt.SelectedDataKey != null)
                    //    TransNo = GrdViewReceipt.SelectedDataKey.Value.ToString();
                    //else
                    TransNo = "";

                    //if (bl.GetIfBillNoExists(int.Parse(billNo), CustomerID) == 0)
                    //{
                    //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('BillNo does not Exists. Please check BillNo.')", true);
                    //    //Error.Text = "BillNo does not Exists. Please check BillNo.";
                    //    pnlEdit.Visible = true;
                    //    ModalPopupExtender2.Show();
                    //    return;
                    //}

                    //var isBillExists = CheckIfBillExists(billNo);

                    //if (isBillExists)
                    //{
                    //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('BillNo already Exists')", true);
                    //    //Error.Text = "BillNo already Exists";
                    //    ModalPopupExtender2.Show();
                    //    return;
                    //}


                    double eligibleAmount = bl.GetSalesPendingAmount(int.Parse(billNo));

                    if (double.Parse(amount) > eligibleAmount)
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('The Amount you entered for BillNo:" + billNo + " is Greater than Pending Sales Amount of " + eligibleAmount.ToString() + ". Please check the Bill Amount')", true);
                        //Error.Text = "The Amount you entered for BillNo:" + billNo + " is Greater than Pending Sales Amount of " + eligibleAmount.ToString() + ". Please check the Bill Amount";
                        ModalPopupExtender2.Show();
                        return;
                    }

                    if ((Session["BillData"] == null) || (((DataSet)Session["BillData"]).Tables[0].Rows.Count == 0))
                    {
                        //if (double.Parse(amount) > double.Parse(txtAmount.Text))
                        //{
                        //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount')", true);
                        //    //Error.Text = "Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount";
                        //    ModalPopupExtender2.Show();
                        //    return;
                        //}

                        ds = new DataSet();
                        dt = new DataTable();

                        dc = new DataColumn("ReceiptNo");
                        dt.Columns.Add(dc);

                        dc = new DataColumn("BillNo");
                        dt.Columns.Add(dc);

                        dc = new DataColumn("Amount");
                        dt.Columns.Add(dc);

                        ds.Tables.Add(dt);

                        drNew = dt.NewRow();

                        drNew["ReceiptNo"] = TransNo;
                        drNew["BillNo"]    = billNo;
                        drNew["Amount"]    = amount;

                        ds.Tables[0].Rows.Add(drNew);

                        Session["BillData"]       = ds;
                        GrdViewDetails.DataSource = ds;
                        GrdViewDetails.DataBind();
                        GrdViewDetails.EditIndex = -1;
                        lnkAddBills.Visible      = true;
                    }
                    else
                    {
                        ds = (DataSet)Session["BillData"];

                        //if ((calcDatasetSum(ds) + double.Parse(amount)) > double.Parse(txtAmount.Text))
                        //{
                        //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount')", true);
                        //    //Error.Text = "Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount";
                        //    ModalPopupExtender2.Show();
                        //    return;
                        //}

                        if (ds.Tables[0].Rows[0]["ReceiptNo"].ToString() == "0")
                        {
                            ds.Tables[0].Rows[0].Delete();
                            ds.Tables[0].AcceptChanges();
                        }

                        drNew = ds.Tables[0].NewRow();
                        drNew["ReceiptNo"] = TransNo;
                        drNew["BillNo"]    = billNo;
                        drNew["Amount"]    = amount;

                        ds.Tables[0].Rows.Add(drNew);
                        Session["BillData"] = ds;
                        //System.Threading.Thread.Sleep(1000);
                        GrdViewDetails.DataSource = ds;
                        GrdViewDetails.DataBind();
                        GrdViewDetails.EditIndex = -1;
                        lnkAddBills.Visible      = true;
                        ModalPopupExtender2.Show();
                        checkPendingBills(ds);
                    }

                    //}
                    //catch (Exception ex)
                    //{
                    //    if (ex.InnerException != null)
                    //    {
                    //        StringBuilder script = new StringBuilder();
                    //        script.Append("alert('Unit with this name already exists, Please try with a different name.');");

                    //        if (ex.InnerException.Message.IndexOf("duplicate values in the index") > -1)
                    //            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script.ToString(), true);

                    //        ModalPopupExtender2.Show();
                    //        return;
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    TroyLiteExceptionManager.HandleException(ex);
                }
                finally
                {
                    //checkPendingBills();
                }
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Ejemplo n.º 9
0
    protected void GrdViewDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            int    curRow = 0;
            string billNo = ((TextBox)GrdViewDetails.Rows[e.RowIndex].FindControl("txtBillNo")).Text;
            string amount = ((TextBox)GrdViewDetails.Rows[e.RowIndex].FindControl("txtBillAmount")).Text;
            //string Id = GrdBills.DataKeys[e.RowIndex].Value.ToString();
            string CustomerID = ddledger.SelectedValue.ToString().Trim();
            string TransNo    = "0";
            ModalPopupExtender2.Show();

            //if (GrdViewReceipt.SelectedDataKey != null)
            //    TransNo = GrdViewReceipt.SelectedDataKey.Value.ToString();


            DataSet ds = (DataSet)Session["BillData"];

            //if ((calcDatasetSum(ds) + double.Parse(amount) - double.Parse(Session["EditedAmount"].ToString())) > double.Parse(txtAmount.Text))
            //{
            //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount')", true);
            //    //Error.Text = "Total Bills amount is exceeding the Receipt Amount. Please check the Bill Amount";
            //    return;
            //}

            BusinessLogic bl = new BusinessLogic(GetConnectionString());

            //if (bl.GetIfBillNoExists(int.Parse(billNo), CustomerID) == 0)
            //{
            //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('BillNo does not Exists. Please check BillNo.')", true);
            //    //Error.Text = "BillNo does not Exists. Please check BillNo.";
            //    pnlEdit.Visible = true;
            //    ModalPopupExtender2.Show();
            //    return;
            //}

            double eligibleAmount = bl.GetSalesPendingAmount(int.Parse(billNo));


            if ((double.Parse(amount) - double.Parse(Session["EditedAmount"].ToString())) > eligibleAmount)
            {
                var eliAmount = double.Parse(Session["EditedAmount"].ToString()) + eligibleAmount;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('The Amount you entered for BillNo:" + billNo + " is Greater than Pending Sales Amount of " + eliAmount.ToString() + ". Please check the Bill Amount')", true);
                //Error.Text = "The Amount you entered for BillNo:" + billNo + " is Greater than Pending Sales Amount of " + eliAmount.ToString() + ". Please check the Bill Amount";
                return;
            }

            curRow = Convert.ToInt32(Session["EditedRow"].ToString());

            ds.Tables[0].Rows[curRow].BeginEdit();
            ds.Tables[0].Rows[curRow]["BillNo"]    = billNo;
            ds.Tables[0].Rows[curRow]["Amount"]    = amount;
            ds.Tables[0].Rows[curRow]["ReceiptNo"] = TransNo;

            var isBillExists = CheckNoOfBillExists(billNo);

            if (isBillExists > 1)
            {
                ds.Tables[0].Rows[curRow].RejectChanges();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('BillNo already Exists')", true);
                //Error.Text = "BillNo already Exists";
                return;
            }

            ds.Tables[0].Rows[curRow].EndEdit();

            ds.Tables[0].Rows[curRow].AcceptChanges();
            GrdViewDetails.DataSource = ds;
            GrdViewDetails.EditIndex  = -1;
            GrdViewDetails.DataBind();
            Session["BillData"] = ds;
            lnkAddBills.Visible = true;
            checkPendingBills(ds);
            ModalPopupExtender2.Show();
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }