protected void btnSave_Click(object sender, EventArgs e) { lblMessage.Text = ""; DataTable dt = new DataTable(); dt = objUploadFilesize.Get_Module_FileUpload("QMS_"); if (dt.Rows.Count > 0) { string datasize = dt.Rows[0]["Size_KB"].ToString(); if (CheckInfileUp.HasFile) { if (CheckInfileUp.PostedFile.ContentLength < Int32.Parse(dt.Rows[0]["Size_KB"].ToString()) * 1024) { string FileName = System.IO.Path.GetFileName(CheckInfileUp.PostedFile.FileName); if (FileName.ToUpper().Equals(txtFileName.Text.ToUpper()) == true) { //get latest File details by the file ID DataSet dsFileDetails = objQMS.getFileDetailsByID(fileID, 0); if (dsFileDetails.Tables[0].Rows.Count > 0) { //string[] filePath = dsFileDetails.Tables[0].Rows[0]["FilePath"].ToString().Split('/'); string PhPath = dsFileDetails.Tables[0].Rows[0]["FilePath"].ToString().Replace("/", "\\"); string oldfileName = System.IO.Path.GetFileName(dsFileDetails.Tables[0].Rows[0]["FilePath"].ToString()); string DestinationPath = Server.MapPath(PhPath); string sFileExt = System.IO.Path.GetExtension(FileName); string sGuidFileName = "QMS_" + System.Guid.NewGuid() + sFileExt; DestinationPath = DestinationPath.Replace(oldfileName, sGuidFileName); CheckInfileUp.PostedFile.SaveAs(DestinationPath); FileInfo f = new FileInfo(DestinationPath); long filelengh = f.Length; objQMS.insertRecordAtCheckIN(fileID, sGuidFileName, Convert.ToInt32(Session["USERID"]), filelengh); //string[] createFolderPathText = DestinationPath.Split('\\'); //string TargetFolder = DestinationPath.Replace(createFolderPathText[createFolderPathText.Length - 1].ToString(), "") + FileInfoAfterUpdationDB.Tables[0].Rows[0]["ID"].ToString(); //System.IO.Directory.CreateDirectory(DestinationPath); BLL_Infra_UploadFileSize objBLL = new BLL_Infra_UploadFileSize(); int rowcountx = 0; long defsize = 450 * 1024; DataTable dtx = objBLL.SearchConfigureFileSize("QMS_", null, null, 1, 10, ref rowcountx); if (dtx.Rows.Count > 0) { if (dtx.Rows[0]["Syncable"].ToString() == "1") { defsize = Convert.ToInt32(dtx.Rows[0]["Size_KB"]) * 1024; } } long sizeinkb = defsize / 1024; String msg = String.Format("myMessage('File is checked-in successfully,\\nPlease browse the file from tree to see latest.');window.parent.location.href='fileloader.aspx?docid=" + fileID + "';"); if (filelengh > defsize) { msg = String.Format("myMessage('File is checked-in successfully,\\nPlease browse the file from tree to see latest.\\nThis file exceeds the file size limit(" + sizeinkb + "KB), you have to sync this file manually');window.parent.location.href='fileloader.aspx?docid=" + fileID + "';"); } txtRemarks.Text = ""; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true); } } else { String msg2 = String.Format("myMessage('Sorry you have browsed diffrent file,\\n please select file as mentioned in Document Name.')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg2", msg2, true); } } else { lblMessage.Text = datasize + " KB File size exceeds maximum limit"; } } else { String msg = String.Format("myMessage('Please browse required document to upload into server')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true); } } else { string js2 = "alert('Upload size not set!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true); } }
/// 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); } } } }