Beispiel #1
0
 public void GetClientInfo()
 {
     try
     {
         BLAddInvoice blAddCl = new BLAddInvoice();
         string ClNm = drpdwnClientNm.SelectedItem.Text;
         if (drpdwnClientNm.SelectedItem.Text != "--Select--")
         {
             SqlDataReader dr = blAddCl.getClientInfo(ClNm);
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     string add = dr.GetString(0) + "\n" + dr.GetString(1) + "\n" + dr.GetString(2) + "\n" + dr.GetString(3) + "\n" + dr.GetString(4);
                     txtAddInvce.Text = add;
                     txtPanNo.Text = dr.GetString(5);
                     txtBillNo.Text = dr.GetString(6);
                 }
                 dr.Close();
             }
         }
         Session["ClNm"] = ClNm;
         Session["Add"] = txtAddInvce.Text;
         Session["PAN"] = txtPanNo.Text;
         Session["BillNo"] = txtBillNo.Text;
     }
     catch (Exception ex)
     {
         lblCatchError.Text = ex.Message.ToString();
     }
 }
Beispiel #2
0
 protected void ddlCliNm_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         BLAddInvoice blInv = new BLAddInvoice();
         string strClientName1 = Convert.ToString(ddlCliNm.SelectedItem.Text);
         SqlDataReader dr = blInv.getClIdByName(strClientName1);
         if (dr.HasRows)
         {
             dr.Read();
             lblCliId1.Text = dr.GetInt32(0).ToString();
         }
         dr.Close();
         fillgridService();
     }
     catch (Exception ex)
     {
         lblCatchError.Text = ex.Message.ToString();
     }
 }
Beispiel #3
0
 protected void SaveProjectDetail(int InvoiceId, int mode)
 {
     try
     {
         BLAddInvoice blgetIn = new BLAddInvoice();
         for (int i = 0; i < dtSelProject.Rows.Count; i++)
         {
             int projectid = int.Parse(dtSelProject.Rows[i].Field<string>(0));
             float proamt = float.Parse(dtSelProject.Rows[i].Field<string>(1));
             blgetIn.AddInvoiceDetail(InvoiceId, projectid, proamt);
         }
         for (int i = 0; i < dtUnselProject.Rows.Count; i++)
         {
             int ProjectId = int.Parse(dtUnselProject.Rows[i].Field<string>(0));
             blgetIn.DelProjectDetail(ProjectId);
         }
     }
     catch (Exception ex)
     {
         lblCatchError.Text = ex.Message.ToString();
     }
 }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                BLAddInvoice blAddCl = new BLAddInvoice();
                txtDtInvce.Text = System.DateTime.Now.ToShortDateString();
                if ((HttpContext.Current.Session["LoginId"]) == null)
                {
                    Response.Redirect("~/Login.aspx");
                }
                Session["SelectProject"] = 0;
                if (Page.IsPostBack)
                {
                    Session["dtgetselectedRecords"] = null;
                }
                SqlDataReader dr = blAddCl.getClientInvce();
                if (dr.HasRows == true)
                {
                    while (dr.Read())
                        drpdwnClientNm.Items.Add(dr.GetString(0));
                    drpdwnClientNm.Items.Insert(0, new ListItem("--Select--", "-1"));
                    dr.Close();
                }

                if (!Page.IsPostBack)
                {
                    if (Request.QueryString["Id"] == "1")
                    {
                        clnm = Session["ClNm"].ToString();
                        drpdwnClientNm.SelectedValue = clnm;
                        txtAddInvce.Text = Session["Add"].ToString();
                        txtPanNo.Text = Session["PAN"].ToString();
                        txtBillNo.Text = Session["BillNo"].ToString();
                        string amt = txtAmtAddInvce.Text.ToString();
                        Session["TotalAmount"] = amt;
                        string ClientName = drpdwnClientNm.SelectedValue.ToString();
                        Session["ClientName"] = ClientName;
                    }
                    DataTable dt = Session["dtgetselectedRecords"] as DataTable;
                    double amt1 = Convert.ToDouble(Session["amt"]);

                    if (dt != null)
                    {
                        GdVwAddInvce.DataSource = dt;
                        GdVwAddInvce.DataBind();
                    }
                    if (dt != null)
                    {
                        double amtNew = 0.0;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            amtNew += double.Parse(dt.Rows[i].Field<string>(4));
                        }
                        Session["addedamt"] = amtNew.ToString();
                        txtAmtAddInvce.Text = amtNew.ToString();
                    }

                    SelAllCheckbox();

                    if (Request.QueryString["InvoiceId"] != null)
                    {
                        InvoiceId = int.Parse(Request.QueryString["InvoiceId"]);
                        Session["InvoiceId"] = InvoiceId;
                        SqlDataReader drgetInv = blAddCl.getInvoiceForUpdate(InvoiceId);

                        if (drgetInv.HasRows == true)
                        {
                            while (drgetInv.Read())
                            {
                                DateTime indate = drgetInv.GetDateTime(2);
                                txtDtInvce.Text = indate.ToString("dd/MM/yyyy");
                                int ClId = drgetInv.GetInt32(3);
                                Session["ClId"] = ClId.ToString();
                                drpdwnClientNm.SelectedValue = Session["ClientName"].ToString();
                                GetClientInfo();
                                txtAmtAddInvce.Text = drgetInv.GetDecimal(4).ToString();
                                txtBillNo.Text = Session["InvoiceNo"].ToString();
                                txtRemrk.Text = drgetInv.GetString(7);
                                if (drgetInv.GetInt32(9) == 1)
                                    chkbxisDel.Checked = true;
                                else
                                    chkbxisDel.Checked = false;
                                if (drgetInv.GetInt32(10) == 1)
                                    chkbxAppInv.Checked = true;
                                else
                                    chkbxAppInv.Checked = false;
                            }
                            drgetInv.Close();
                        }
                        DataTable dtgetInvDet = blAddCl.GetInvoiceDetailForUpdate(InvoiceId);
                        GdVwAddInvce.DataSource = dtgetInvDet;
                        GdVwAddInvce.DataBind();
                        Session["dtgetselectedRecordsUpdate"] = dtgetInvDet;
                        SelAllCheckbox();
                    }
                }
                else
                {
                    lblCatchError.Text = "";
                    lblSelProjectMessage.Text = "";
                    lblResult.Text = "";
                }
                //if (!Page.IsPostBack)
                //{
                //    if (Request.QueryString["InvoiceId"] != null)
                //    {
                //        InvoiceId = int.Parse(Request.QueryString["InvoiceId"]);
                //        Session["InvoiceId"] = InvoiceId;
                //        SqlDataReader drgetInv = blAddCl.getInvoiceForUpdate(InvoiceId);

                //        //SqlDataReader dr = blAddCl.getClientInvce();
                //        //if (dr.HasRows == true)
                //        //{
                //        //    while (dr.Read())
                //        //        drpdwnClientNm.Items.Add(dr.GetString(0));
                //        //    drpdwnClientNm.Items.Insert(0, new ListItem("--Select--", "-1"));
                //        //    dr.Close();
                //        //}
                //        if (Request.QueryString["Id"] == "1")
                //        {
                //            clnm = Session["ClNm"].ToString();
                //            drpdwnClientNm.SelectedValue = clnm;
                //            txtAddInvce.Text = Session["Add"].ToString();
                //            txtPanNo.Text = Session["PAN"].ToString();
                //            txtBillNo.Text = Session["BillNo"].ToString();
                //            string amt = txtAmtAddInvce.Text.ToString();
                //            Session["TotalAmount"] = amt;
                //            string ClientName = drpdwnClientNm.SelectedValue.ToString();
                //            Session["ClientName"] = ClientName;
                //        }
                //        DataTable dt = Session["dtgetselectedRecords"] as DataTable;
                //        double amt1 = Convert.ToDouble(Session["amt"]);

                //        if (dt != null)
                //        {
                //            GdVwAddInvce.DataSource = dt;
                //            GdVwAddInvce.DataBind();

                //            double amtNew = 0.0;
                //            for (int i = 0; i < dt.Rows.Count; i++)
                //            {
                //                amtNew += double.Parse(dt.Rows[i].Field<string>(4));
                //            }
                //            Session["addedamt"] = amtNew.ToString();
                //            txtAmtAddInvce.Text = amtNew.ToString();
                //        }

                //        if (drgetInv.HasRows == true)
                //        {
                //            while (drgetInv.Read())
                //            {
                //                DateTime indate = drgetInv.GetDateTime(2);
                //                txtDtInvce.Text = indate.ToString("dd/MM/yyyy");
                //                int ClId = drgetInv.GetInt32(3);
                //                Session["ClId"] = ClId.ToString();
                //                drpdwnClientNm.SelectedValue = Session["ClientName"].ToString();
                //                GetClientInfo();
                //                txtAmtAddInvce.Text = drgetInv.GetDecimal(4).ToString();
                //                txtBillNo.Text = Session["InvoiceNo"].ToString();
                //                txtRemrk.Text = drgetInv.GetString(7);
                //                if (drgetInv.GetInt32(9) == 1)
                //                    chkbxisDel.Checked = true;
                //                else
                //                    chkbxisDel.Checked = false;
                //                if (drgetInv.GetInt32(10) == 1)
                //                    chkbxAppInv.Checked = true;
                //                else
                //                    chkbxAppInv.Checked = false;
                //            }
                //            drgetInv.Close();
                //        }
                //        DataTable dtgetInvDet = blAddCl.GetInvoiceDetailForUpdate(InvoiceId);
                //        GdVwAddInvce.DataSource = dtgetInvDet;
                //        GdVwAddInvce.DataBind();
                //        Session["dtgetselectedRecordsUpdate"] = dtgetInvDet;
                //    }
                //    SelAllCheckbox();
                //}
                //else
                //{
                //    //Session["dtgetselectedRecords"] = null;
                //    lblCatchError.Text = "";
                //    lblSelProjectMessage.Text = "";
                //    lblResult.Text = "";
                //}
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Beispiel #5
0
        protected void drpdwnClientNm_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int ClientId = 0;
                string ClNm = drpdwnClientNm.SelectedItem.Text;
                BLAddInvoice blAddCl = new BLAddInvoice();
                GetClientInfo();
                DataTable dtCleintDet = new DataTable();

                dtCleintDet.Columns.Add("Address");
                dtCleintDet.Columns.Add("PAN");
                dtCleintDet.Columns.Add("BillNo");
                string add = txtAddInvce.Text;
                string pan = txtPanNo.Text;
                string billno = txtBillNo.Text;
                dtCleintDet.Rows.Add(add, pan, billno);
                Session["ClNm"] = ClNm;
                Session["Add"] = txtAddInvce.Text;
                Session["PAN"] = txtPanNo.Text;
                Session["BillNo"] = txtBillNo.Text;

                SqlDataReader dr1 = blAddCl.getClIdByName(ClNm);
                if (dr1.HasRows)
                {
                    dr1.Read();
                    ClientId = dr1.GetInt32(0);
                    dr1.Close();
                }
                Session["ClId"] = ClientId;
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Beispiel #6
0
        protected void btnSvPrvInv_Click(object sender, EventArgs e)
        {
            int ClId = 0;

            try
            {
                // Session["InvoiceId"] = null;
                int mode = 0, Invoiceid = 0;
                BLAddInvoice blgetIn = new BLAddInvoice();
                SqlDataReader dr = blgetIn.GetInvoiceId1();
                if (dr.HasRows)
                {
                    dr.Read();
                    Invoiceid = dr.GetInt32(0);
                    dr.Close();
                }
                Invoiceid++;
                string InvoiceNo = Session["BillNo"] + Invoiceid.ToString();
                DateTime date = Convert.ToDateTime(txtDtInvce.Text);
                ClId = Convert.ToInt32(Session["ClId"]);
                decimal amt = decimal.Parse(txtAmtAddInvce.Text);
                decimal OtherChrge = Convert.ToDecimal(0);
                decimal TotAmt = Convert.ToDecimal(txtAmtAddInvce.Text);
                string remark = txtRemrk.Text;
                string status = "In Process";
                int isdel = 0;
                if (chkbxisDel.Checked)
                    isdel = 1;
                else
                    isdel = 0;
                int app = 0;
                if (chkbxAppInv.Checked)
                    app = 1;
                else
                    app = 0;
                if (GdVwAddInvce.Rows.Count == 0)
                {
                    lblSelProjectMessage.Text = "Please Select At Least One Project";
                }
                else
                {
                    fillSelUnselectedProjects();
                    int InvId;
                    if (Session["InvoiceId"] != null)
                    {
                        InvoiceNo = txtBillNo.Text;
                        InvId = int.Parse(Session["InvoiceId"].ToString());
                        mode = 1;

                        if (dtSelProject.Rows.Count == 0)
                        {
                            lblSelProjectMessage.Text = "Please Select At Least One Project";
                        }
                        else
                        {
                            blgetIn.AddInvoice(InvId, InvoiceNo, date, ClId, amt, OtherChrge, TotAmt, remark, status, isdel, app, mode);
                            SaveProjectDetail(InvId, mode);
                            HiddenFieldInvoiceId.Value = Convert.ToString(InvId);
                            lblResult.Visible = true;
                            lblResult.Text = "Invoice Details are Updated Successfully";
                            //ClientScript.RegisterStartupScript(this.GetType(), "newWindow", String.Format("<script>window.open('{0}');</script>", "Invoice.aspx?InvoiceID=" + InvId));
                            Generate_Invoice_and_Annexure();
                            //Session["InvoiceId"] = null;
                            clearfilelds();
                        }
                    }
                    else
                    {
                        if (dtSelProject.Rows.Count == 0)
                        {
                            lblSelProjectMessage.Text = "please select atleast one project";
                        }
                        else
                        {
                            blgetIn.AddInvoice(Invoiceid, InvoiceNo, date, ClId, amt, OtherChrge, TotAmt, remark, status, isdel, app, mode);
                            SaveProjectDetail(Invoiceid, mode);
                            HiddenFieldInvoiceId.Value = Convert.ToString(Invoiceid);
                            lblResult.Visible = true;
                            lblResult.Text = "Invoice Details are Added Successfully";
                            //ClientScript.RegisterStartupScript(this.GetType(), "newWindow", String.Format("<script>window.open('{0}');</script>", "Invoice.aspx?InvoiceID=" + Invoiceid));
                            Generate_Invoice_and_Annexure();
                            clearfilelds();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
            string amount = txtAmtAddInvce.Text;
            decimal TotAmt1 = Convert.ToDecimal(txtAmtAddInvce.Text);
        }