private void GetHandle() { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = Request.QueryString["ATH"]; DataTable dt = objAttachmentcls.GetALLHandleByID(); if (dt.Rows.Count > 0) { txtAttachmentHandle.Text = dt.Rows[0]["t_hndl"].ToString(); txtAcessIndex.Text = dt.Rows[0]["t_indx"].ToString(); txtTableName.Text = dt.Rows[0]["t_tabl"].ToString(); txtDescription.Text = dt.Rows[0]["t_tdes"].ToString(); txtRemarks.Text = dt.Rows[0]["t_rema"].ToString(); ddlDBID.SelectedValue = dt.Rows[0]["t_dbid"].ToString(); btnSaveHandle.Text = "Update"; txtAttachmentHandle.Enabled = false; divHeader.InnerText = "Update Attachment Handle"; } else { btnSaveHandle.Text = "Save"; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.LibraryCode = Request.QueryString["LibCode"]; DataTable dtLibCode = objAttachmentcls.GetLibraryCodeFromDataBase(); if (dtLibCode.Rows.Count > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Library Code already in used so it is not deleted');", true); } else { int res = objAttachmentcls.DeleteLibrary(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } } catch (Exception ex) { // ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('DBID used somewhere');", true); } }
protected void lnkDelete_Click(object sender, EventArgs e) { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.DBID = Request.QueryString["DBID"]; DataTable dtUSedDBID = objAttachmentcls.GetDBIDInHandle(); if (dtUSedDBID.Rows[0]["Dbidcount"].ToString() == "0") { int res = objAttachmentcls.DeleteDatabase(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('DBID used somewhere');", true); } } catch (Exception ex) { } }
protected void btnSystemAttachUpload_Click(object sender, EventArgs e) { if (Request.QueryString["RefHandle"] != null && Request.QueryString["RefIndex"] != null) { divTransmittalScreen.Visible = true; objAttachmentcls = new AttachmentCls(); // objAttachmentcls.IndexValue = Request.QueryString["Index"]; objAttachmentcls.AttachmentHandle = Request.QueryString["RefHandle"]; objAttachmentcls.IndexValue = Request.QueryString["RefIndex"]; DataTable dt = objAttachmentcls.GetExistingAttachment(); if (dt.Rows.Count > 0) { // Session["sDocumentId"] = dt.Rows[0]["t_dcid"].ToString(); //// Session["sFileName"] = dt.Rows[0]["t_fnam"].ToString(); // Session["sLibCode"] = dt.Rows[0]["t_lbcd"].ToString(); // Session["sattachedby"] = dt.Rows[0]["t_atby"].ToString(); divViewExistingAttachment.Visible = true; divExistingAttachNotExists.Visible = false; btnCopyAttachment.Visible = true; gvExistingAttachments.DataSource = dt; gvExistingAttachments.DataBind(); } else { divExistingAttachNotExists.Visible = true; divViewExistingAttachment.Visible = false; } } { // No Attachment exists for the provide reference handle and reference Index } }
protected void lnkDelete_Click(object sender, EventArgs e) { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.PurposeCode = Request.QueryString["PurposeCode"]; DataTable dt = objAttachmentcls.GetPurposeCodeCount(); if (dt.Rows[0]["PurposeCodeCount"].ToString() == "0") { int res = objAttachmentcls.DeletePurpose(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Purpose Code used somewhere');", true); } } catch (Exception ex) { } }
protected void lnkDownload_Click(object sender, EventArgs e) { try { LinkButton lnkbtn = (LinkButton)sender; string[] values = lnkbtn.CommandArgument.Split('&'); AttachmentCls objAttachmentcls = new AttachmentCls(); objAttachmentcls.IndexValue = values[2]; DataTable dt = objAttachmentcls.GetPath(); string ServerPath = dt.Rows[0]["t_path"].ToString() + "\\" + values[0];// Server.MapPath("~/Files/") + values[0]; // "\\\\" + dt.Rows[0]["ServerName"].ToString() + dt.Rows[0]["Path"].ToString() + values[0]; WebClient req = new WebClient(); HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearContent(); response.ClearHeaders(); response.Buffer = true; response.AddHeader("Content-Disposition", "attachment;filename=\"" + values[1] + "\""); byte[] data = req.DownloadData(ServerPath); response.BinaryWrite(data); response.End(); } catch (Exception ex) { //ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Some Technical issue Data Not Uploaded');", true); } }
private void GetDatabase() { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.DBID = Request.QueryString["DBID"]; DataTable dt = objAttachmentcls.GetDBID(); if (dt.Rows.Count > 0) { txtDBID.Text = dt.Rows[0]["t_dbid"].ToString(); txtDBServerName.Text = dt.Rows[0]["t_serv"].ToString(); txtDatabaseName.Text = dt.Rows[0]["t_dbnm"].ToString(); txtDBDesc.Text = dt.Rows[0]["t_desc"].ToString(); ddlLibrary.SelectedValue = dt.Rows[0]["t_lbcd"].ToString(); btnSaveDatabaseDetails.Text = "Update"; txtDBID.Enabled = false; divHeader.InnerText = "Update Database"; } else { btnSaveDatabaseDetails.Text = "Save"; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void lnkDelete_Click(object sender, EventArgs e) { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = Request.QueryString["ATH"]; DataTable dtHandle = objAttachmentcls.GetHandleId(); if (dtHandle.Rows.Count == 0) { int res = objAttachmentcls.DeleteHandle(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Attachment Handle used somewhere');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
private void GetLibrary() { try { objAttachmentcls = new AttachmentCls(); objAttachmentcls.LibraryCode = Request.QueryString["LibCode"]; DataTable dt = objAttachmentcls.GetLibCode(); if (dt.Rows.Count > 0) { txtLibraryCode.Text = dt.Rows[0]["t_lbcd"].ToString(); txtLibDesc.Text = dt.Rows[0]["t_desc"].ToString(); txtPath.Text = dt.Rows[0]["t_path"].ToString(); txtServerName.Text = dt.Rows[0]["t_serv"].ToString(); ddlIsActive.SelectedValue = dt.Rows[0]["t_acti"].ToString(); btnSaveLibrary.Text = "Update"; txtLibraryCode.Enabled = false; divHeader.InnerText = "Update Library"; btnDelete.Visible = true; } else { btnSaveLibrary.Text = "Save"; btnDelete.Visible = false; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
private void BindAllAttachments() { try { DataTable dt = new DataTable(); if (HttpContext.Current.Cache["ALLATHData"] == null) { objAttachmentcls = new AttachmentCls(); dt = objAttachmentcls.GetAllAttachments(); HttpContext.Current.Cache.Insert("ALLATHData", dt, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); } else { dt = (DataTable)HttpContext.Current.Cache["ALLATHData"]; } if (dt.Rows.Count > 0) { gvAttachment.DataSource = dt; gvAttachment.DataBind(); divNoRecord.Visible = false; divViewAttachment.Visible = true; } else { divNoRecord.Visible = true; divViewAttachment.Visible = false; } } catch (System.Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void lnkDelete_Click(object sender, EventArgs e) { try { LinkButton lnkUpdate = (LinkButton)sender; objAttachmentcls = new AttachmentCls(); objAttachmentcls.DocumentId = lnkUpdate.CommandArgument; int res = objAttachmentcls.DeleteAttachment(); if (res > 0) { // File.Delete(Path); HttpContext.Current.Cache.Remove("ATHData"); BindData(); ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } catch (System.Exception ex) { // ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('DBID used somewhere');", true); } }
protected void ddlDBID_SelectedIndexChanged(object sender, EventArgs e) { objAttachmentcls = new AttachmentCls(); objAttachmentcls.DBID = ddlDBID.SelectedValue; DataTable dt = objAttachmentcls.GetDBID(); txtDBDescription.Text = dt.Rows[0]["t_desc"].ToString(); txtDBDescription.Visible = true; }
protected void btnSaveDatabaseDetails_Click(object sender, EventArgs e) { try { int res = 0; if (txtDBID.Text != "" && txtDBServerName.Text != "" && txtDatabaseName.Text != "" && txtDBDesc.Text != "") { objAttachmentcls = new AttachmentCls(); objAttachmentcls.LibraryCode = ddlLibrary.SelectedValue; objAttachmentcls.DBID = txtDBID.Text.Trim(); objAttachmentcls.DBServer = txtDBServerName.Text.Trim(); objAttachmentcls.DatabaseName = txtDatabaseName.Text.Trim(); objAttachmentcls.DBDescription = txtDBDesc.Text.Trim(); if (btnSaveDatabaseDetails.Text == "Save") { DataTable dt = objAttachmentcls.GetDBID(); if (dt.Rows.Count == 0) { res = objAttachmentcls.InsertDBdetails(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Saved Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Saved');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('DBID already exist');", true); } } else { res = objAttachmentcls.UpdateDatabase(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Updated Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Updated');", true); } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please enter all data');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
private void BindLibrary() { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetAllActiveLibrary(); ddlLibrary.DataSource = dt; ddlLibrary.DataTextField = "t_lbcd"; ddlLibrary.DataValueField = "t_lbcd"; ddlLibrary.DataBind(); }
private void BindPurpose() { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetALLPurpose(); ddlPurpose.DataSource = dt; ddlPurpose.DataTextField = "PurposeDescription"; ddlPurpose.DataValueField = "PurposeCode"; ddlPurpose.DataBind(); }
protected void ddlHandle_SelectedIndexChanged(object sender, EventArgs e) { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetIndexByHandle(ddlHandle.SelectedValue); ddlIndex.DataSource = dt; ddlIndex.DataTextField = "AccessIndex"; ddlIndex.DataValueField = "AccessIndex"; ddlIndex.DataBind(); }
private void BindDBID() { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetALLDBID(); ddlDBID.DataSource = dt; ddlDBID.DataTextField = "t_dbid"; ddlDBID.DataValueField = "t_dbid"; ddlDBID.DataBind(); ddlDBID.Items.Insert(0, "Select"); }
//private void BindLibrary() //{ // objAttachmentcls = new AttachmentCls(); // DataTable dt = objAttachmentcls.GetAllActiveLibrary(); // ddlLibrary.DataSource = dt; // ddlLibrary.DataTextField = "LibraryCode"; // ddlLibrary.DataValueField = "LibraryCode"; // ddlLibrary.DataBind(); //} private void BindHandle() { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetALLHandle(); ddlHandle.DataSource = dt; ddlHandle.DataTextField = "Attachment_Handle"; ddlHandle.DataValueField = "Attachment_Handle"; ddlHandle.DataBind(); ddlHandle.Items.Insert(0, "Select"); }
protected void btnSaveHandle_Click(object sender, EventArgs e) { try { if (txtAttachmentHandle.Text != "" && txtAcessIndex.Text != "" && txtTableName.Text != "" && ddlDBID.SelectedValue != "Select") { objAttachmentcls = new AttachmentCls(); objAttachmentcls.DBID = ddlDBID.SelectedValue; objAttachmentcls.AttachmentHandle = txtAttachmentHandle.Text.Trim(); objAttachmentcls.IndexValue = txtAcessIndex.Text.Trim(); objAttachmentcls.TableName = txtTableName.Text.Trim(); objAttachmentcls.TableDesc = txtDescription.Text.Trim(); objAttachmentcls.Remarks = txtRemarks.Text.Trim(); if (btnSaveHandle.Text == "Save") { int res = objAttachmentcls.InsertHandle(); if (res > 0) { txtAttachmentHandle.Text = ""; txtAcessIndex.Text = ""; txtTableName.Text = ""; txtDescription.Text = ""; txtRemarks.Text = ""; ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Saved Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Saved');", true); } } else { int res = objAttachmentcls.UpdateHandle(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Updated Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Updated');", true); } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please enter all data');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void btnUpload_Click(object sender, EventArgs e) { if (ddlHandle.SelectedValue != "Select" && ddlIndex.SelectedValue != "") { objAttachmentcls = new AttachmentCls(); objAttachmentcls.IndexValue = ddlIndex.SelectedValue; // Request.QueryString["Index"]; DataTable dt = objAttachmentcls.GetPath(); string ServerPath = dt.Rows[0]["Path"].ToString() + "\\"; // "\\\\" + dt.Rows[0]["ServerName"].ToString() + "\\" + dt.Rows[0]["Path"].ToString() + "\\"; // Server.MapPath("~/Files/");// if (FileUpload.HasFile) { int filecount = 0; filecount = FileUpload.PostedFiles.Count(); if (filecount > 0) { foreach (HttpPostedFile PostedFile in FileUpload.PostedFiles) { string fileName = Path.GetFileNameWithoutExtension(PostedFile.FileName); string fileExtension = Path.GetExtension(PostedFile.FileName); try { AttachmentCls objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = ddlHandle.SelectedValue; // Request.QueryString["AthHandle"]; objAttachmentcls.IndexValue = ddlIndex.SelectedValue; // Request.QueryString["Index"]; objAttachmentcls.PurposeCode = ddlPurpose.SelectedValue; // Request.QueryString["PurposeCode"]; objAttachmentcls.AttachedBy = "0"; //Request.QueryString["AttachedBy"]; objAttachmentcls.FileName = fileName + fileExtension; objAttachmentcls.LibraryCode = dt.Rows[0]["LibCode"].ToString(); int nRecord = new Random(Guid.NewGuid().GetHashCode()).Next(); objAttachmentcls.RunningId = nRecord; objAttachmentcls.DocumentId = "AAA" + nRecord.ToString(); //DataTable dtDocID = objAttachmentcls.InsertAttachmentdata(); DataTable dtDocID = objAttachmentcls.InsertAttachmentdata(); //Change- 27-08-2018 Insert Attachment error related change if (dtDocID.Rows.Count > 0) { PostedFile.SaveAs(ServerPath + dtDocID.Rows[0][0]); ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Successfully Uploaded');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + ex.Message + "');", true); } } } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please select all fields');", true); } }
private void BindGrid() { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetALLDBID(); if (dt.Rows.Count > 0) { gvData.DataSource = dt; gvData.DataBind(); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data not found');", true); } }
protected void btnSavePurpose_Click(object sender, EventArgs e) { try { if (txtPurposeCode.Text != "" && txtPDescription.Text != "") { objAttachmentcls = new AttachmentCls(); objAttachmentcls.PurposeCode = txtPurposeCode.Text.Trim(); objAttachmentcls.PurposeDesc = txtPDescription.Text.Trim(); if (btnSavePurpose.Text == "Save") { int res = objAttachmentcls.InsertPurpose(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Saved Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Saved');", true); } } else { int res = objAttachmentcls.UpdatePurpose(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Updated Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Updated');", true); } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please enter all data');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
private void GetPurpose() { objAttachmentcls = new AttachmentCls(); objAttachmentcls.PurposeCode = Request.QueryString["PurposeCode"]; DataTable dt = objAttachmentcls.GetALLPurposeByID(); if (dt.Rows.Count > 0) { txtPurposeCode.Text = dt.Rows[0]["t_prcd"].ToString(); txtPDescription.Text = dt.Rows[0]["t_desc"].ToString(); btnSavePurpose.Text = "Update"; txtPurposeCode.Enabled = false; divHeader.InnerText = "Update Purpose"; } else { btnSavePurpose.Text = "Save"; } }
private void BindGrid() { try { objAttachmentcls = new AttachmentCls(); DataTable dt = objAttachmentcls.GetALLPurpose(); if (dt.Rows.Count > 0) { gvData.DataSource = dt; gvData.DataBind(); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data not found');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
private void BindData() { try { //if (Request.QueryString["AthHandle"] != null) //{ objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = ddlHandle.SelectedValue; //Request.QueryString["AthHandle"]; objAttachmentcls.IndexValue = ddlIndex.SelectedValue; // Request.QueryString["Index"]; DataTable dt = objAttachmentcls.GetAttachments(); gvAttachment.DataSource = dt; gvAttachment.DataBind(); //} //else //{ // ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('No record found');", true); //} } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void btnUpload_Click(object sender, EventArgs e) { if (Request.QueryString["AthHandle"] != null && Request.QueryString["Index"] != null && Request.QueryString["AttachedBy"] != null) { objAttachmentcls = new AttachmentCls(); // objAttachmentcls.IndexValue = Request.QueryString["Index"]; objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"]; DataTable dt = objAttachmentcls.GetPath(); if (dt.Rows.Count > 0) { //string ServerPath = "\\\\" + dt.Rows[0]["ServerName"].ToString() + "\\" + dt.Rows[0]["Path"].ToString() + "\\"; //dt.Rows[0]["Path"].ToString() + "\\";// // Server.MapPath("~/Files/");// string ServerPath = "D:\\" + dt.Rows[0]["t_path"].ToString() + "\\"; //dt.Rows[0]["Path"].ToString() + "\\";// // Server.MapPath("~/Files/");// string LocalPath = Server.MapPath("~/Files/"); if (FileUpload.HasFile) { int filecount = 0; filecount = FileUpload.PostedFiles.Count(); if (filecount > 0) { foreach (HttpPostedFile PostedFile in FileUpload.PostedFiles) { string fileName = Path.GetFileNameWithoutExtension(PostedFile.FileName); string fileExtension = Path.GetExtension(PostedFile.FileName); try { AttachmentCls objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"]; objAttachmentcls.IndexValue = Request.QueryString["Index"]; objAttachmentcls.PurposeCode = "Dmisg134_1_vendor";// Request.QueryString["PurposeCode"]; objAttachmentcls.AttachedBy = Request.QueryString["AttachedBy"]; objAttachmentcls.FileName = fileName + fileExtension; objAttachmentcls.LibraryCode = dt.Rows[0]["LibCode"].ToString(); // DataTable dtFile = objAttachmentcls.GetFileName(); // if (dtFile.Rows.Count == 0) // { DataTable dtDocID = objAttachmentcls.Insertdata(); if (dtDocID.Rows[0][0].ToString() != "0") { try { FileUpload.SaveAs(ServerPath + dtDocID.Rows[0][0]); } catch (Exception ex) {// err.Text = ex.Message; } // FileUpload.SaveAs(LocalPath + fileName + fileExtension); HttpContext.Current.Cache.Remove("ATHData"); BindData(); ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Successfully Uploaded');", true); } else { //objAttachmentcls = new AttachmentCls(); //objAttachmentcls.DocumentId = dtDocID.Rows[0][0].ToString(); //int res = objAttachmentcls.DeleteAttachment(); ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Attachment Handle does not exist');", true); } // } // else // { // ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('This file name already exist please change your file name');", true); // } } catch (System.Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + ex.Message + "');", true); } } } else { } } else { } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Attachment Handle does not exist');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data not found Properly');", true); } }
private void BindData() { try { DataTable dt = new DataTable(); if (Request.QueryString["RefHandle"] != null && Request.QueryString["RefIndex"] != null) { objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"]; objAttachmentcls.IndexValue = Request.QueryString["Index"]; dt = objAttachmentcls.GetAllExistingAttachments(); // HttpContext.Current.Cache.Insert("ATHData", dt, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); if (dt.Rows.Count > 0) { gvAttachment.DataSource = dt; gvAttachment.DataBind(); divNoRecord.Visible = false; // gvExistingAttachments.Visible = true; divViewAttachment.Visible = true; // divExistingAttachNotExists.Visible = false; } else { divNoRecord.Visible = true; // divExistingAttachNotExists.Visible = true; divViewAttachment.Visible = false; } } else if (Request.QueryString["AthHandle"] != null && Request.QueryString["Index"] != null && Request.QueryString["AttachedBy"] != null) { if (HttpContext.Current.Cache["ATHData"] == null) { objAttachmentcls = new AttachmentCls(); objAttachmentcls.AttachmentHandle = Request.QueryString["AthHandle"]; objAttachmentcls.IndexValue = Request.QueryString["Index"]; dt = objAttachmentcls.GetAttachments(); HttpContext.Current.Cache.Insert("ATHData", dt, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); } else { dt = (DataTable)HttpContext.Current.Cache["ATHData"]; } if (dt.Rows.Count > 0) { gvAttachment.DataSource = dt; gvAttachment.DataBind(); divNoRecord.Visible = false; divViewAttachment.Visible = true; } else { divNoRecord.Visible = true; divViewAttachment.Visible = false; } } // else // { else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('No Data found');", true); } // } } catch (System.Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }
protected void btnSaveLibrary_Click(object sender, EventArgs e) { try { int res = 0; if (txtLibraryCode.Text != "" && txtLibDesc.Text != "" && txtPath.Text != "" && txtServerName.Text != "") { objAttachmentcls = new AttachmentCls(); objAttachmentcls.LibraryCode = txtLibraryCode.Text.Trim(); objAttachmentcls.LibraryDescription = txtLibDesc.Text.Trim(); objAttachmentcls.Path = txtPath.Text.Trim(); objAttachmentcls.IsActive = ddlIsActive.SelectedValue; objAttachmentcls.ServerName = txtServerName.Text.Trim(); if (btnSaveLibrary.Text == "Save") { DataTable dt = objAttachmentcls.GetLibCode(); if (dt.Rows.Count == 0) { res = objAttachmentcls.InsertLibrary(); if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Saved Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Saved');", true); } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Library Code already exist');", true); } } else { if (ddlIsActive.SelectedValue == "N") { DataTable dtLibCode = objAttachmentcls.GetLibraryCodeFromDataBase(); if (dtLibCode.Rows.Count > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Library Code Already in used so it is not Deactivated');", true); } else { res = objAttachmentcls.UpdateLibrary(); } } else { res = objAttachmentcls.UpdateLibrary(); } if (res > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Updated Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Updated');", true); } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please enter all data');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true); } }