Пример #1
0
    protected void btnUploadFile_Click(object sender, EventArgs e)
    {//Logging Start
        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());
        }

        Bill_Sys_NF3_Template objNF3Template = new Bill_Sys_NF3_Template();
        Boolean flag       = false;
        Boolean updateflag = false;
        string  ImgId      = "";

        try
        {
            if (rdbpombills.SelectedValue == "0")
            {
                if (!fuUploadReport.HasFile)
                {
                    Page.RegisterStartupScript("ss", "<script language='javascript'> alert('please select file from upload Report !');showUploadFilePopup();</script>");
                    return;
                }
                String szDefaultPath    = objNF3Template.getPhysicalPath();
                int    ImageId          = 0;
                String szDestinationDir = "";

                //  szDestinationDir = objNF3Template.GetCompanyName(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                DataSet ds = objNF3Template.GetPomCaseId(Session["UPLOADPOMID"].ToString(), ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    String sz_Case_Id = ds.Tables[0].Rows[i]["SZ_CASE_ID"].ToString();
                    string szSpecID   = ds.Tables[0].Rows[i]["sz_speciality_id"].ToString();

                    _obj = new Bill_Sys_BillTransaction_BO();
                    string szNodeType = _obj.GetNodeType(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID, szSpecID, sz_Case_Id);
                    string NodeId     = _obj.GetNodeIDMST_Nodes(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID, szNodeType);
                    RequiredDocuments.Bill_Sys_RequiredDocumentBO bo = new RequiredDocuments.Bill_Sys_RequiredDocumentBO();
                    //   string szNodePath = bo.GetNodePath(NodeId, sz_Case_Id, ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    szDestinationDir = "";
                    szDestinationDir = objNF3Template.GetCompanyName(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    szDestinationDir = szDestinationDir + "\\POM receive\\" + Session["UPLOADPOMID"].ToString() + "\\";
                    szDestinationDir = szDestinationDir.Replace("\\", "/");
                    strLinkPath      = szDestinationDir + fuUploadReport.FileName;
                    if (!updateflag)
                    {
                        if (!Directory.Exists(szDefaultPath + szDestinationDir))
                        {
                            Directory.CreateDirectory(szDefaultPath + szDestinationDir);
                        }
                        fuUploadReport.SaveAs(szDefaultPath + szDestinationDir + fuUploadReport.FileName);
                        updateflag = true;
                    }

                    // Start : Save report under document manager.

                    ArrayList objAL = new ArrayList();

                    objAL.Add(sz_Case_Id);
                    objAL.Add("");
                    objAL.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);

                    objAL.Add(fuUploadReport.FileName);
                    objAL.Add(szDestinationDir);
                    objAL.Add(((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME.ToString());
                    objAL.Add(NodeId);

                    ImgId = objNF3Template.SaveDocumentData(objAL);


                    // End :   Save report under document manager.
                    if (!flag)
                    {
                        if (Session["POMSTATUS"].ToString().Equals("1"))
                        {
                            objNF3Template.UpdateReportPomPath(fuUploadReport.FileName, szDestinationDir, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Session["UPLOADPOMID"].ToString(), ImgId, "VPOMR");
                        }
                        else
                        {
                            objNF3Template.UpdateReportPomPath(fuUploadReport.FileName, szDestinationDir, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Session["UPLOADPOMID"].ToString(), ImgId, "POM");
                        }
                        flag = true;
                    }
                }

                // End :   Save report under document manager.


                usrMessage.PutMessage("File Upload Successfully");
                usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                usrMessage.Show();

                //fillControl();

                fillControl();
                this.con.SourceGrid              = grdPomReport;
                this.txtSearchBox.SourceGrid     = grdPomReport;
                this.grdPomReport.Page           = this.Page;
                this.grdPomReport.PageNumberList = this.con;
                grdPomReport.XGridKey            = "Report_pom";
                grdPomReport.XGridBindSearch();
            }
            else
            {
                _objReport = new Bill_Sys_ReportBO();
                if (!fuUploadReport.HasFile)
                {
                    Page.RegisterStartupScript("ss", "<script language='javascript'> alert('please select file from upload Report !');showUploadFilePopup();</script>");
                    return;
                }
                String  szDefaultPath    = objNF3Template.getPhysicalPath();
                int     ImageId          = 0;
                String  szDestinationDir = "";
                DataSet dspomother       = new DataSet();
                //  szDestinationDir = objNF3Template.GetCompanyName(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                dspomother = _objReport.GetPomotherCaseId(Session["UPLOADPOMID"].ToString(), ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);

                for (int i = 0; i < dspomother.Tables[0].Rows.Count; i++)
                {
                    String sz_Case_Id = dspomother.Tables[0].Rows[i]["SZ_CASE_ID"].ToString();
                    string szSpecID   = dspomother.Tables[0].Rows[i]["sz_speciality_id"].ToString();

                    _obj = new Bill_Sys_BillTransaction_BO();
                    string szNodeType = _obj.GetNodeType(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID, szSpecID, sz_Case_Id);
                    string NodeId     = _obj.GetNodeIDMST_Nodes(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID, szNodeType);
                    RequiredDocuments.Bill_Sys_RequiredDocumentBO bo = new RequiredDocuments.Bill_Sys_RequiredDocumentBO();
                    //   string szNodePath = bo.GetNodePath(NodeId, sz_Case_Id, ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    szDestinationDir = "";
                    szDestinationDir = objNF3Template.GetCompanyName(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    szDestinationDir = szDestinationDir + "\\POM receive\\" + Session["UPLOADPOMID"].ToString() + "\\";
                    szDestinationDir = szDestinationDir.Replace("\\", "/");
                    strLinkPath      = szDestinationDir + fuUploadReport.FileName;
                    if (!updateflag)
                    {
                        if (!Directory.Exists(szDefaultPath + szDestinationDir))
                        {
                            Directory.CreateDirectory(szDefaultPath + szDestinationDir);
                        }
                        fuUploadReport.SaveAs(szDefaultPath + szDestinationDir + fuUploadReport.FileName);
                        updateflag = true;
                    }

                    // Start : Save report under document manager.

                    ArrayList objAL = new ArrayList();

                    objAL.Add(sz_Case_Id);
                    objAL.Add("");
                    objAL.Add(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);

                    objAL.Add(fuUploadReport.FileName);
                    objAL.Add(szDestinationDir);
                    objAL.Add(((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME.ToString());
                    objAL.Add(NodeId);

                    ImgId = objNF3Template.SaveDocumentData(objAL);


                    // End :   Save report under document manager.
                    if (!flag)
                    {
                        if (Session["POMSTATUS"].ToString().Equals("1"))
                        {
                            _objReport.UpdateReportPomOtherPath(fuUploadReport.FileName, szDestinationDir, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Session["UPLOADPOMID"].ToString(), ImgId, "VPOMR");
                        }
                        else
                        {
                            _objReport.UpdateReportPomOtherPath(fuUploadReport.FileName, szDestinationDir, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Session["UPLOADPOMID"].ToString(), ImgId, "POM");
                        }
                        flag = true;
                    }
                }

                // End :   Save report under document manager.


                usrMessage.PutMessage("File Upload Successfully");
                usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                usrMessage.Show();

                fillControl();
                this.con.SourceGrid              = grdPomReport;
                this.txtSearchBox.SourceGrid     = grdPomReport;
                this.grdPomReport.Page           = this.Page;
                this.grdPomReport.PageNumberList = this.con;
                grdPomReport.XGridKey            = "Report_Pom_Other";
                grdPomReport.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());
        }
    }