Exemplo n.º 1
0
        public static List <Model.Account> getEmailCC()
        {
            BLL.Upload objBLL = new BLL.Upload();
            var        list   = new List <Model.Account>();

            list = objBLL.getEmail();
            return(list);
        }
Exemplo n.º 2
0
        protected void ddlCustomer_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            DataTable customerByID;

            BLL.Upload _BLL = new BLL.Upload();

            customerByID             = _BLL.GetCustomerByID(e.Value);
            this.RadGrid1.DataSource = customerByID;
            this.RadGrid1.DataBind();
        }
Exemplo n.º 3
0
        private void initCombo()
        {
            DataTable customer;

            BLL.Upload _BLL = new BLL.Upload();
            customer = _BLL.GetCustomer();
            this.ddlCustomer.AllowCustomText = true;
            this.ddlCustomer.MarkFirstMatch  = true;
            this.ddlCustomer.DataSource      = customer;

            this.ddlCustomer.DataBind();
        }
Exemplo n.º 4
0
        protected void initListbox()
        {
            BLL.Upload objBLL = new BLL.Upload();
            var        list   = new List <Model.Account>();

            list = objBLL.getEmail();


            dlemailCC.DataSource     = list;
            dlemailCC.DataTextField  = "name";
            dlemailCC.DataValueField = "email";
            dlemailCC.DataBind();
        }
Exemplo n.º 5
0
        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(".\\") + "PdfReview/" + fileCurrentName + ".pdf";


            string pageCount;

            BLL.Upload _BLL = new BLL.Upload();
            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("~/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("~/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 PDF to Image success.";
            L.create_by = Session["EMAIL"].ToString();

            Log.WriteLog(L);

            return(true);
        }
Exemplo n.º 6
0
        private bool ReadExcel(string filename)
        {
            FileInfo excel = new FileInfo(Server.MapPath("~/EXCEL/" + filename));

            using (ExcelPackage package = new ExcelPackage(excel))
            {
                ExcelWorkbook workbook = package.Workbook;
                //*** Sheet 1
                ExcelWorksheet worksheet = workbook.Worksheets.First();



                //   job.job_name = worksheet.Cells["A3"].Text;


                List <Model.Supplier> lstSupp = new List <Model.Supplier>();


                int i = 2;

                do
                {
                    Model.Supplier m_supp = new Model.Supplier();

                    m_supp.supp_company          = worksheet.Cells[i, 1].Text.Trim().Replace("'", "");
                    m_supp.supp_code             = worksheet.Cells[i, 2].Text.Trim().Replace("'", "");
                    m_supp.supp_name             = worksheet.Cells[i, 3].Text.Trim().Replace("'", "");
                    m_supp.supp_short_name       = worksheet.Cells[i, 4].Text.Trim().Replace("'", "");
                    m_supp.supp_address_1        = worksheet.Cells[i, 5].Text.Trim().Replace("'", "");
                    m_supp.supp_address_2        = worksheet.Cells[i, 6].Text.Trim().Replace("'", "");
                    m_supp.supp_contact_person   = worksheet.Cells[i, 7].Text.Trim().Replace("'", "");
                    m_supp.supp_contact_position = worksheet.Cells[i, 8].Text.Trim().Replace("'", "");

                    lstSupp.Add(m_supp);
                    i++;
                } while (worksheet.Cells[i, 1].Text != "");


                BLL.Upload _BLL = new BLL.Upload();
                _BLL.InsertSupplier(lstSupp);
            }

            return(true);
        }
Exemplo n.º 7
0
        protected void initDocumentbyID(string doc_id)
        {
            DataTable dt;

            BLL.Upload _BLL = new BLL.Upload();

            Model.Document m_doc = new Model.Document();
            dt = _BLL.getDocument_By_DocId(m_doc_id);

            if (dt.Rows.Count > 0)
            {
                int x = 0;
                Int32.TryParse(dt.Rows[0]["page_count"].ToString(), out x);
                m_doc.page_count      = x;
                Session["PAPER_TYPE"] = dt.Rows[0]["paper_type"].ToString();
                Session["PAGE_COUNT"] = dt.Rows[0]["page_count"].ToString();
                Session["CONTENT"]    = dt.Rows[0]["content"].ToString();
            }
        }
Exemplo n.º 8
0
        protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int         idx = Convert.ToInt32(e.RowIndex);
            GridViewRow Row = grid.Rows[idx];



            Model.Criteria.Document MDL = new Model.Criteria.Document();
            MDL.doc_id = Row.Cells[0].Text;

            BLL.Upload _BLL = new BLL.Upload();
            _BLL.Delete_Document(MDL);

            BindGrid();
            //BLL.job _BLL = new BLL.job();
            //_BLL.Delete_Job(job_id);

            //BindGrid();
        }
Exemplo n.º 9
0
        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);
                }
            }
        }
Exemplo n.º 10
0
        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;
                }
            }
        }
Exemplo n.º 11
0
        void testPostback()
        {
            if (txtNot.Text != "")
            {
                Model.Criteria.Document _doc = new Model.Criteria.Document();
                _doc.doc_id          = doc_id.Value;
                _doc.approve_problem = txtNot.Text;
                BLL.Upload _BLL = new BLL.Upload();
                _BLL.Update_sign_approve_problem(_doc);


                //   Response.Redirect("./DataDocument.aspx");
            }
            else
            {
                Model.Criteria.Document _doc = new Model.Criteria.Document();
                _doc.doc_id          = doc_id.Value;
                _doc.approve_problem = "0";
                BLL.Upload _BLL = new BLL.Upload();
                _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 + "/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 approve success.";
                L.create_by = Session["EMAIL"].ToString();
                Log.WriteLog(L);

                Model.Criteria.Document _Doc = new Model.Criteria.Document();
                BLL.Upload _BLL = new BLL.Upload();

                _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("./DataDocument.aspx");
            }
            else
            {
                //   Response.Redirect("./Pdf/" + tmp + ".Pdf");
            }
        }
Exemplo n.º 12
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string        message = null;
            List <string> _mailCC = new List <string>();

            foreach (ListItem item in dlemailCC.Items)
            {
                if (item.Selected)
                {
                    _mailCC.Add(item.Value);
                }
            }
            //   ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);

            //string[] _mailCC = null;
            //if (strCC != null)
            //{
            //    _mailCC = strCC.Split(',');
            ////String strCC = Request.Form["dlemailCC"].ToString();
            ////string[] _mailCC = null;
            ////if (strCC != null)
            ////{
            ////    _mailCC = strCC.Split(',');
            ////}


            String tmpMail;


            tmpMail = Request.Form["dlemail"].ToString();

            initDataAccount(tmpMail);

            string[]      mailTo       = new string[] { tmpMail };
            List <string> myCollection = new List <string>();      // Attach File

            string serverName    = ConfigurationManager.AppSettings["serverName"];
            string strPathAttach = MapPath(".//AttachFiles/" + Session["DOC_ID"].ToString() + ".zip");

            myCollection.Add(strPathAttach);
            StringBuilder mailBody = new StringBuilder();
            string        sTAB     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

            string mailForm = Session["TITLE"].ToString() + " " + Session["NAME"].ToString() + "   " + Session["SURNAME"].ToString();

            mailBody.AppendLine("<table>");
            mailBody.AppendLine("<tr><td>Subject :" + sTAB + Session["CONTENT"].ToString() + "</td></tr>");
            mailBody.AppendLine("<tr><td>To :" + sTAB + Account.title + "  " + Account.name + "   " + Account.surname + "</td></tr>");
            mailBody.AppendLine("</table><br />");


            string paper_type = Session["PAPER_TYPE"].ToString();
            string page_count = Session["PAGE_COUNT"].ToString();
            string signature;

            BLL.ManageAccount M_BLL = new BLL.ManageAccount();
            signature = M_BLL.Get_Signature_By_Email(tmpMail);



            mailBody.AppendLine("<table>");
            mailBody.AppendLine("<tr><td>Please sign form applicaion <a href='ht" + "tp://" + serverName + "/FrmApplicationReview.aspx?doc_id=" + Session["DOC_ID"].ToString() + "&email=" + tmpMail + "&page_count=" + page_count + "&paper_type=" + paper_type + "&signature=" + signature + "'>Click here.</a> </td></tr>");
            mailBody.AppendLine("<tr><td><BR/></td></tr>");
            mailBody.AppendLine("<tr><td><BR/>Best Regards,<td></tr>");
            mailBody.AppendLine("<tr><td><BR/>" + mailForm + "</td></tr>");
            mailBody.AppendLine("</table><br />");



            Model.Criteria.Document _DOC = new Model.Criteria.Document();
            _DOC.send_mail_approve_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            _DOC.secure_approve         = tmpMail;
            _DOC.doc_id = Session["DOC_ID"].ToString();
            BLL.Upload _BLL = new BLL.Upload();
//_BLL.Update_send_mail_Review(_DOC);


            m_content = Session["CONTENT"].ToString();

            //Helper.Utility.SendEmail(mailTo, _mailCC.ToArray(), m_content,mailBody.ToString(),true,myCollection.ToArray(),mailForm);



            Response.Redirect("DataDocument.aspx");
        }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        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 + "/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 request success.";
                L.create_by = Session["EMAIL"].ToString();
                Log.WriteLog(L);

                Model.Criteria.Document _Doc = new Model.Criteria.Document();
                BLL.Upload _BLL = new BLL.Upload();

                _Doc.sign_prepare_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                _Doc.doc_id            = doc_id.Value;
                _BLL.Update_send_mail_Request(_Doc);


                PdfToImage("", _Doc.doc_id);

                Response.Redirect("./DataDocument.aspx");

//Response.Redirect("./PdfPrepare/" + doc_id.Value + ".Pdf");
            }
            else
            {
                // Response.Redirect("./PdfPrepare/" + doc_id.Value + ".Pdf");
            }
        }
Exemplo n.º 15
0
        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(".\\") + "PdfRequest/" + fileCurrentName + ".pdf";



            string pageCount;

            BLL.Upload _BLL = new BLL.Upload();
            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("~/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("~/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 PDF to Image success.";
            L.create_by = Session["EMAIL"].ToString();

            Log.WriteLog(L);

            return(true);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        //protected void UploadMultipleFiles(object sender, EventArgs e)
        //{

        //    foreach (HttpPostedFile postedFile in FileUpload2.PostedFiles)
        //    {
        //        string fileName = Path.GetFileName(postedFile.FileName);
        //        postedFile.SaveAs(Server.MapPath("~/PDF/") + fileName);
        //    }
        //    lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count);
        //}


        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //// For test

            // String  strCC = Request.Form["dlemailCC"].ToString();
            // string[] _mailCC = null;
            //if (strCC != null)
            //{
            //    _mailCC = strCC.Split(',');
            //}

            //////////

            //String tmpMail;
            //tmpMail = Request.Form["dlemail"].ToString();

            //       string[] mailTo = new string[] {tmpMail };
            List <string> myCollection  = new List <string>();
            List <string> ZipCollection = new List <string>();

            ///  UploadMain PDF

            if (UploadMain())
            {
                HttpFileCollection fileCollection = Request.Files;
                for (int i = 1; i < fileCollection.Count; i++)
                {
                    HttpPostedFile uploadfile = fileCollection[i];
                    string         fileName   = Path.GetFileName(uploadfile.FileName);
                    if (uploadfile.ContentLength > 0)
                    {
                        uploadfile.SaveAs(Server.MapPath("~/AttachFiles/") + fileName);
                        myCollection.Add(Server.MapPath("~/AttachFiles/") + fileName);
                        lblMessage.Text += fileName + "  Saved  Successfully<br>";

                        BLL.Upload _BLL = new BLL.Upload();
                        _BLL.Update_AttachFile(Doc, 1);
                    }

                    else // Update AttachFile 1 = 0
                    {
                        BLL.Upload _BLL = new BLL.Upload();
                        _BLL.Update_AttachFile(Doc, 0);
                    }
                }


                //Zip

                using (Ionic.Zip.ZipFile compress = new Ionic.Zip.ZipFile())
                {
                    string zipfilepath = Server.MapPath("~/AttachFiles/");
                    compress.AddFiles(myCollection.ToArray(), Doc.doc_id);
                    compress.Save(Server.MapPath("~/AttachFiles/") + Doc.doc_id + ".zip");
                }

                Response.Redirect("DataDocument.aspx");
            }


            //     Helper.Utility.SendEmail("Test ODS",mailTo, _mailCC , myCollection.ToArray(),"This is link",false);

            //       Response.Redirect("Default.aspx");
        }