protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();

        _Bill_Sys_invoice.Updateinvoicepaymnettransaction(txtChequeAmount.Text, txtpaymentdate.Text, txtChequeNumber.Text, txtDescription.Text, txtsoftwarepaymnetid.Text);
        string szinvoiceid = "";
        string ids         = txtTransInvoiceId.Text;

        string[] arrrInvoiceId = ids.Split(',');
        for (int i = 0; i < arrrInvoiceId.Length; i++)
        {
            if (szinvoiceid == "")
            {
                szinvoiceid = "'" + arrrInvoiceId[i].ToString() + "'";
            }
            else
            {
                szinvoiceid = szinvoiceid + "," + "'" + arrrInvoiceId[i].ToString() + "'";
            }
        }
        DataSet dspaymentamount = new DataSet();

        dspaymentamount = _Bill_Sys_invoice.GetInvoicepaymnetDetails(szinvoiceid);
        grdPaymentTransaction.DataSource = dspaymentamount;
        grdPaymentTransaction.DataBind();
        txtChequeNumber.Text = "";
        txtpaymentdate.Text  = "";
        txtChequeAmount.Text = "";
        txtDescription.Text  = "";
        ModalPopupExtender1.Show();
    }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["InvoiceID"] != null)
     {
         invoiceid = Request.QueryString["InvoiceID"].ToString();
         companyid = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID;
         Bill_Sys_invoice _Bill_Sys_Invoice_Generate = new Bill_Sys_invoice();
         DataSet          dsinvoice = _Bill_Sys_Invoice_Generate.GetInvoicegenerateDetails(invoiceid, companyid);
         grdinvoicegenerate.DataSource = dsinvoice;
         grdinvoicegenerate.DataBind();
     }
 }
    protected void btndelete_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string           szinvoicetransid;
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            for (int i = 0; i < grdInvoiceTransaction.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)grdInvoiceTransaction.Rows[i].FindControl("ChkDelete");
                if (chk.Checked == true)
                {
                    szinvoicetransid = grdInvoiceTransaction.DataKeys[i]["INVOICE_TRANS_ID"].ToString();
                    _Bill_Sys_invoice.deleteinvoiceTransaction(txtCompanyID.Text, szinvoicetransid);
                }
            }
            btninvoiceupdate.Enabled = false;
            ClearControl();
            grdInvoiceTransaction.XGridBindSearch();
            usrMessage.PutMessage("Invoice Transaction Deleted successfully");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string           sztotalpaymnetamount;
        string           szinvoiceid       = "";
        Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
        string           ids = txtTransInvoiceId.Text;

        string[]  arrrInvoiceId = ids.Split(',');
        ArrayList arrIds        = new ArrayList();

        for (int i = 0; i < arrrInvoiceId.Length; i++)
        {
            arrIds.Add(arrrInvoiceId[i].ToString());
            if (szinvoiceid == "")
            {
                szinvoiceid = "'" + arrrInvoiceId[i].ToString() + "'";
            }
            else
            {
                szinvoiceid = szinvoiceid + "," + "'" + arrrInvoiceId[i].ToString() + "'";
            }
        }
        hdnBal.Value         = lblBalance.Text;
        sztotalpaymnetamount = _Bill_Sys_invoice.Saveinvoicepaymenttransaction(txtChequeAmount.Text, txtChequeNumber.Text, txtDescription.Text, txtpaymentdate.Text, utxtUserId.Text, arrIds, txtCompanyID.Text, lblBalance.Text);
        string[] values              = sztotalpaymnetamount.Split(',');
        string   returnvalue         = values[0];
        string   szsoftwarepaymentid = values[1];

        txtsoftwarepaymnetid.Text = szsoftwarepaymentid;
        DataSet dspaymentamount = new DataSet();

        dspaymentamount = _Bill_Sys_invoice.GetInvoicepaymnetDetails(szinvoiceid);
        grdPaymentTransaction.DataSource = dspaymentamount;
        grdPaymentTransaction.DataBind();
        txtChequeNumber.Text = "";
        txtpaymentdate.Text  = "";
        txtChequeAmount.Text = "";
        txtDescription.Text  = "";
        ModalPopupExtender1.Show();
        grdInvoicegenerate.XGridBindSearch();
        grdPaymentTransaction.Visible = true;
    }
    protected void btnupdate_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string           sztransid         = txtinvoicetransid.Text;
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            _Bill_Sys_invoice.UpdateinvoiceTransaction(txtCompanyID.Text, sztransid, txttransactionname.Text, txttransactioncost.Value, ddltype.SelectedItem.ToString());
            ClearControl();
            grdInvoiceTransaction.XGridBindSearch();
            usrMessage.PutMessage("Invoice Transaction Update successfully");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
예제 #6
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string szreturn = "";
            hdnPOMValue.Value = "Yes";
            string szfilename   = "";
            string szBillno     = "";
            string sz_caseid    = "";
            string szRemoteAddr = Page.Request.ServerVariables["REMOTE_ADDR"].ToString();
            btnYes.Attributes.Add("onclick", "YesMassage");
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            ArrayList        arrinvoicebill    = new ArrayList();
            szfilename   = getFileName();
            sz_file_path = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_NAME + "/Comman Folder/";
            string  strBill       = "";
            DataSet dsinvoiceinfo = new DataSet();

            DataSet dsinvoicetransinfo = new DataSet();
            dsinvoicetransinfo = _Bill_Sys_invoice.GetInvoiceTransdetails(txtCompanyID.Text, "Software");
            double l = 0;

            for (int i = 0; i < grdInvoice.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)grdInvoice.Rows[i].FindControl("ChkDelete");
                if (chk.Checked == true)
                {
                    szBillno = grdInvoice.DataKeys[i]["SZ_BILL_NUMBER"].ToString();
                    arrinvoicebill.Add(szBillno);

                    if (strBill == "")
                    {
                        strBill = "'" + grdInvoice.DataKeys[i]["SZ_BILL_NUMBER"].ToString() + "'";
                    }
                    else
                    {
                        strBill = strBill + "," + "'" + grdInvoice.DataKeys[i]["SZ_BILL_NUMBER"].ToString() + "'";
                    }

                    if (i == 0)
                    {
                        l = Convert.ToDouble(dsinvoicetransinfo.Tables[0].Rows[0]["mn_cost"]);
                    }
                    else
                    {
                        l = l + Convert.ToDouble(dsinvoicetransinfo.Tables[0].Rows[0]["mn_cost"]);
                    }
                }
            }

            Bill_Sys_invoice _Bill_Sys_invoiceinfo = new Bill_Sys_invoice();
            dsinvoiceinfo = _Bill_Sys_invoiceinfo.GetInvoiceInfo(strBill);
            szreturn      = _Bill_Sys_invoice.Saveinvoice(txtCompanyID.Text, utxtUserId.Text, arrinvoicebill, sz_file_path, szfilename, l.ToString(), ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME, szRemoteAddr);
            if (szreturn == "fail")
            {
            }
            else
            {
                string[] values      = szreturn.Split(',');
                string   returnvalue = values[0];
                string   szinvoiceid = values[1];
                InvoiceTest(dsinvoiceinfo, szinvoiceid, sz_file_path, szfilename);
                grdInvoice.XGridBindSearch();
                usrMessage.PutMessage("Invoice Status Generated successfully");
                usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                usrMessage.Show();
            }
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
예제 #7
0
    protected void InvoiceTest(DataSet dsinvoiceinfo, string szinvoiceid, string szFilePath, string szFileName)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }

        try
        {
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();

            DataSet dsinvoicetransinfo = new DataSet();
            dsinvoicetransinfo = _Bill_Sys_invoice.GetInvoiceTransdetails(txtCompanyID.Text, "Software");

            DataSet dscompanyinfo = new DataSet();
            dscompanyinfo = _Bill_Sys_invoice.Getcompanydetails(txtCompanyID.Text);

            DataSet dscompanyaddrss = new DataSet();
            dscompanyaddrss = _Bill_Sys_invoice.Getcompanyaddress("Software");

            string                   strBill = "";
            string                   szfilename;
            MemoryStream             m        = new MemoryStream();
            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4, 36, 36, 20, 36);
            //create pdf
            float[]   widthbase = { 4f };
            PdfPTable tblBase   = new PdfPTable(widthbase);
            tblBase.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
            tblBase.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
            tblBase.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_TOP;
            tblBase.DefaultCell.Colspan             = 1;
            PdfWriter writer = PdfWriter.GetInstance(document, m);
            document.Open();

            float[]   width3   = { 4f };
            PdfPTable heading3 = new PdfPTable(width3);
            heading3.TotalWidth         = document.PageSize.Width - document.LeftMargin - document.RightMargin;
            heading3.DefaultCell.Border = Rectangle.NO_BORDER;
            heading3.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
            heading3.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_LEFT;
            heading3.DefaultCell.Colspan             = 1;


            tblBase.DefaultCell.Border = Rectangle.NO_BORDER;

            heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_INFO"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 12, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_ADDR"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_ZIP"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase("Phone : " + dscompanyaddrss.Tables[0].Rows[0]["SZ_PHONE_NO"].ToString() + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase("Tax Id : " + dscompanyaddrss.Tables[0].Rows[0]["SZ_TAX_ID"].ToString() + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));

            heading3.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
            heading3.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_RIGHT;

            heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_COMPANY_NAME"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 12, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_ADDRESS_STREET"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_COMPANY_ADD"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));

            tblBase.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
            heading3.AddCell(new Phrase(""));
            tblBase.AddCell(heading3);


            float[]   width2   = { 2f };
            PdfPTable heading2 = new PdfPTable(width2);
            heading2.TotalWidth         = document.PageSize.Width - document.LeftMargin - document.RightMargin;
            heading2.DefaultCell.Border = Rectangle.NO_BORDER;
            heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
            heading2.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE;
            tblBase.DefaultCell.Border = Rectangle.NO_BORDER;
            heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
            heading2.AddCell(new Phrase("Invoice Id : " + szinvoiceid + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            //heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
            //heading2.AddCell(new Phrase("Date : " + currentdate + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            tblBase.AddCell(heading2);


            float[]   width1   = { 1f, 3f, 2f, 3f, 3f, 2f };
            PdfPTable heading1 = new PdfPTable(width1);
            heading1.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

            heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
            heading1.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE;
            heading1.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_TOP;
            tblBase.DefaultCell.Border  = Rectangle.NO_BORDER;
            heading1.DefaultCell.Border = Rectangle.BOX;
            heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
            heading1.DefaultCell.BackgroundColor     = iTextSharp.text.Color.LIGHT_GRAY;
            heading1.AddCell(new Phrase("Bill Number", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.AddCell(new Phrase("Patient Name[Case No]", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.AddCell(new Phrase("Bill Date", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.AddCell(new Phrase("Date of Service", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.AddCell(new Phrase("Transaction Description", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.AddCell(new Phrase("Cost", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.DefaultCell.BackgroundColor = iTextSharp.text.Color.WHITE;



            int    j = 0;
            double n = 0;

            for (int i = 0; i < dsinvoiceinfo.Tables[0].Rows.Count; i++)
            {
                for (int k = 0; k < dsinvoicetransinfo.Tables[0].Rows.Count; k++)
                {
                    if (j >= 40)
                    {
                        #region New Page Code
                        j = 0;
                        tblBase.AddCell(heading1);
                        tblBase.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - document.TopMargin - heading2.TotalHeight - 1, writer.DirectContent);

                        tblBase            = new PdfPTable(widthbase);
                        tblBase.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
                        tblBase.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                        tblBase.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_TOP;
                        tblBase.DefaultCell.Colspan             = 1;

                        document.NewPage();
                        heading3                    = new PdfPTable(width3);
                        heading3.TotalWidth         = document.PageSize.Width - document.LeftMargin - document.RightMargin;
                        heading3.DefaultCell.Border = Rectangle.NO_BORDER;
                        heading3.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
                        heading3.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_LEFT;
                        tblBase.DefaultCell.Border = Rectangle.NO_BORDER;

                        heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_INFO"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 12, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_ADDR"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase(dscompanyaddrss.Tables[0].Rows[0]["SZ_COMPANY_ZIP"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase("Phone : " + dscompanyaddrss.Tables[0].Rows[0]["SZ_PHONE_NO"].ToString() + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase("Tax Id : " + dscompanyaddrss.Tables[0].Rows[0]["SZ_TAX_ID"].ToString() + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));


                        heading3.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
                        heading3.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_RIGHT;

                        heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_COMPANY_NAME"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 12, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_ADDRESS_STREET"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading3.AddCell(new Phrase(dscompanyinfo.Tables[0].Rows[0]["SZ_COMPANY_ADD"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));

                        tblBase.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
                        heading3.AddCell(new Phrase(""));
                        tblBase.AddCell(heading3);

                        heading2                    = new PdfPTable(width2);
                        heading2.TotalWidth         = document.PageSize.Width - document.LeftMargin - document.RightMargin;
                        heading2.DefaultCell.Border = Rectangle.NO_BORDER;
                        heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                        heading2.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE;
                        tblBase.DefaultCell.Border = Rectangle.NO_BORDER;
                        heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
                        heading2.AddCell(new Phrase("Invoice Id : " + szinvoiceid + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        //heading2.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
                        //heading2.AddCell(new Phrase("Date : " + currentdate + " ", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        tblBase.AddCell(heading2);

                        heading1            = new PdfPTable(width1);
                        heading1.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;

                        heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                        heading1.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE;
                        heading1.DefaultCell.VerticalAlignment   = iTextSharp.text.Element.ALIGN_TOP;
                        tblBase.DefaultCell.Border  = Rectangle.NO_BORDER;
                        heading1.DefaultCell.Border = Rectangle.BOX;
                        heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                        heading1.DefaultCell.BackgroundColor     = iTextSharp.text.Color.LIGHT_GRAY;
                        heading1.AddCell(new Phrase("Bill Number", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.AddCell(new Phrase("Patient Name[Case No]", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.AddCell(new Phrase("Bill Date", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.AddCell(new Phrase("Date of Service", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.AddCell(new Phrase("Transaction Description", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.AddCell(new Phrase("Cost", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
                        heading1.DefaultCell.BackgroundColor = iTextSharp.text.Color.WHITE;



                        #endregion
                    }
                    double sztotalcost = Convert.ToDouble(dsinvoicetransinfo.Tables[0].Rows[k]["mn_cost"]);
                    heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
                    heading1.AddCell(new Phrase(dsinvoiceinfo.Tables[0].Rows[i]["SZ_BILL_NUMBER"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));
                    heading1.AddCell(new Phrase(dsinvoiceinfo.Tables[0].Rows[i]["SZ_PATIENT_NAME"].ToString() + " " + "[" + dsinvoiceinfo.Tables[0].Rows[i]["SZ_CASE_NO"].ToString() + "]", iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));
                    heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                    heading1.AddCell(new Phrase(dsinvoiceinfo.Tables[0].Rows[i]["DT_BILL_DATE"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));
                    heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER;
                    heading1.AddCell(new Phrase(dsinvoiceinfo.Tables[0].Rows[i]["SZ_SERVICE_DATE"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));
                    heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
                    heading1.AddCell(new Phrase(dsinvoicetransinfo.Tables[0].Rows[k]["sz_transaction_desc"].ToString(), iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));
                    heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
                    heading1.AddCell(new Phrase(sztotalcost.ToString("0.00"), iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Color.BLACK)));


                    if (i == 0)
                    {
                        n = Convert.ToDouble(dsinvoicetransinfo.Tables[0].Rows[k]["mn_cost"]);
                    }
                    else
                    {
                        n = n + Convert.ToDouble(dsinvoicetransinfo.Tables[0].Rows[k]["mn_cost"]);
                    }

                    j++;
                }
            }
            heading1.DefaultCell.Border = Rectangle.NO_BORDER;
            heading1.AddCell(new Phrase(""));
            heading1.AddCell(new Phrase(""));
            heading1.AddCell(new Phrase(""));
            heading1.AddCell(new Phrase(""));
            heading1.DefaultCell.Border = Rectangle.RECTANGLE;
            heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT;
            heading1.AddCell(new Phrase("Total Software Cost", iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            heading1.DefaultCell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
            heading1.AddCell(new Phrase(n.ToString("0.00"), iTextSharp.text.FontFactory.GetFont("Arial", 8, Font.BOLD, iTextSharp.text.Color.BLACK)));
            tblBase.AddCell(heading1);

            tblBase.WriteSelectedRows(0, -1, document.LeftMargin, document.PageSize.Height - document.TopMargin - heading2.TotalHeight - 1, writer.DirectContent);
            document.Close();
            if (!Directory.Exists(ApplicationSettings.GetParameterValue("PhysicalBasePath") + szFilePath))
            {
                Directory.CreateDirectory(ApplicationSettings.GetParameterValue("PhysicalBasePath") + szFilePath);
            }
            //if (!Directory.Exists(sz_file_path))
            //    Directory.CreateDirectory(sz_file_path);
            string szSavePath = ApplicationSettings.GetParameterValue("PhysicalBasePath") + szFilePath + szFileName;
            string szOpenPath = ApplicationSettings.GetParameterValue("DocumentManagerURL") + szFilePath + szFileName;
            System.IO.File.WriteAllBytes(szSavePath, m.GetBuffer());
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "Done", "window.open('" + szOpenPath + "');", true);
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }
        finally
        {
        }


        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btninvoice_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }

        try
        {
            double           blTotalInvoiceAmount = 0;
            string           szinvoiceid          = "";
            Bill_Sys_invoice _Bill_Sys_invoice    = new Bill_Sys_invoice();
            ArrayList        arrInvoiceid         = new ArrayList();
            for (int i = 0; i < grdInvoicegenerate.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)grdInvoicegenerate.Rows[i].FindControl("ChkDelete");
                if (chk.Checked == true)
                {
                    if (szinvoiceid == "")
                    {
                        szinvoiceid          = grdInvoicegenerate.DataKeys[i]["i_invoice_id"].ToString();
                        Session["InvoiceID"] = szinvoiceid;
                    }
                    else
                    {
                        szinvoiceid = szinvoiceid + "," + grdInvoicegenerate.DataKeys[i]["i_invoice_id"].ToString();
                    }

                    blTotalInvoiceAmount = blTotalInvoiceAmount + (Convert.ToDouble(grdInvoicegenerate.DataKeys[i]["MN_INVOICE_AMOUNT"].ToString()));
                }
            }
            if (ddlsoftwarefee.SelectedItem.Text == "Paid")
            {
                DataSet dspaymentamount = new DataSet();
                dspaymentamount = _Bill_Sys_invoice.GetInvoicepaymnetDetails(szinvoiceid);
                grdPaymentTransaction.DataSource = dspaymentamount;
                grdPaymentTransaction.DataBind();
                btnSave.Enabled      = true;
                btnUpdate.Enabled    = false;
                txtChequeNumber.Text = "";
                txtpaymentdate.Text  = "";
                txtChequeAmount.Text = "";
                txtDescription.Text  = "";
            }
            else
            {
                txtChequeNumber.Text             = "";
                txtpaymentdate.Text              = "";
                txtChequeAmount.Text             = "";
                txtDescription.Text              = "";
                grdPaymentTransaction.DataSource = null;
                grdPaymentTransaction.DataBind();
                btnUpdate.Enabled = false;
                btnSave.Enabled   = true;
            }
            txtTransInvoiceId.Text = szinvoiceid;
            lblBalance.Text        = blTotalInvoiceAmount.ToString("0.00");
            sztotalamount.Text     = lblBalance.Text;
            hdnBal.Value           = lblBalance.Text;

            ModalPopupExtender1.Show();
            grdInvoicegenerate.XGridBindSearch();
            //usrMessage.PutMessage("Payment Status Update successfully");
            //usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            //usrMessage.Show();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnUploadFile_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }

        try
        {
            string           sz_file_path      = "";
            string           szfilename        = "";
            Bill_Sys_invoice objInvoice        = new Bill_Sys_invoice();
            DataSet          dsinvoiceid       = new DataSet();
            DataSet          dspaymentamount   = new DataSet();
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();


            FileUpload _FileUpload = new FileUpload();
            ArrayList  arr         = new ArrayList();


            if (!fuUploadReport.HasFile)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", " alert('please select file from upload Report !');showUploadFilePopup();", true);
                return;
            }

            dsinvoiceid = objInvoice.GetsoftwareInvoiceId(Session["payment_No"].ToString(), txtCompanyID.Text);


            string strBillNo  = "";
            string strCaseID  = "";
            string strsSpecID = "";
            sz_file_path = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_NAME + "/Comman Folder/";
            if (dsinvoiceid.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsinvoiceid.Tables[0].Rows.Count; i++)
                {
                    strBillNo  = dsinvoiceid.Tables[0].Rows[i][0].ToString();
                    strCaseID  = dsinvoiceid.Tables[0].Rows[i][1].ToString();
                    strsSpecID = dsinvoiceid.Tables[0].Rows[i][2].ToString();
                    Bill_Sys_SoftwareInVoice_UploadFile _objUploadFile = new Bill_Sys_SoftwareInVoice_UploadFile();

                    _objUploadFile.sz_bill_no    = strBillNo;
                    _objUploadFile.sz_case_id    = strCaseID;
                    _objUploadFile.sz_company_id = txtCompanyID.Text;
                    _objUploadFile.sz_FileName   = fuUploadReport.FileName;

                    _objUploadFile.sz_UserId     = ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID.ToString();
                    _objUploadFile.sz_UserName   = ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME.ToString();
                    _objUploadFile.sz_StatusCode = "";
                    _objUploadFile.sz_flag       = "PAY";

                    _objUploadFile.sz_payment_id    = Session["payment_No"].ToString();
                    _objUploadFile.sz_speciality_id = strsSpecID;

                    _objUploadFile.sz_File_PhysicalPath = sz_file_path;
                    arr.Add(_objUploadFile);
                }
            }

            _FileUpload.InvoiceUploadFile(arr);

            if (!Directory.Exists(ApplicationSettings.GetParameterValue("BASEPATH") + sz_file_path))
            {
                Directory.CreateDirectory(ApplicationSettings.GetParameterValue("BASEPATH") + sz_file_path);
            }
            fuUploadReport.SaveAs(ApplicationSettings.GetParameterValue("BASEPATH") + sz_file_path + fuUploadReport.FileName);


            dspaymentamount = _Bill_Sys_invoice.GetInvoicepaymnetDetails(Session["InvoiceID"].ToString());
            grdPaymentTransaction.DataSource = dspaymentamount;
            grdPaymentTransaction.DataBind();

            usrMessage.PutMessage("File Upload Successfully");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
            ModalPopupExtender1.Show();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btndelete_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string           szinvoiceidtype   = "";
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            for (int i = 0; i < grdInvoicegenerate.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)grdInvoicegenerate.Rows[i].FindControl("ChkDelete");
                if (chk.Checked == true)
                {
                    if (ddlsoftwarefee.SelectedItem.Text == "Paid")
                    {
                        if (szinvoiceidtype == "")
                        {
                            szinvoiceidtype = "'" + grdInvoicegenerate.DataKeys[i]["i_invoice_id"].ToString() + "'";
                        }
                        else
                        {
                            szinvoiceidtype = szinvoiceidtype + "," + "'" + grdInvoicegenerate.DataKeys[i]["i_invoice_id"].ToString() + "'";
                        }
                        usrMessage.PutMessage(szinvoiceidtype + " You Can not delete this Paid Invoice...");
                        usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                        usrMessage.Show();
                        //string sztype = grdInvoicegenerate.DataKeys[i]["PAID_STATUS"].ToString();
                    }
                    else
                    {
                        string szinvoiceid = grdInvoicegenerate.DataKeys[i]["i_invoice_id"].ToString();
                        _Bill_Sys_invoice.deletesoftwareinvoice(szinvoiceid, txtCompanyID.Text);
                        usrMessage.PutMessage("Deleted successfully ...");
                        usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                        usrMessage.Show();
                    }
                }
            }
            grdInvoicegenerate.XGridBindSearch();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnPaymentDelete_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }

        try
        {
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            for (int i = 0; i < grdPaymentTransaction.Items.Count; i++)
            {
                CheckBox chkDelete1 = (CheckBox)grdPaymentTransaction.Items[i].FindControl("chkDelete");
                if (chkDelete1.Checked)
                {
                    _Bill_Sys_invoice.deletesoftwarepaymentTransaction(grdPaymentTransaction.Items[i].Cells[1].Text, txtCompanyID.Text);
                }
            }
            usrMessage.PutMessage("Payment deleted successfully ...");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
            string    szinvoiceid   = "";
            string    ids           = txtTransInvoiceId.Text;
            string[]  arrrInvoiceId = ids.Split(',');
            ArrayList arrIds        = new ArrayList();
            for (int i = 0; i < arrrInvoiceId.Length; i++)
            {
                if (szinvoiceid == "")
                {
                    szinvoiceid = "'" + arrrInvoiceId[i].ToString() + "'";
                }
                else
                {
                    szinvoiceid = szinvoiceid + "," + "'" + arrrInvoiceId[i].ToString() + "'";
                }
            }

            DataSet dspaymentamount = new DataSet();
            dspaymentamount = _Bill_Sys_invoice.GetInvoicepaymnetDetails(szinvoiceid);
            grdPaymentTransaction.DataSource = dspaymentamount;
            grdPaymentTransaction.DataBind();
            txtChequeNumber.Text = "";
            txtpaymentdate.Text  = "";
            txtChequeAmount.Text = "";
            txtDescription.Text  = "";
            ModalPopupExtender1.Show();
            grdInvoicegenerate.XGridBindSearch();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string           sztotalpaymnetamount;
            string           szStorageinvoiceid = "";
            Bill_Sys_invoice _Bill_Sys_invoice  = new Bill_Sys_invoice();
            string           ids = txtTranstorageId.Text;
            string[]         arrrStorageInvoiceId = ids.Split(',');
            ArrayList        arrIds = new ArrayList();
            for (int i = 0; i < arrrStorageInvoiceId.Length; i++)
            {
                arrIds.Add(arrrStorageInvoiceId[i].ToString());
                if (szStorageinvoiceid == "")
                {
                    szStorageinvoiceid = "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
                else
                {
                    szStorageinvoiceid = szStorageinvoiceid + "," + "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
            }

            szbalance.Text       = lblBalance.Text;
            sztotalpaymnetamount = _Bill_Sys_invoice.Savestoragepaymenttransaction(txtChequeAmount.Text, txtChequeNumber.Text, txtDescription.Text, txtpaymentdate.Text, utxtUserId.Text, arrIds, txtCompanyID.Text, lblBalance.Text);
            string[] values             = sztotalpaymnetamount.Split(',');
            string   returnvalue        = values[0];
            string   szstoragepaymentid = values[1];
            txtstoragepaymnetid.Text = szstoragepaymentid;
            DataSet dspaymentamount = new DataSet();
            dspaymentamount = _Bill_Sys_invoice.GetStorageInvoicepaymnetDetails(szStorageinvoiceid);
            grdPaymentTransaction.DataSource = dspaymentamount;
            grdPaymentTransaction.DataBind();
            usrMessage.PutMessage("Your payment saved");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
            txtChequeNumber.Text = "";
            txtpaymentdate.Text  = "";
            txtChequeAmount.Text = "";
            txtDescription.Text  = "";

            ModalPopupExtender1.Show();
            grdStoragegenerate.XGridBindSearch();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }