Ejemplo n.º 1
0
        private void GenerateCheckListDoc()
        {
            lblLinkChkList1.Text = "";
            string registerFileNo = dbFileNoData.getFileNo("CRS");
            //string ChkFileName = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + "Rajendra.doc");
            string ChkFileName = "CRS_" + cmbVillage.SelectedValue.ToString() + "_" + cmbDocumentNo.SelectedValue.ToString() + "_" + registerFileNo + ".doc";

            Response.Clear();
            //Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
            Response.AddHeader("content-disposition", "attachment;filename=" + ChkFileName + "");
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/doc";
            System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);

            So1CheckList.RenderControl(htmlWrite);
            string       path    = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + ChkFileName);
            StreamWriter sWriter = new StreamWriter(path);

            //FileUpload FileChk = new FileUpload();
            //FileChk. = ChkFileName.ToString();

            sWriter.Write(stringWrite.ToString());
            sWriter.Close();


            //update MR File Number
            dbFileNoData.registername = "CRS";
            dbFileNoData.currentno    = Convert.ToInt32(registerFileNo) + 1;
            dbFileNoData.UpdateFileNo();
            lblLinkChkList1.Text = ChkFileName;

            //Insert in to Document Status
            string DocumentID = dbDocumentStatusData.getDocumentSeqNo();

            dbDocumentStatusData.documentid   = Convert.ToInt32(DocumentID);
            dbDocumentStatusData.villagecode  = cmbVillage.SelectedValue.ToString();
            dbDocumentStatusData.documentcode = "CRS";
            dbDocumentStatusData.documentname = ChkFileName;
            dbDocumentStatusData.documentpath = path;
            dbDocumentStatusData.createdby    = Session["UserName"].ToString();
            dbDocumentStatusData.createddate  = DateTime.Today;
            dbDocumentStatusData.docno        = cmbDocumentNo.SelectedValue.ToString();
            //Check For Record Exist
            dsDocumenteExists = dbDocumentStatusData.DocumentExistInDocStatus(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString(), "CRS", "SO2");
            if (dsDocumenteExists.Tables[0].Rows.Count == 0)
            {
                //string ModifiedSurveyNo = dbDocumentStatusData.surveyno;
                //dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", "");
                dbDocumentStatusData.surveyno      = "";
                dbDocumentStatusData.familyno      = "";
                dbDocumentStatusData.titlesearchno = "";
                dbDocumentStatusData.officename    = "SO2";
                bool DocInsert = dbDocumentStatusData.AddDocumentStatus();
            }
            else
            {
                bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentStatusFile();
                if (DocumentFileUpdate)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Check List Remark Not Uploaded');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Check List Remark updated');", true);
                }
            }

            Response.Write(stringWrite.ToString());
            Response.End();
        }
Ejemplo n.º 2
0
        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.DocumentExistInDocStatus(VillageCode, DocumentNo, DocType, "SO1");
                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();
                }
                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)
            {
            }
        }