Ejemplo n.º 1
0
 private bool InsertDocumentStatus(string DocType, string fileName)
 {
     if (cmbDocumentNo.SelectedIndex < 0)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please Select Document Number');", true);
         return(false);
     }
     else if (txtDocNo.Text.Length < 3)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please Enter Document 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.familyno = "";
         dbDocumentStatusData.surveyno = "";
         //Check Existing Title Search Exist
         //dsDocumenttitleSearch = dbDocumentStatusData.DocumentTitleExist(cmbVillage.SelectedValue.ToString().Trim(), cmbFamily.SelectedValue.ToString().Trim(), cmbFamilySurvey.SelectedValue.ToString().Trim());
         dsDocumenttitleSearch = dbDocumentStatusData.DocumentTitleExistRO(cmbVillage.SelectedValue.ToString().Trim(), cmbDocumentNo.SelectedValue.ToString().Trim());
         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    = Session["UserName"].ToString();
         dbDocumentStatusData.createddate  = DateTime.Today;
         dbDocumentStatusData.docno        = cmbDocumentNo.SelectedValue.ToString().Trim();
         //Check For Record Exist
         dsDocumenteExists = dbDocumentStatusData.DocumentExistRO(cmbVillage.SelectedValue.ToString().Trim(), cmbDocumentNo.SelectedValue.ToString().Trim(), DocType);
         if (dsDocumenteExists.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.UpdateDocumentStatusFile();
             if (DocumentFileUpdate)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('New File Not Updated');", true);
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('New File updated');", true);
             }
         }
         return(true);
     }
 }