Esempio n. 1
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);
            }
        }