protected void cmdUpload_Click(object source, EventArgs e) { BLL_TRV_Attachment att = new BLL_TRV_Attachment(); try { int RequestID = 0; if (flName.PostedFile.ContentLength > 0) { string sFileName, filePath; sFileName = System.Guid.NewGuid().ToString() + System.IO.Path.GetExtension(flName.PostedFile.FileName); filePath = ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString(); if (flName.PostedFile.ContentLength <= 3048000) { filePath = Server.MapPath("~/") + ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString() + sFileName; flName.PostedFile.SaveAs(filePath); att.SaveAttchement(RequestID, sFileName, System.IO.Path.GetFileName(flName.PostedFile.FileName), "INVOICE", "", Convert.ToInt32(Session["USERID"].ToString()), UDFLib.ConvertIntegerToNull(Request.QueryString["SUPPLIER_ID"])); SaveInvoice(); GetInvoices(""); } } } catch (UnauthorizedAccessException ex) { throw new Exception(ex.Message + "Permission to upload file denied"); } finally { att = null; } }
public Boolean SaveAttchement(int requestid, string attachment_name, string attachment_path, string attachment_type, string refnumber, int userid) { BLL_TRV_Attachment objTrv = new BLL_TRV_Attachment(); try { return(objTrv.SaveAttchement(requestid, attachment_name, attachment_path, attachment_type, refnumber, userid, null)); } catch { throw; } finally { objTrv = null; } }
protected void btnCreateTicket_Click(object s, EventArgs e) { try { string sFileName = Guid.NewGuid().ToString(); string filePath = Server.MapPath("~/") + ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString() + sFileName + ".pdf"; EO.Pdf.Runtime.AddLicense("p+R2mbbA3bNoqbTC4KFZ7ekDHuio5cGz4aFZpsKetZ9Zl6TNHuig5eUFIPGe" + "tcznH+du5PflEuCG49jjIfewwO/o9dB2tMDAHuig5eUFIPGetZGb566l4Of2" + "GfKetZGbdePt9BDtrNzCnrWfWZekzRfonNzyBBDInbW6yuCwb6y9xtyxdabw" + "+g7kp+rp2g+9RoGkscufdePt9BDtrNzpz+eupeDn9hnyntzCnrWfWZekzQzr" + "peb7z7iJWZekscufWZfA8g/jWev9ARC8W7zTv/vjn5mkBxDxrODz/+ihb6W0" + "s8uud4SOscufWbOz8hfrqO7CnrWfWZekzRrxndz22hnlqJfo8h8="); EO.Pdf.HtmlToPdf.Options.AfterRenderPage = new EO.Pdf.PdfPageEventHandler(On_AfterRenderPage); EO.Pdf.HtmlToPdf.ConvertHtml(@"<html><div>" + txtMailBody.Text + "</div> </html> ", filePath); BLL_TRV_TravelRequest TRequest = new BLL_TRV_TravelRequest(); BLL_TRV_Attachment att = new BLL_TRV_Attachment(); int RequestID = UDFLib.ConvertToInteger(Request.QueryString["requestid"].ToString()); if (!String.IsNullOrEmpty(hdf_TicketNumber.Value)) { if (TRequest.UpdateETicketNumber(RequestID, Convert.ToInt32(hdf_Flightid.Value), hdf_TicketNumber.Value, UDFLib.ConvertToInteger(Session["USERID"].ToString()), Convert.ToInt32(hdf_PaxID.Value))) { att.SaveAttchement(RequestID, sFileName + ".pdf", sFileName + ".pdf", "ETICKET", hdf_TicketNumber.Value, Convert.ToInt32(Session["USERID"].ToString()), UDFLib.ConvertIntegerToNull(Request.QueryString["SUPPLIER_ID"])); } } GetETickets(); } catch (Exception ex) { String msgmodalexp = String.Format("alert('" + ex.Message + "');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "expCreateTicket", msgmodalexp, true); } String msgmodal = String.Format("hideModal('dvCreateTicket');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "dvCreateTicket", msgmodal, true); }
protected void cmdUpload_Click(object source, EventArgs e) { BLL_TRV_Attachment att = new BLL_TRV_Attachment(); try { if (IsPostBack) { if (Attach_Type.ToString().ToUpper() == "INVOICE") { SaveInvoice(); ddlAttachmentType.SelectedIndex = 0; txtInvAmount.Text = ""; txtInvNo.Text = ""; } if (flName.PostedFile.ContentLength > 0) { string sFileName, filePath; sFileName = System.Guid.NewGuid().ToString() + Path.GetExtension(flName.PostedFile.FileName); filePath = ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString(); if (flName.PostedFile.ContentLength <= 3048000) { filePath = Server.MapPath("~/") + ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString() + sFileName; flName.PostedFile.SaveAs(filePath); att.SaveAttchement(RequestID, Path.GetFileName(flName.PostedFile.FileName), sFileName, Attach_Type, "", Convert.ToInt32(Session["USERID"].ToString()), UDFLib.ConvertIntegerToNull(Request.QueryString["SUPPLIER_ID"])); } } } GetAttachment(RequestID, Attach_Type); } catch (UnauthorizedAccessException ex) { throw new Exception(ex.Message + "Permission to upload file denied"); } finally { att = null; } }
/// Agent will be able to upload the ticket if the status is Issued or Approved /// Status can be checked in TRequest.Get_TravelStatus menthod protected void cmdTicketNo_onClick(object source, EventArgs e) { lblMessage.Text = ""; TextBox txtETicketNumber = (TextBox)((GridViewRow)((Button)source).Parent.Parent).FindControl("txtETicketNumber"); FileUpload flName = (FileUpload)((GridViewRow)((Button)source).Parent.Parent).FindControl("flName"); BLL_TRV_TravelRequest TRequest = new BLL_TRV_TravelRequest(); BLL_TRV_Attachment att = new BLL_TRV_Attachment(); BLL_Infra_UploadFileSize objUploadFilesize = new BLL_Infra_UploadFileSize(); DataTable dt = new DataTable(); dt = objUploadFilesize.Get_Module_FileUpload("TRV_"); string status = ""; DataTable dtStatus = TRequest.Get_TravelStatus(UDFLib.ConvertToInteger(Request.QueryString["requestid"].ToString())); if (dtStatus.Rows.Count > 0) { status = dtStatus.Rows[0]["currentStatus"].ToString(); if (status == "APPROVED" || status == "ISSUED") { if (dt.Rows.Count > 0) { string datasize = dt.Rows[0]["Size_KB"].ToString(); if (flName.PostedFile.ContentLength < Int32.Parse(dt.Rows[0]["Size_KB"].ToString()) * 1024) { try { int RequestID = UDFLib.ConvertToInteger(Request.QueryString["requestid"].ToString()); int Flightid; PaxID = UDFLib.ConvertToInteger(((Button)source).CommandArgument.Split(',')[0]); Flightid = UDFLib.ConvertToInteger(((Button)source).CommandArgument.Split(',')[1]); if (!String.IsNullOrEmpty(txtETicketNumber.Text) && flName.PostedFile.ContentLength > 0) { if (TRequest.UpdateETicketNumber(RequestID, Flightid, txtETicketNumber.Text, UDFLib.ConvertToInteger(Session["USERID"].ToString()), PaxID)) { //string msg = "E-TICKET for Request #" + RequestID.ToString() + " has been uploaded on the website, please download the same"; // UDFLib.ConvertToInteger(Session["USERID"].ToString())); if (flName.PostedFile.ContentLength > 0) { string sFileName, filePath; sFileName = System.Guid.NewGuid().ToString() + Path.GetExtension(flName.PostedFile.FileName); filePath = ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString(); if (flName.PostedFile.ContentLength <= 3048000) { flName.PostedFile.SaveAs((Server.MapPath("~/") + ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"].ToString() + sFileName)); att.SaveAttchement(RequestID, Path.GetFileName(flName.PostedFile.FileName), sFileName, "ETICKET", txtETicketNumber.Text, Convert.ToInt32(Session["USERID"].ToString()), UDFLib.ConvertIntegerToNull(Request.QueryString["SUPPLIER_ID"])); //File.Copy(filePath, @"\\server01\uploads\Travel\ticket\" + sFileName); } } } GetETickets(); } } catch { } finally { TRequest = null; } } else { lblMessage.Text = datasize + " KB File size exceeds maximum limit"; } } else { string js2 = "alert('Upload size not set!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true); } } } }