protected void LogIn(object sender, EventArgs e) { if (IsValid) { String _userName, _password; _userName = UserName.Text.ToString(); _password = Password.Text.ToString(); String sql; DataTable dt; sql = "Select * from account where username='******' AND password='******'"; clsDB conn = new clsDB(); dt = conn.ExecuteDataTable(sql); if (dt.Rows.Count > 0) { Session["TITLE"] = dt.Rows[0]["title"].ToString(); Session["NAME"] = dt.Rows[0]["name"].ToString(); Session["SURNAME"] = dt.Rows[0]["surname"].ToString(); Session["LEVEL"] = dt.Rows[0]["level"].ToString(); Session["EMAIL"] = dt.Rows[0]["email"].ToString(); Session["SIGNATURE"] = dt.Rows[0]["signature"].ToString(); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Log in success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("../DataDocument.aspx"); } else { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Log in fail."; L.create_by = _userName; Log.WriteLog(L); } // // Validate the user password // var manager = new UserManager(); // ApplicationUser user = manager.Find(UserName.Text, Password.Text); // if (user != null) // { // IdentityHelper.SignIn(manager, user, RememberMe.Checked); // IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); // } // else // { // FailureText.Text = "Invalid username or password."; // ErrorMessage.Visible = true; // } } }
private bool PdfToImage(string pdfName, string fileCurrentName) { int desired_x_dpi = 300; int desired_y_dpi = 300; string ServerPath = Server.MapPath(".\\"); string pdfPath = Server.MapPath(".\\") + "PO_PdfReview/" + fileCurrentName + ".pdf"; string pageCount; BLL.PO _BLL = new BLL.PO(); pageCount = _BLL.Get_PageCount(Session["DOC_ID"].ToString()); using (var rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(pdfPath); for (var pageNumber = 1; pageNumber <= int.Parse(pageCount); pageNumber++) { if (int.Parse(pageCount) > 1) { var pageFilePath = Path.Combine(Server.MapPath("~/PO_PdfToImageReview/"), fileCurrentName + "_" + (pageNumber) + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } else { var pageFilePath = Path.Combine(Server.MapPath("~/PO_PdfToImageReview/"), fileCurrentName + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } } } Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Convert PO PDF to Image success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); return(true); }
void testPostback() { string currentFile = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/tmpFrmApplication.html"; //string currentFile = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/testHtml.html"; var url = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/PO_FrmApplicationRequest.aspx?doc_id=" + doc_id.Value + "&signature=" + signature_file.Value + "&page_count=" + page_count.Value + "&paper_type=" + paper_type.Value; var http = (HttpWebRequest)WebRequest.Create(url); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); string content = sr.ReadToEnd(); Int32 pos_start, pos_stop; string MidString; pos_start = content.IndexOf("submit", 0); pos_stop = content.IndexOf("/>", pos_start); MidString = content.Substring(pos_start - 13, (pos_stop + 2) - (pos_start - 13)); content = content.Replace(MidString, ""); //content = content.Replace("Images/", "Images/" + signature_file.Value); //content = content.Replace("PdfToImage/", "PdfToImage/" + doc_id.Value); content = content.Replace("top:123px", "top:" + dTop.Value.Replace("'", "")); content = content.Replace("left:123px", "left:" + dLeft.Value.Replace("'", "")); content = content.Replace("hidden='hidden'", ""); content = content.Replace("<div class='row vertical-center-row'><div class='text-center col-md-1 col-md-offset-1'></div></div></div>", ""); //if (paper_type.Value =="L") //{ // content = content.Replace("width='790'", "width='1120'"); // content = content.Replace("height='1120'", "height='790'"); //} string path = System.AppDomain.CurrentDomain.BaseDirectory + "tmpFrmApplication.html"; System.IO.File.WriteAllText(path, content); // test git // string currentFile = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/tmpFormApplication.html"; //DateTime time = DateTime.Now; //string format = "M-d-h-mm-ss"; //string tmp = time.ToString(format); if (HtmlToPdf(currentFile, doc_id.Value, paper_type.Value)) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Sign PO request success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Model.PO_Document _Doc = new Model.PO_Document(); BLL.PO _BLL = new BLL.PO(); _Doc.sign_prepare_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _Doc.doc_id = doc_id.Value; _BLL.Update_sign_prepare_date(_Doc); PdfToImage("", _Doc.doc_id); Response.Redirect("./PO_DataDocument.aspx"); //Response.Redirect("./PdfPrepare/" + doc_id.Value + ".Pdf"); } else { // Response.Redirect("./PdfPrepare/" + doc_id.Value + ".Pdf"); } }
private bool PdfToImage(string pdfName, string fileCurrentName) { int desired_x_dpi = 300; int desired_y_dpi = 300; string ServerPath = Server.MapPath(".\\"); string pdfPath = Server.MapPath(".\\") + "PO_PdfRequest/" + fileCurrentName + ".pdf"; string pageCount; BLL.PO _BLL = new BLL.PO(); pageCount = _BLL.Get_PageCount(Session["DOC_ID"].ToString()); //for (int i = 0; i < int.Parse(pageCount); i++) //{ // if (int.Parse(pageCount) > 1) // { // zoomImg.Save(@ServerPath + "/PdfToImageApprove/" + fileCurrentName + "_" + (i + 1) + ".PNG"); // } // else // { // zoomImg.Save(@ServerPath + "/PdfToImageApprove/" + fileCurrentName + ".PNG"); // } //} using (var rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(pdfPath); for (var pageNumber = 1; pageNumber <= int.Parse(pageCount); pageNumber++) { if (int.Parse(pageCount) > 1) { var pageFilePath = Path.Combine(Server.MapPath("~/PO_PdfToImageRequest/"), fileCurrentName + "_" + (pageNumber) + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } else { var pageFilePath = Path.Combine(Server.MapPath("~/PO_PdfToImageRequest/"), fileCurrentName + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } } } //Model.Criteria.Document doc = new Model.Criteria.Document(); //doc.doc_id = fileCurrentName; //doc.upload_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); //BLL.Upload _BLL = new BLL.Upload(); //int ret; //ret = _BLL.Update_upload_date(doc); // Write LOG Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Convert PO PDF to Image success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); return(true); }
void testPostback() { if (txtNot.Text != "") { Model.PO_Document _doc = new Model.PO_Document(); _doc.doc_id = doc_id.Value; _doc.approve_problem = txtNot.Text; BLL.PO _BLL = new BLL.PO(); _BLL.Update_sign_approve_problem(_doc); // Response.Redirect("./DataDocument.aspx"); } else { Model.PO_Document _doc = new Model.PO_Document(); _doc.doc_id = doc_id.Value; _doc.approve_problem = "0"; BLL.PO _BLL = new BLL.PO(); _BLL.Update_sign_approve_problem(_doc); } string currentFile = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/tmpFrmApplication.html"; var url = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/PO_FrmApplicationApprove.aspx?doc_id=" + doc_id.Value + "&signature=" + signature_file.Value + "&page_count=" + page_count.Value + "&paper_type=" + paper_type.Value + "&top=" + dTop.Value + "&left=" + dLeft.Value; var http = (HttpWebRequest)WebRequest.Create(url); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); string content = sr.ReadToEnd(); Int32 pos_start, pos_stop; string MidString; pos_start = content.IndexOf("submit", 0); pos_stop = content.IndexOf("/>", pos_start); MidString = content.Substring(pos_start - 13, (pos_stop + 2) - (pos_start - 13)); content = content.Replace(MidString, ""); pos_start = content.IndexOf("txtNot", 0); pos_stop = content.IndexOf("/>", pos_start); MidString = content.Substring(pos_start - 13, (pos_stop + 2) - (pos_start - 13)); content = content.Replace(MidString, ""); content = content.Replace("top:5000px", "top:" + dTop.Value.Replace("'", "")); content = content.Replace("left:5000px", "left:" + dLeft.Value.Replace("'", "")); if (txtNot.Text == "") { content = content.Replace("hidden='hidden'", ""); } string path = System.AppDomain.CurrentDomain.BaseDirectory + "tmpFrmApplication.html"; System.IO.File.WriteAllText(path, content); // string currentFile = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/tmpFormApplication.html"; DateTime time = DateTime.Now; string format = "M-d-h-mm-ss"; string tmp = time.ToString(format); if (HtmlToPdf(currentFile, doc_id.Value, paper_type.Value)) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Sign PO approve success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Model.PO_Document _Doc = new Model.PO_Document(); BLL.PO _BLL = new BLL.PO(); _Doc.sign_approve_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _Doc.doc_id = doc_id.Value; _BLL.Update_sign_approve_date(_Doc); ///////////////////////// ReplyMail(); Response.Redirect("./PO_DataDocument.aspx"); } else { // Response.Redirect("./Pdf/" + tmp + ".Pdf"); } }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridDataItem dataItem = null; if (e.Item is GridDataItem) { dataItem = e.Item as GridDataItem; int selectedRowIndex = dataItem.RowIndex; } if (e.CommandName == "PO_PDF") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View PO " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PO_Pdf/" + filename + ".pdf"); //if (!File.Exists(path)) //{ // Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); // return; //} byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } if (e.CommandName == "PDF_Approve") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View PR Approve " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PdfApprove/" + filename + ".pdf"); //if (!File.Exists(path)) //{ // Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); // return; //} byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } if (e.CommandName == "PO_PDF_APPROVE") { string filename = e.CommandArgument.ToString(); try { if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View PO Approve " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PO_PdfApprove/" + filename + ".pdf"); //if (!File.Exists(path)) //{ // Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); // return; //} byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } catch (FileNotFoundException Exception) { } } // Attath file if (e.CommandName == "cmd") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Download attach file name " + filename + ".zip"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PO_AttachFiles/" + filename + ".zip"); byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".zip"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } if (e.CommandName == "step2") { int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailRequest.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Request.');</script>"); } else if (e.CommandArgument.ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); } else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go PO_SendMailRequest.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("PO_SendMailRequest.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } if (e.CommandName == "step3") { int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Review.');</script>"); } //else if ( e.CommandArgument.ToString() == "1") //{ // Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); //} else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to PO_SendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("PO_SendMailReview.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } if (e.CommandName == "step4") { int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Review.');</script>"); } //else if ( e.CommandArgument.ToString() == "1") //{ // Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); //} else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to PO_SendMailApprove.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("PO_SendMailApprove.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } }
private bool PdfToImage(string pdfName, string fileCurrentName) { int desired_x_dpi = 300; int desired_y_dpi = 300; int pageCount = 1; string ServerPath = Server.MapPath(".\\"); string pdfPath = Server.MapPath("~/Pdf/" + fileCurrentName + ".pdf"); PdfSharp.Pdf.PdfDocument inputDocument = PdfReader.Open(pdfPath, PdfDocumentOpenMode.ReadOnly); int widthPage = 0; widthPage = (int)inputDocument.Pages[0].Width; if (widthPage > 800) { paper_type = "L"; } else { paper_type = "P"; } using (var rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(pdfPath); pageCount = rasterizer.PageCount; for (var pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++) { if (rasterizer.PageCount > 1) { var pageFilePath = Path.Combine(Server.MapPath("~/PdfToImage/"), fileCurrentName + "_" + (pageNumber) + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } else { var pageFilePath = Path.Combine(Server.MapPath("~/PdfToImage/"), fileCurrentName + ".PNG"); var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath); } } } Model.Criteria.Document doc = new Model.Criteria.Document(); doc.doc_id = fileCurrentName; doc.upload_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); doc.page_count = pageCount; doc.paper_type = paper_type; BLL.Upload _BLL = new BLL.Upload(); _BLL.Update_upload_date(doc); // Write LOG Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Convert PDF to Image success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); return(true); }
private bool UploadMain() { if (FileUpload1.HasFile) { string folderPath = Server.MapPath("~/Pdf/"); //Check whether Directory (Folder) exists. if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists. Create it. Directory.CreateDirectory(folderPath); } FileUpload fu = FileUpload1; String fileExtension = System.IO.Path.GetExtension(fu.FileName).ToLower(); String[] allowedExtensions = { ".pdf" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { try { ClsModule mdl = new ClsModule(); Doc.doc_id = mdl.getRuningNoDoc(); Doc.doc_name = fu.FileName; Doc.create_by = Session["NAME"].ToString(); Doc.secure_prepare = Session["EMAIL"].ToString(); Doc.attach_file_name = Doc.doc_id + ".zip"; Doc.content = Content.Text; Doc.pr_flag = 1; Doc.suplier_id = ddlCustomer.SelectedValue.ToString(); Doc.supplier_name = ddlCustomer.Text; Doc.comment = comment.Value; string s_newfilename = Doc.doc_id + fileExtension; fu.PostedFile.SaveAs(folderPath + s_newfilename); Thread.Sleep(3000); // Insert DB string ret; BLL.Upload _BLL = new BLL.Upload(); string temp; ret = _BLL.InsertDocument_step1(Doc); if (ret == "1") { Response.Write("1"); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Upload success."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); PdfToImage("", Doc.doc_id); } else { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Can not upload."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); } // lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded."; //imagepath = ImageSavedPath + s_newfilename; return(true); } catch (Exception ex) { Response.Write(ex.Message); Response.Write("File could not be uploaded."); Response.End(); // return false; } } else { Response.Write("Please upload pdf file only."); return(false); } } return(true); } else { Response.Write("<script>alert('โปรดเลือกเอกสารที่ต้องการ Approve ก่อน');</script>"); return(false); } }
private bool UploadMain() { if (FileUpload1.HasFile) { string folderPath = Server.MapPath("~/EXCEL/"); //Check whether Directory (Folder) exists. if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists. Create it. Directory.CreateDirectory(folderPath); } FileUpload fu = FileUpload1; String fileExtension = System.IO.Path.GetExtension(fu.FileName).ToLower(); String[] allowedExtensions = { ".xlsx" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { try { string job_id; ClsModule mdl = new ClsModule(); job_id = mdl.getRuningNoDoc(); //Doc.doc_name = fu.FileName; //Doc.create_by = Session["NAME"].ToString(); //Doc.secure_prepare = Session["EMAIL"].ToString(); //Doc.attach_file_name = Doc.doc_id + ".zip"; //Doc.content = Content.Text; string s_newfilename = job_id + fileExtension; fu.PostedFile.SaveAs(folderPath + s_newfilename); ClsModule obj = new ClsModule(); MODEL.Log L = new MODEL.Log(); Helper.Utility Log = new Helper.Utility(); L.ip = obj.GetIPAddress(); L.page = obj.getPageName(); L.content = "Upload success."; L.create_by = ""; // Session["EMAIL"].ToString(); Log.WriteLog(L); ReadExcel(job_id); genBarcode(job_id); Response.Redirect("DataJob.aspx"); // lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded."; //imagepath = ImageSavedPath + s_newfilename; return(true); } catch (Exception ex) { Response.Write("File could not be uploaded." + ex.Message); return(false); } } else { Response.Write("Please upload xlsx file only."); return(false); } } return(true); } else { Response.Write("<script>alert('โปรดเลือกไฟล์ก่อน');</script>"); return(false); } }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridDataItem dataItem = null; if (e.Item is GridDataItem) { dataItem = e.Item as GridDataItem; int selectedRowIndex = dataItem.RowIndex; } if (e.CommandName == "PDF_PREPARE2") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View Prepare " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("Pdf/" + filename + ".pdf"); //if (!File.Exists(path)) //{ // Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); // return; //} byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } // Attath file if (e.CommandName == "lnkDownload") { // ajxMgr.ResponseScripts.Add((string.Format("alert('Hello from the server! Server time is {0}');", DateTime.Now.ToLongTimeString()))); try { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Download attach file name " + filename + ".zip"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("AttachFiles/" + filename + ".zip"); byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".zip"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } catch (FileNotFoundException exeception) { } } if (e.CommandName == "step22") { //GridDataItem dataItem =null; DataTable _dt; _dt = (DataTable)Session["DT"]; int index = Convert.ToInt32(e.CommandArgument); ////if (e.Item is GridDataItem) ////{ ////dataItem = e.Item as GridDataItem; //// int selectedRowIndex = dataItem.RowIndex; ////} if (dataItem.Cells[4].Text != Session["EMAIL"].ToString()) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to FrmApplicationPrepare."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ Sign prepare.');</script>"); } else if (_dt.Rows[index]["step2"].ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถ Sign prepare ได้เนื่องจาก Sign ไปแล้ว');</script>"); } else { string page_count = ""; string doc_id; string signature; string paper_type; BLL.Upload _BLL = new BLL.Upload(); doc_id = dataItem.Cells[0].Text; page_count = _BLL.get_Pagecount(doc_id); paper_type = _BLL.Get_Paper_type(doc_id); signature = Session["SIGNATURE"].ToString(); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to FrmApplicationPrepare."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("FrmApplicationRequest.aspx?doc_id=" + doc_id + "&signature=" + signature + "&page_count=" + page_count + "&paper_type=" + paper_type); } } if (e.CommandName == "step2") { int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailRequest.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Request.');</script>"); } else if (e.CommandArgument.ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); } else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to SendMailRequest.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("SendMailRequest.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } if (e.CommandName == "step3") { if (!Convert.ToBoolean(DataBinder.Eval(dataItem.DataItem, "step2"))) { RadWindowManager1.RadAlert("ไม่สามารถส่งเมล์ Review ได้ต้องทำการ Request ก่อน", 200, 100, "Alert", "callBackFn"); return; } int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Review.');</script>"); } //else if ( e.CommandArgument.ToString() == "1") //{ // Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); //} else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to SendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("SendMailReview.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } if (e.CommandName == "step4") { if (!Convert.ToBoolean(DataBinder.Eval(dataItem.DataItem, "step3"))) { RadWindowManager1.RadAlert("ไม่สามารถส่งเมล์ Approve ได้ต้องทำการ Review ก่อน", 200, 100, "Alert", "callBackFn"); return; } int idx = Convert.ToInt32(e.CommandArgument); if (Session["LEVEL"].ToString() != "2") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailReview.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Review.');</script>"); } //else if ( e.CommandArgument.ToString() == "1") //{ // Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); //} else { string doc_id; string email; string content; doc_id = dataItem.Cells[2].Text; email = Session["EMAIL"].ToString(); content = dataItem.Cells[4].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to SendMailApprove.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("SendMailApprove.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } if (e.CommandName == "PDF_APPROVE") { try { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View PR Complete " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PdfApprove/" + filename + ".pdf"); //if (!File.Exists(path)) //{ // Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); // return; //} byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } catch (FileNotFoundException exception) { } } if (e.CommandName == "OPEN_PO") { if (Convert.ToBoolean(DataBinder.Eval(dataItem.DataItem, "step4"))) { string filename = e.CommandArgument.ToString(); if (filename != "") { Response.Redirect("Upload_PO.aspx?doc_id=" + filename + "&content=" + dataItem.Cells[4].Text); } } else { RadWindowManager1.RadAlert("ไม่สามารถเปิด PO ได้ต้องทำ PR ให้เสร็จทุกขั้นตอนก่อน", 200, 100, "Alert", "callBackFn"); return; } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { String _userName, _password; _userName = UserName.Text.ToString(); _password = Password.Text.ToString(); String sql; DataTable dt; sql = "Select * from account where username='******' AND password='******'"; Class.clsDB conn = new Class.clsDB(); dt = conn.ExecuteDataTable(sql); if (dt.Rows.Count > 0) { Session["TITLE"] = dt.Rows[0]["title"].ToString(); Session["NAME"] = dt.Rows[0]["name"].ToString(); Session["SURNAME"] = dt.Rows[0]["surname"].ToString(); Session["LEVEL"] = dt.Rows[0]["level"].ToString(); Session["EMAIL"] = dt.Rows[0]["email"].ToString(); Session["PLACE_TYPE"] = dt.Rows[0]["place_type"].ToString(); string place_type = dt.Rows[0]["place_type"].ToString(); string Lev = dt.Rows[0]["level"].ToString(); Class.ClsModule obj = new Class.ClsModule(); string IP = obj.GetIPAddress(); string page = obj.getPageName(); MODEL.Log L = new MODEL.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Log in success."; L.create_by = Session["EMAIL"].ToString(); L.ip = IP; L.page = page; Log.WriteLog(L); switch (place_type) { case "A": Response.Redirect("~/PlaceA.aspx"); break; case "B": Response.Redirect("~/PlaceB.aspx"); break; case "C": Response.Redirect("~/PlaceC.aspx"); break; case "Z": Response.Redirect("~/PlaceZ.aspx"); break; } Response.Redirect("../Default.aspx"); } } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "step2") { DataTable _dt; _dt = (DataTable)Session["DT"]; int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = grid.Rows[index]; if (selectedRow.Cells[4].Text != Session["EMAIL"].ToString()) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to FrmApplicationPrepare."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ Sign prepare.');</script>"); } else if (_dt.Rows[index]["step2"].ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถ Sign prepare ได้เนื่องจาก Sign ไปแล้ว');</script>"); } else { string page_count = ""; string doc_id; string signature; string paper_type; BLL.Upload _BLL = new BLL.Upload(); doc_id = selectedRow.Cells[0].Text; page_count = _BLL.get_Pagecount(doc_id); paper_type = _BLL.Get_Paper_type(doc_id); signature = Session["SIGNATURE"].ToString(); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to FrmApplicationPrepare."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("FrmApplicationPrepare.aspx?doc_id=" + doc_id + "&signature=" + signature + "&page_count=" + page_count + "&paper_type=" + paper_type); } } // APPROVE CHECK SECURE_APPROVE if (e.CommandName == "step4") { DataTable _dt; _dt = (DataTable)Session["DT"]; int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = grid.Rows[index]; if (selectedRow.Cells[14].Text != Session["EMAIL"].ToString()) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to FrmApplicationApprove."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ Sign Approve.');</script>"); } else if (_dt.Rows[index]["step4"].ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถ Sign approve ได้เนื่องจากได้ Sign ไปแล้ว');</script>"); } else { string doc_id; string signature; string page_count; string paper_type; doc_id = selectedRow.Cells[0].Text; BLL.Upload _BLL = new BLL.Upload(); page_count = _BLL.get_Pagecount(doc_id); paper_type = _BLL.Get_Paper_type(doc_id); signature = Session["SIGNATURE"].ToString(); Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to FrmApplicationApprove."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("FrmApplicationApprove.aspx?doc_id=" + doc_id + "&signature=" + signature + "&page_count=" + page_count + "&paper_type=" + paper_type); } } if (e.CommandName == "cmd") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Download attach file name " + filename + ".zip"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("AttachFiles/" + filename + ".zip"); byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".zip"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } if (e.CommandName == "PDF_APPROVE") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View Approve " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PdfApprove/" + filename + ".pdf"); if (!File.Exists(path)) { Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign approve.');</script>"); return; } byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } if (e.CommandName == "PDF_PREPARE") { string filename = e.CommandArgument.ToString(); if (filename != "") { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "View Prepare " + filename + ".pdf"; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); string path = MapPath("PdfPrepare/" + filename + ".pdf"); if (!File.Exists(path)) { Response.Write("<script>alert('ไฟล์นี้ยังไม่ได้ถูก Sign prepare.');</script>"); return; } byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-Type", "Application/octet-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } } //if (e.CommandName == "DELETE") //{ // int index = Convert.ToInt32(e.CommandArgument); // GridViewRow selectedRow = grid.Rows[index]; // if(selectedRow.Cells[5].Text != Session["EMAIL"].ToString()) // { // Model.Log L = new Model.Log(); // Helper.Utility Log = new Helper.Utility(); // L.content = "[Access denied!] Delete " + selectedRow.Cells[0].Text; // L.create_by = Session["EMAIL"].ToString(); // Log.WriteLog(L); // } // else // { // Model.Log L = new Model.Log(); // Helper.Utility Log = new Helper.Utility(); // Model.Criteria.Document criteria = new Model.Criteria.Document(); // criteria.doc_id = selectedRow.Cells[0].Text; // BLL.Upload BL = new BLL.Upload(); // BL.Delete_Document(criteria); // L.content = "Delete Documnet " + selectedRow.Cells[0].Text; // L.create_by = Session["EMAIL"].ToString(); // Log.WriteLog(L); // BindGrid(); // } // } if (e.CommandName == "step3") { DataTable _dt; _dt = (DataTable)Session["DT"]; int idx = Convert.ToInt32(e.CommandArgument); GridViewRow Row = grid.Rows[idx]; if (Row.Cells[4].Text != Session["EMAIL"].ToString()) { Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "[Access denied!] Go to sendMailApprove.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Write("<script>alert('คุณไม่มีสิทธิ์ส่งเมล์เพื่อ Approve.');</script>"); } else if (_dt.Rows[idx]["step2"].ToString() == "0") { Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากเอกสารยังไม่ได้ Sign prepare.');</script>"); } else if (_dt.Rows[idx]["step3"].ToString() == "1") { Response.Write("<script>alert('คุณไม่สามารถส่งเมล์ได้เนื่องจากส่งไปแล้ว');</script>"); } else { string doc_id; string email; string content; doc_id = Row.Cells[0].Text; email = Session["EMAIL"].ToString(); content = Row.Cells[2].Text; Model.Log L = new Model.Log(); Helper.Utility Log = new Helper.Utility(); L.content = "Go to SendMailApprove.aspx."; L.create_by = Session["EMAIL"].ToString(); Log.WriteLog(L); Response.Redirect("SendMailApprove.aspx?doc_id=" + doc_id + "&email=" + email + "&content=" + content); } } }