/// <summary> /// Bind Data to Drop Downs /// </summary> public void screenIntilation() { objUploadDocumentBLL = new UploadDocumentBLL(); objUploadDocument = new UploadDocumentBO(); UploadDocumentList objUploadDocumentList = new UploadDocumentList(); objUploadDocumentList = objUploadDocumentBLL.GetUploadDocument(); ListItem lstItem = DocTypeDropDownList.Items[0]; DocTypeDropDownList.Items.Clear(); DocTypeDropDownList.DataSource = objUploadDocumentList;//dt.Tables[0]; DocTypeDropDownList.DataTextField = "DocumentType"; DocTypeDropDownList.DataValueField = "DocumentTypeID"; DocTypeDropDownList.DataBind(); DocTypeDropDownList.Items.Insert(0, lstItem); }
/// <summary> /// Bind Data to Drop downs /// </summary> public void screenIntilation() { objUploadDocumentBLL = new UploadDocumentBLL(); objUploadDocument = new UploadDocumentBO(); UploadDocumentList objUploadDocumentList = new UploadDocumentList(); objUploadDocumentList = objUploadDocumentBLL.GetUploadDocument(); DocTypeDropDownList.DataSource = objUploadDocumentList;//dt.Tables[0]; DocTypeDropDownList.DataTextField = "DocumentType"; DocTypeDropDownList.DataValueField = "DocumentTypeID"; DocTypeDropDownList.DataBind(); DocTypeDropDownList.Items.Insert(0, new ListItem("-- Select --", "0")); DocTypeDropDownList.SelectedIndex = 0; string DocumentCode = Request.QueryString["DOCUMENT_CODE"].ToString(); DocTypeDropDownList.ClearSelection(); if (DocumentCode.Length > 0) { for (int i = 0; i < objUploadDocumentList.Count; i++) { if (DocumentCode == objUploadDocumentList[i].DocumentCode) { if (DocTypeDropDownList.Items.FindByValue(objUploadDocumentList[i].DocumentTypeID.ToString()) != null) { DocTypeDropDownList.Items.FindByValue(objUploadDocumentList[i].DocumentTypeID.ToString()).Selected = true; DocTypeDropDownList.Enabled = false; } else { DocTypeDropDownList.Items[0].Selected = true; } } } } else { DocTypeDropDownList.Items[0].Selected = true; } }
protected void Page_Load(object sender, EventArgs e) { string papDocumentID = (Request.QueryString["papDocumentID"]); string ProjectCode = (Request.QueryString["ProjectCode"]); UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); UploadDocumentBO UploadDocumentBOObj = new UploadDocumentBO(); string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); UploadDocumentBOObj = UploadDocumentBLLobj.getFilePath(papDocumentID, ProjectCode); if (File.Exists(UploadDocumentBOObj.DocumentPath)) { string sFileName = Path.GetFileName(UploadDocumentBOObj.DocumentPath); File.Copy(UploadDocumentBOObj.DocumentPath, sTempPath + sFileName, true); this.spncontent.Style.Add("display", ""); this.contentPanel1.Attributes["src"] = ConfigurationManager.AppSettings["TempFolder"].ToString() + sFileName; lblMessage.Visible = false; } else { this.spncontent.Style.Add("display", "none"); lblMessage.Visible = true; } }
/// <summary> /// Bind Data to Grid /// </summary> private void BindGrid() { int HHID = 0; string DocumentCode = string.Empty; if ((Request.QueryString["HHID"]) != null) { HHID = Convert.ToInt32(Request.QueryString["HHID"]); } if (Request.QueryString["DOCUMENT_CODE"] != null) { DocumentCode = Request.QueryString["DOCUMENT_CODE"].ToString(); } else { DocumentCode = "All"; } string ProjectCode = Request.QueryString["ProjectCode"].ToString(); int ProjectID = Convert.ToInt32(Request.QueryString["ProjectID"]); UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); int DocserviceID = 0; if (txtDocserviceID.Text.Trim().Length > 0) { DocserviceID = Convert.ToInt32(txtDocserviceID.Text.Trim()); } //grdUploadDocument.DataSource = UploadDocumentBLLobj.GetALLUploadDocument(HHID, DocumentCode, ProjectID.ToString(), DocserviceID); //grdUploadDocument.DataBind(); WIS_BusinessObjects.UploadDocumentList uplist = UploadDocumentBLLobj.GetALLUploadDocument(HHID, DocumentCode, ProjectID.ToString(), DocserviceID, Convert.ToInt32(Session["USER_ID"])); WIS_BusinessObjects.UploadDocumentList uplist1 = new WIS_BusinessObjects.UploadDocumentList(); foreach (UploadDocumentBO upbo in uplist) { string FilePath = upbo.DocumentPath; if (FilePath != null) { if (upbo.HHID <= 0) { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + sFileName, true); string path = ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + sFileName; upbo.DocumentPath = path; } } else { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\" + sFileName, true); string path = ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + upbo.HHID.ToString() + "/" + sFileName; upbo.DocumentPath = path; } } } uplist1.Add(upbo); } grdUploadDocument.DataSource = uplist1; grdUploadDocument.DataBind(); grdUploadDocument.AllowPaging = true; }
/// <summary> /// Bind Search Data /// </summary> private void BindGridForSearch() { int HHID; string DocumentCode = string.Empty; string KeyWord = string.Empty; if ((Request.QueryString["HHID"]) != null) { HHID = Convert.ToInt32(Request.QueryString["HHID"]); } else { HHID = 0; DocumentCode = "All"; } if ((Request.QueryString["DOCUMENT_CODE"]) != null) { DocumentCode = Request.QueryString["DOCUMENT_CODE"].ToString(); } else { DocumentCode = "All"; } string ProjectCode = Request.QueryString["ProjectCode"].ToString(); //Convert.ToInt32(Session["HHID"].ToString()); int DocserviceID = 0; if (txtDocserviceID.Text.Trim().Length > 0) { DocserviceID = Convert.ToInt32(txtDocserviceID.Text.Trim()); } if (txtSearchKeyword.Text.ToString().Trim() == string.Empty) { KeyWord = "ALL"; } else { KeyWord = txtSearchKeyword.Text.ToString().Trim(); } // = txtSearchKeyword.Text.ToString().Trim(); UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); //grdUploadDocument.DataSource = UploadDocumentBLLobj.GetSearchDocument(KeyWord, HHID, DocumentCode, upProjectIDTextBox.Text, DocserviceID); //grdUploadDocument.DataBind(); UploadDocumentList uplist = UploadDocumentBLLobj.GetSearchDocument(KeyWord, HHID, DocumentCode, upProjectIDTextBox.Text, DocserviceID, Convert.ToInt32(Session["USER_ID"])); System.Web.HttpBrowserCapabilities browser = Request.Browser; if (browser.Type.ToUpper().Contains("IE") || true) { UploadDocumentList uplist1 = new UploadDocumentList(); foreach (UploadDocumentBO upbo in uplist) { string FilePath = upbo.DocumentPath; if (FilePath != null) { if (upbo.HHID <= 0) { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + sFileName, true); string path = ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + sFileName; upbo.DocumentPath = path; } } else { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\" + sFileName, true); string path = ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + upbo.HHID.ToString() + "/" + sFileName; upbo.DocumentPath = path; } } } uplist1.Add(upbo); } grdUploadDocument.DataSource = uplist1; grdUploadDocument.DataBind(); grdUploadDocument.Columns[grdUploadDocument.Columns.Count - 3].Visible = false; } else { grdUploadDocument.Columns[grdUploadDocument.Columns.Count - 2].Visible = false; grdUploadDocument.DataSource = uplist; grdUploadDocument.DataBind(); } }
/// <summary> /// view or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdUploadDocument_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "ViewRow") { int PAPDOCUMENTID = 0; GridViewRow row = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; Literal LtlDocumentPath = (Literal)row.FindControl("LtlDocumentPath"); ViewState["PAPDOCUMENTID"] = e.CommandArgument; PAPDOCUMENTID = Convert.ToInt32(ViewState["PAPDOCUMENTID"].ToString()); string FilePath = LtlDocumentPath.Text.ToString(); string[] spiltValue = FilePath.Split('.'); if (spiltValue.Length > 0) { string s = spiltValue[spiltValue.Length - 1]; if (s.Length > 0) { if (s.Trim().ToLower() != "")// "tif") { if (FilePath != null) { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + sFileName, true); string path = ConfigurationManager.AppSettings["TempFolder"].ToString() + sFileName; ScriptManager.RegisterStartupScript(this, this.GetType(), "ViewFile", "ViewFile('" + path + "');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ViewFile", "alert('File does not exist in the file system.');", true); } //File.Copy(FilePath, sTempPath + sFileName, true); //this.contentPanel1.Attributes["src"] = ConfigurationManager.AppSettings["TempFolder"].ToString() + sFileName; } } else { this.contentPanel1.Attributes["src"] = null; if (FilePath != null) { string ProjectCode = Session["PROJECT_CODE"].ToString(); string paramChangeRequest = string.Format("ViewUploadDocument({0},'{1}');", PAPDOCUMENTID, ProjectCode); ClientScript.RegisterStartupScript(this.GetType(), "ViewUploadDocument", paramChangeRequest, true); } } } } } if (e.CommandName == "DeleteRow") { string message = string.Empty; int PAPDOCUMENTID = 0; GridViewRow row = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; Literal LtlDocumentPath = (Literal)row.FindControl("LtlDocumentPath"); //Literal value avaiable in the grid Literal LilProjectCode = (Literal)row.FindControl("LilProjectCode"); Literal LitHHID = (Literal)row.FindControl("LitHHID"); ViewState["PAPDOCUMENTID"] = e.CommandArgument; if (ViewState["PAPDOCUMENTID"] != null) { PAPDOCUMENTID = Convert.ToInt32(ViewState["PAPDOCUMENTID"].ToString()); } UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); message = UploadDocumentBLLobj.DeleteDocument(Convert.ToInt32(ViewState["PAPDOCUMENTID"]), Convert.ToInt32(Session["USER_ID"])); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Document Deleted successfully"; try { string FilePath = LtlDocumentPath.Text.ToString(); string sFileName = Path.GetFileName(FilePath); if (LitHHID.Text.Trim() == "0") { string main_strPath_user = ConfigurationManager.AppSettings["main_strPath_user"].ToString() + LilProjectCode.Text.ToString() + "\\" + sFileName; if (main_strPath_user != null) { if (File.Exists(main_strPath_user)) { File.Delete(main_strPath_user); } } } else { string main_strPath_user = ConfigurationManager.AppSettings["main_strPath_user"].ToString() + LilProjectCode.Text.ToString() + "\\" + LitHHID.Text.ToString() + "\\" + sFileName; if (main_strPath_user != null) { if (File.Exists(main_strPath_user)) { File.Delete(main_strPath_user); } } } } catch (IOException ex) { throw ex; //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + ex + "');", true); } } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } BindGrid(true, true); } }
// Writes file to current folder private void WriteToFile(string strNewFileName, ref byte[] Buffer) { //Decleraton local Varabiles string message = string.Empty; string AlertMessage = string.Empty; //created object to BO layer and BLL layer objUploadDocument = new UploadDocumentBO(); objUploadDocumentBLL = new UploadDocumentBLL(); //get the value using seesion and UI Screen string uID = userIDTextBox.Text; // userIDTextBox.Text //Session["USER_ID"].ToString(); string pID = upProjectIDTextBox.Text; //upProjectIDTextBox.Text; int HHID = Convert.ToInt32(upHHIDTextBox.Text); //upHHIDTextBox.Text // Store it in database HttpPostedFile myFile = fileMyFile.PostedFile; // to get user selected file string strFilename = Path.GetFileName(myFile.FileName); string ServerProposalFilePath = strNewFileName; // Store it in database file Name string filepath = System.IO.Path.GetFullPath(fileMyFile.PostedFile.FileName); //create Object for save Data objUploadDocument.HHID = HHID; objUploadDocument.ProjectID = Convert.ToInt32(upProjectIDTextBox.Text); if (txtDocserviceID.Text.Trim().Length > 0) { objUploadDocument.DOCSERVICEID = Convert.ToInt32(txtDocserviceID.Text.Trim()); } else { objUploadDocument.DOCSERVICEID = 0; } objUploadDocument.KeyWord = txtKeyword.Text.ToString().Trim(); objUploadDocument.Description = txtDescription.Text.ToString().Trim(); objUploadDocument.DocumentTypeID = Convert.ToInt32(DocTypeDropDownList.SelectedItem.Value.ToString()); objUploadDocument.DocumentPath = ServerProposalFilePath; objUploadDocument.UserID = Convert.ToInt32(uID); message = objUploadDocumentBLL.InsertUploadDocument(objUploadDocument); AlertMessage = "alert('" + message + "');"; if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Document uploaded successfully"; //Copy the file to file server path //pID //ProjectCodeTextBox.Text string projectName = ProjectCodeTextBox.Text; string activeDir = ConfigurationManager.AppSettings["activeDir"].ToString(); //Path is defined in webapp string newPath = System.IO.Path.Combine(activeDir, projectName); if (!Directory.Exists(newPath)) { System.IO.Directory.CreateDirectory(newPath); } string newFileName = System.IO.Path.GetRandomFileName(); newPath = System.IO.Path.Combine(newPath, newFileName); //string strPath_user = ConfigurationManager.AppSettings["strPath_user"].ToString() + projectName + "\\" + strFilename; //string cpy_strPath_user = ConfigurationManager.AppSettings["cpy_strPath_user"].ToString() + projectName + "\\"; //File.Copy(strPath_user, cpy_strPath_user + strNewFileName, true); // To save file in destination path if (HHID == 0) { string main_strPath_user = ConfigurationManager.AppSettings["main_strPath_user"].ToString() + projectName + "\\"; fileMyFile.SaveAs(main_strPath_user + strNewFileName); } else { string main_strPath_user = ConfigurationManager.AppSettings["main_strPath_user"].ToString() + projectName + "\\" + HHID.ToString() + "\\"; newPath = System.IO.Path.Combine(activeDir, projectName); string HHIDpath = System.IO.Path.Combine(newPath, HHID.ToString()); if (!Directory.Exists(HHIDpath)) { System.IO.Directory.CreateDirectory(HHIDpath); } fileMyFile.SaveAs(main_strPath_user + strNewFileName); } // end BindGrid(false, false); txtKeyword.Text = string.Empty; txtDescription.Text = string.Empty; } AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }
/// <summary> /// bind grid data for search /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BindGridForSearch() { Int32 HHID = 0; if (txtHHID.Text.Trim().Length > 0) { HHID = Convert.ToInt32(txtHHID.Text); } string DocumentCode = string.Empty; string KeyWord = string.Empty; DocumentCode = "All"; if (txtSearchKeyword.Text.ToString().Trim() == string.Empty) { KeyWord = "ALL"; } else { KeyWord = txtSearchKeyword.Text.ToString().Trim(); } UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); //grdUploadDocument.DataSource = UploadDocumentBLLobj.GetSearchDocument(KeyWord, HHID, DocumentCode, drpProjectsearch.SelectedValue, 0); //grdUploadDocument.DataBind(); UploadDocumentList uplist = UploadDocumentBLLobj.GetSearchDocument(KeyWord, HHID, DocumentCode, drpProjectsearch.SelectedValue, 0, Convert.ToInt32(Session["USER_ID"])); UploadDocumentList uplist1 = new UploadDocumentList(); foreach (UploadDocumentBO upbo in uplist) { string FilePath = upbo.DocumentPath; if (FilePath != null) { if (upbo.HHID <= 0) { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + sFileName, true); string path = "../" + ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + sFileName; upbo.DocumentPath = path; } } else { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\" + sFileName, true); string path = "../" + ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + upbo.HHID.ToString() + "/" + sFileName; upbo.DocumentPath = path; } } } uplist1.Add(upbo); } grdUploadDocument.DataSource = uplist1; grdUploadDocument.DataBind(); grdUploadDocument.AllowPaging = true; }
//if the user search the record and other information private void BindGrid() { int HHID = 0; if (Session["HH_ID"] != null) { HHID = Convert.ToInt32(Session["HH_ID"]); } else { HHID = 0; } string projectID = drpProject.SelectedValue; string DocumentCode = string.Empty; //if (drpProject.SelectedIndex > 0) //{ // if (HHIDTextBox.Text.Trim().Length > 0) // HHID = Convert.ToInt32(HHIDTextBox.Text.Trim()); //} DocumentCode = "All"; UploadDocumentBLL UploadDocumentBLLobj = new UploadDocumentBLL(); //grdUploadDocument.DataSource = UploadDocumentBLLobj.GetALLUploadDocument(HHID, DocumentCode, projectID, 0); //grdUploadDocument.DataBind(); UploadDocumentList uplist = UploadDocumentBLLobj.GetALLUploadDocument(HHID, DocumentCode, projectID, 0, Convert.ToInt32(Session["USER_ID"])); UploadDocumentList uplist1 = new UploadDocumentList(); foreach (UploadDocumentBO upbo in uplist) { string FilePath = upbo.DocumentPath; if (FilePath != null) { if (upbo.HHID <= 0) { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + sFileName, true); string path = "../" + ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + sFileName; upbo.DocumentPath = path; } } else { string sTempPath = ConfigurationManager.AppSettings["TempDirectory"].ToString(); if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\"); } if (!Directory.Exists(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\")) { System.IO.Directory.CreateDirectory(sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\"); } string sFileName = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { File.Copy(FilePath, sTempPath + upbo.Projectcode + @"\" + upbo.HHID.ToString() + @"\" + sFileName, true); string path = "../" + ConfigurationManager.AppSettings["TempFolder"].ToString() + upbo.Projectcode + "/" + upbo.HHID.ToString() + "/" + sFileName; upbo.DocumentPath = path; } } } uplist1.Add(upbo); } grdUploadDocument.DataSource = uplist1; grdUploadDocument.DataBind(); grdUploadDocument.AllowPaging = true; }