Ejemplo n.º 1
0
        //private void DisableControls(System.Web.UI.Control control)
        //{
        //    foreach (System.Web.UI.Control c in control.Controls)
        //    {
        //        // Get the Enabled property by reflection.
        //        Type type = c.GetType();
        //        PropertyInfo prop = type.GetProperty("Enabled");

        //        // Set it to False to disable the control.
        //        if (prop != null)
        //        {
        //            prop.SetValue(c, false, null);
        //        }

        //        // Recurse into child controls.
        //        if (c.Controls.Count > 0)
        //        {
        //            this.DisableControls(c);
        //        }
        //    }
        //}
        //

        private void GenerateFileName(string DocType, FileUpload FControlName, LinkButton LinkDoc)
        {
            try
            {
                string registerFileNo = dbFileNoData.getFileNo(DocType);
                string filename       = Path.GetFileName(FControlName.FileName);
                string fileExtension  = System.IO.Path.GetExtension(FControlName.PostedFile.FileName);
                string VillageCode    = cmbVillage.SelectedValue.ToString();
                string DocumentNo     = cmbDocumentNo.SelectedValue.ToString();
                string NewFileName    = DocType + "_" + VillageCode + "_" + DocumentNo + "_" + registerFileNo + fileExtension;
                string folderName     = Server.MapPath("~/Documents/" + VillageCode + "/");
                if (!Directory.Exists(folderName))
                {
                    Directory.CreateDirectory(folderName);
                }
                FControlName.SaveAs(folderName + NewFileName);
                //update MR File Number
                dbFileNoData.registername = DocType;
                dbFileNoData.currentno    = Convert.ToInt32(registerFileNo) + 1;
                dbFileNoData.UpdateFileNo();
                LinkDoc.Text = NewFileName;
                string FinalPath = folderName + NewFileName;
                ViewState["filepath"] = FinalPath;

                //Insert in to Document Status
                string DocumentID = dbDocumentStatusData.getDocumentSeqNo();
                dbDocumentStatusData.documentid   = Convert.ToInt32(DocumentID);
                dbDocumentStatusData.villagecode  = VillageCode;
                dbDocumentStatusData.documentcode = DocType;
                dbDocumentStatusData.documentname = NewFileName;
                dbDocumentStatusData.documentpath = ViewState["filepath"].ToString();
                dbDocumentStatusData.createdby    = Session["UserName"].ToString();
                dbDocumentStatusData.createddate  = DateTime.Today;
                dbDocumentStatusData.docno        = DocumentNo;
                //Check For Record Exist
                dsDocumenteExists = dbDocumentStatusData.DocumentExistRO(VillageCode, DocumentNo, DocType);
                if (dsDocumenteExists.Tables[0].Rows.Count == 0)
                {
                    //string ModifiedSurveyNo = dbDocumentStatusData.surveyno;
                    //dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", "");
                    dbDocumentStatusData.surveyno      = "";
                    dbDocumentStatusData.familyno      = "";
                    dbDocumentStatusData.titlesearchno = "";
                    dbDocumentStatusData.officename    = "HO";
                    bool DocInsert = dbDocumentStatusData.AddDocumentStatus();
                }
                else
                {
                    bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentStatusFile();
                    if (DocumentFileUpdate)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('New File Not Uploaded');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('New File updated');", true);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string filePath = Server.MapPath("~/Documents/");

                int cellNo = 0;
                if (lblIteration1.Text == "1" && lblIteration2.Text == "" && lblIteration3.Text == "")
                {
                    cellNo = 0;
                }
                else if (lblIteration1.Text == "1" && lblIteration2.Text == "2" && lblIteration3.Text == "")
                {
                    cellNo = 1;
                }
                else if (lblIteration1.Text == "1" && lblIteration2.Text == "2" && lblIteration3.Text == "3")
                {
                    cellNo = 2;
                }

                for (int i = 0; i < grdDocument.Rows.Count; i++)
                {
                    string villagecode   = grdDocument.DataKeys[i].Values[0].ToString();
                    string docno         = grdDocument.DataKeys[i].Values[1].ToString();
                    string documentcode  = grdDocument.DataKeys[i].Values[2].ToString();
                    string uploaddoccode = grdDocument.DataKeys[i].Values[3].ToString();

                    RadioButtonList rblApproval   = (RadioButtonList)grdDocument.Rows[i].Cells[cellNo].FindControl("rblApproval" + cellNo.ToString());
                    FileUpload      fuQueryUpload = (FileUpload)grdDocument.Rows[i].Cells[cellNo].FindControl("fuQueryUpload" + cellNo.ToString());

                    string action = rblApproval.ToolTip.ToString();
                    string filename = "", folderPath = filePath + villagecode + "\\";

                    if (action.Contains("query"))
                    {
                        if (fuQueryUpload.HasFile)
                        {
                            //"FR_40_17_12.sql"
                            string sSystemFileName = Path.GetFileName(fuQueryUpload.PostedFile.FileName);
                            string sFileExtention  = Path.GetExtension(sSystemFileName);

                            filename = uploaddoccode + "_" + villagecode + "_" + docno + "_" + "1" + sFileExtention;

                            string ValidExtensions = ".pdf,.xls,.xlsx,.doc,.docx,";
                            if (ValidExtensions.ToLower().Contains(sFileExtention.Trim().ToLower() + ","))
                            {
                                if (!Directory.Exists(folderPath))
                                {
                                    Directory.CreateDirectory(folderPath);
                                }

                                {
                                    fuQueryUpload.SaveAs(folderPath + filename);
                                }
                            }
                        }
                    }
                    bool bValid = false;
                    dbDocStatus.villagecode  = villagecode;
                    dbDocStatus.docno        = docno;
                    dbDocStatus.documentcode = documentcode;
                    dbDocStatus.type         = action;

                    if (action == "query" && !string.IsNullOrEmpty(filename))
                    {
                        string DocumentID = dbDocumentStatusData.getDocumentSeqNo();
                        dbDocStatus.documentid        = Convert.ToInt32(DocumentID);
                        dbDocStatus.documentname      = filename;
                        dbDocStatus.solicitorapproval = rblApproval.SelectedValue;
                        dbDocStatus.solicitorappdate  = DateTime.Today;
                        dbDocStatus.documentpath      = folderPath + filename;
                        dbDocStatus.createdby         = "RSD";
                        dbDocStatus.createddate       = DateTime.Today;
                        dbDocStatus.documentcode      = uploaddoccode;

                        bValid = dbDocStatus.UpdateDocumentStatus();
                    }
                    if (action == "approval")
                    {
                        dbDocStatus.solicitorapproval = rblApproval.SelectedValue;
                        dbDocStatus.solicitorappdate  = DateTime.Today;
                        bValid = dbDocStatus.UpdateDocumentStatus();
                    }
                }

                ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "alert('Record Inserted Successfully');", true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        private bool InsertDocumentStatus(string DocType, string fileName)
        {
            if (txtDocNo.Text.Length < 3)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please Enter Document Number');", true);
                return(false);
            }
            //else if (cmbFamily.SelectedIndex < 0)
            //{
            //    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please Select family number');", true);
            //    return false;
            //}
            else if (cmbVillage.SelectedIndex < 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Village');", true);
                return(false);
            }
            else
            {
                string DocumentID = dbDocumentStatusData.getDocumentSeqNo();
                dbDocumentStatusData.documentid  = Convert.ToInt32(DocumentID);
                dbDocumentStatusData.villagecode = cmbVillage.SelectedValue.ToString().Trim();
                dbDocumentStatusData.familyno    = cmbFamily.SelectedValue.ToString().Trim();
                dbDocumentStatusData.surveyno    = selectedListItems();
                //Check Existing Title Search Exist
                //dsDocumenttitleSearch = dbDocumentStatusData.DocumentTitleExist(cmbVillage.SelectedValue.ToString().Trim(), cmbFamily.SelectedValue.ToString().Trim(), cmbFamilySurvey.SelectedValue.ToString().Trim());
                dsDocumenttitleSearch = dbDocumentStatusData.DocumentTitleExist(cmbVillage.SelectedValue.ToString().Trim(), cmbFamilyDocNo.SelectedValue.ToString().Trim(), selectedListItems());
                if (dsDocumenttitleSearch.Tables[0].Rows.Count > 0)
                {
                    dbDocumentStatusData.titlesearchno = dsDocumenttitleSearch.Tables[0].Rows[0]["titlesearchno"].ToString();
                }
                else
                {
                    dbDocumentStatusData.titlesearchno = txtDocNo.Text.ToString();
                }

                ///

                dbDocumentStatusData.documentcode = DocType;
                dbDocumentStatusData.documentname = fileName;
                dbDocumentStatusData.documentpath = ViewState["filepath"].ToString();
                dbDocumentStatusData.createdby    = "RSD";
                dbDocumentStatusData.createddate  = DateTime.Today;
                dbDocumentStatusData.docno        = cmbFamilyDocNo.SelectedValue.ToString().Trim();
                //Check For Record Exist
                dsDocumentexists = dbDocumentStatusData.DocumentExist(cmbVillage.SelectedValue.ToString().Trim(), cmbFamilyDocNo.SelectedValue.ToString().Trim(), selectedListItems(), DocType);
                if (dsDocumentexists.Tables[0].Rows.Count == 0)
                {
                    string ModifiedSurveyNo = dbDocumentStatusData.surveyno;
                    dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", "");
                    bool DocInsert = dbDocumentStatusData.AddDocumentStatus();
                }
                else
                {
                    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('File Already exist now updating');", true);
                    // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "element.onclick = function(){ return confirm('Are you sure you want to delete?'); };",true);
                    bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentFile(selectedListItems());
                    if (DocumentFileUpdate)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('New File updated');", true);
                    }
                }
                return(true);
            }
        }
Ejemplo n.º 4
0
        protected void btnGenerateReport_Click(object sender, EventArgs e)
        {
            //Syncfusion PDF
            Syncfusion.Pdf.PdfDocument[] documents = new Syncfusion.Pdf.PdfDocument[10];
            string[] allPDFDocument = new string[10];

            List <string>     listPDF   = new List <string>();
            DocToPDFConverter converter = new DocToPDFConverter();

            dsShowAllDocData = dbFamilyDetailsData.getSOOfficeDocument(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString());
            if (dsShowAllDocData.Tables[0].Rows.Count > 0)
            {
                int i = 0;
                foreach (DataRow rows in dsShowAllDocData.Tables[0].Rows)
                {
                    string DocFileName = rows["docfile"].ToString();
                    if (DocFileName != "" && !string.IsNullOrEmpty(DocFileName))
                    {
                        string FileExist = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName);
                        if (File.Exists(FileExist))
                        {
                            string fileextension = Path.GetExtension(FileExist.ToString());
                            switch (fileextension)
                            {
                            case ".docx":
                                WordDocument wordDocumentdocx = new WordDocument(FileExist, FormatType.Docx);
                                string       FolderNameDocx   = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/");
                                if (!Directory.Exists(FolderNameDocx))
                                {
                                    Directory.CreateDirectory(FolderNameDocx);
                                }
                                documents[i] = converter.ConvertToPDF(wordDocumentdocx);
                                string genfilenameDocx = wordDocumentdocx + "_" + i;
                                //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text));
                                documents[i].Save(FolderNameDocx + genfilenameDocx + ".pdf");
                                allPDFDocument[i] = FolderNameDocx + genfilenameDocx + ".pdf";
                                //documents[i].Save(@"F:\\DocToPDF1.pdf");
                                listPDF.Add(FolderNameDocx + genfilenameDocx + ".pdf");
                                break;

                            //RSD
                            case ".doc":
                                WordDocument wordDocumentDoc = new WordDocument(FileExist, FormatType.Doc);
                                string       FolderNameDoc   = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/");
                                if (!Directory.Exists(FolderNameDoc))
                                {
                                    Directory.CreateDirectory(FolderNameDoc);
                                }
                                documents[i] = converter.ConvertToPDF(wordDocumentDoc);
                                string genfilenameDoc = wordDocumentDoc + "_" + i;
                                //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text));
                                documents[i].Save(FolderNameDoc + genfilenameDoc + ".pdf");
                                allPDFDocument[i] = FolderNameDoc + genfilenameDoc + ".pdf";
                                //documents[i].Save(@"F:\\DocToPDF1.pdf");
                                listPDF.Add(FolderNameDoc + genfilenameDoc + ".pdf");
                                break;

                            case ".pdf":

                                string FolderNamePDF = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName);
                                if (!File.Exists(FolderNamePDF))
                                {
                                    //Directory.CreateDirectory(FolderNameDoc);
                                }
                                else
                                {
                                    //listPDF.Add(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + FileExist + ".pdg");
                                    listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName));
                                }


                                break;
                            }
                        }
                    }
                    i = i + 1;
                }//FOr End

                //Get All 7/12 File
                DataSet       dsGet712Files  = new DataSet();
                List <string> listPDF712File = new List <string>();
                dsGet712Files = dbFamilyDetailsData.Get712files(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString());
                if (dsGet712Files.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow rows in dsGet712Files.Tables[0].Rows)
                    {
                        string PDFFileName712 = rows["pdffilename"].ToString();
                        if (PDFFileName712 != "" && !string.IsNullOrEmpty(PDFFileName712))
                        {
                            string FileExist = Server.MapPath(@"~/7-12PDF/" + PDFFileName712 + ".pdf");
                            if (File.Exists(FileExist))
                            {
                                listPDF712File.Add(FileExist);
                            }
                        }
                    }
                    //Create 712 PDF FIle One
                    Syncfusion.Pdf.PdfDocument PDFFile712 = new Syncfusion.Pdf.PdfDocument();

                    //Syncfusion.Pdf.PdfDocumentBase.Merge(PDFFile712, listPDFArray712);

                    //listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName));
                }


                //End 712file

                Syncfusion.Pdf.PdfDocument newPdf1 = new Syncfusion.Pdf.PdfDocument();
                //DocToPDFConverter converter2 = new DocToPDFConverter();

                string[] listPDFArray    = listPDF.ToArray();
                string[] listPDFArray712 = listPDF712File.ToArray();
                Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray);
                Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray712);
                //newPdf1.Save(@"F:\\newPDFRSD.pdf");
                //newPdf1.Close(true);

                try
                {
                    string registerFileNo = dbFileNoData.getFileNo("PTS");
                    //string filename = Path.GetFileName(FControlName.FileName);
                    string fileExtension = ".pdf";
                    string VillageCode   = cmbVillage.SelectedValue.ToString();
                    string DocumentNo    = cmbDocumentNo.SelectedValue.ToString();
                    string NewFileName   = "PTS" + "_" + VillageCode + "_" + DocumentNo + "_" + registerFileNo + fileExtension;
                    string folderName    = Server.MapPath("~/Documents/" + VillageCode + "/");
                    if (!Directory.Exists(folderName))
                    {
                        Directory.CreateDirectory(folderName);
                    }
                    newPdf1.Save(folderName + NewFileName);
                    newPdf1.Close(true);
                    //  FControlName.SaveAs(folderName + NewFileName);

                    dbFileNoData.registername = "PTS";
                    dbFileNoData.currentno    = Convert.ToInt32(registerFileNo) + 1;
                    dbFileNoData.UpdateFileNo();
                    lbllnkTS.Text = NewFileName;
                    string FinalPath = folderName + NewFileName;
                    ViewState["filepath"] = FinalPath;

                    //Insert in to Document Status
                    string DocumentID = dbDocumentStatusData.getDocumentSeqNo();
                    dbDocumentStatusData.documentid   = Convert.ToInt32(DocumentID);
                    dbDocumentStatusData.villagecode  = cmbVillage.SelectedValue.ToString();
                    dbDocumentStatusData.documentcode = "PTS";
                    dbDocumentStatusData.documentname = NewFileName;
                    dbDocumentStatusData.documentpath = ViewState["filepath"].ToString();
                    dbDocumentStatusData.createdby    = Session["UserName"].ToString();
                    dbDocumentStatusData.createddate  = DateTime.Today;
                    dbDocumentStatusData.docno        = cmbDocumentNo.SelectedValue.ToString();
                    //Check For Record Exist
                    dsDocumenteExists = dbDocumentStatusData.DocumentExistRO(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString(), "PTS");
                    if (dsDocumenteExists.Tables[0].Rows.Count == 0)
                    {
                        //string ModifiedSurveyNo = dbDocumentStatusData.surveyno;
                        //dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", "");
                        dbDocumentStatusData.surveyno      = "";
                        dbDocumentStatusData.familyno      = "";
                        dbDocumentStatusData.titlesearchno = "";
                        dbDocumentStatusData.officename    = "SO1";
                        bool DocInsert = dbDocumentStatusData.AddDocumentStatus();
                        if (DocInsert)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Not Uploaded');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Uploaded');", true);
                            SendSMS("5");
                        }
                    }
                    else
                    {
                        bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentStatusFile();
                        if (DocumentFileUpdate)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report Not Uploaded');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Update');", true);
                            SendSMS("5");
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }