Esempio n. 1
0
        public ActionResult detdel(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string cdel  = Request["cdel"];
            string vcid  = Request["vcid"];
            string vcdid = Request["vcdid"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("AitagBill_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string money1 = dbobj.get_dbvalue(conn1, "select ('專案編號' + vcno + ',品項' + bdprodno + ',金額' + convert(char,vcallmoney)) as st1  from vend_contractdet where vcdid = '" + condtionArr[i].ToString() + "'");

                        sysnote += money1 + "<br>";
                        //刪除明細資料
                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM vend_contractdet where vcdid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/custcontract/detlist' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden id='vcid' name='vcid' value='" + vcid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";

                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });
                }
            }
        }
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string qcerno = "";

            if (!string.IsNullOrWhiteSpace(Request["qcerno"]))
            {
                qcerno         = Request["qcerno"].Trim();
                ViewBag.qcerno = qcerno;
            }
            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                string tgourl = "/certifycheck/List?page=" + page + "&qcerno=" + qcerno + "&qcerno=" + qcerno;
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string cerno = dbobj.get_dbvalue(conn1, "select cerno from certifycheck where cerno ='" + condtionArr[i].ToString() + "'");

                        sysnote += "認證申請編號:" + cerno + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM certifycheck where cerno = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/certifycheck/List?page=" + page + "&qcerno=" + qcerno + "&qcerno=" + qcerno;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
        private void logcheckEditMailBack(delholidaylog col)
        {
            NDcommon dbobj = new NDcommon();

            #region 寄送mail給申請人
            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
            {
                string fromadd = "", fromaddname = "", toadd = "";
                fromadd     = dbobj.get_dbvalue(conn, "select enemail from employee where empid='" + Request["empid"] + "'");
                fromaddname = dbobj.get_dbvalue(conn, "select empname from employee where empid='" + Request["empid"] + "'");
                toadd       = dbobj.get_dbvalue(conn, "select enemail from employee where empid='" + col.empid + "'");
                string mailtitle = "", MailContext = "";
                mailtitle   = "銷假單資料退回";
                MailContext = "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=BIG5'></HEAD><body>";
                MailContext = MailContext + "以下為明細資料:<BR>";
                MailContext = MailContext + "<table cellpadding=3 cellspacing=0 bordercolorlight=#000000 bordercolordark=ffffff border=1 width=400 bgcolor=ffffff style='FONT-SIZE: 11pt;FONT-FAMILY:Tahoma,Arial'>";
                MailContext = MailContext + "<tr><td align=right width=130>請假單號:</td><td>" + col.hsno + "</td></tr>";
                MailContext = MailContext + "<tr><td align=right width=130>申請人:</td><td>" + col.empname + "</td></tr>";
                MailContext = MailContext + "<tr><td align=right width=130>假別:</td><td>" + Request["hdaytitle"] + "</td></tr>";

                string hlogsdate = dbobj.get_dbDate(col.hlogsdate, "yyyy/MM/dd");
                string hlogedate = dbobj.get_dbDate(col.hlogedate, "yyyy/MM/dd");
                string SEDate    = "自{0} ({1})<br>至{2} ({3})";
                SEDate      = string.Format(SEDate, hlogsdate, col.hlogstime, hlogedate, col.hlogetime);
                MailContext = MailContext + "<tr><td align=right width=130>日期起訖:</td><td>" + SEDate + "</td></tr>";
                MailContext = MailContext + "<tr><td align=right width=130>共計時數:</td><td>" + col.hloghour + "</td></tr>";

                if (dbobj.get_dbnull2(col.hlogcomment) != "")
                {
                    MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>" + col.hlogcomment.ToString().Trim().Replace(Environment.NewLine, "<br>") + "</td></tr>";
                }
                else
                {
                    MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>&nbsp;</td></tr>";
                }


                MailContext = MailContext + "</table>";
                MailContext = MailContext + "</body></HTML>";

                dbobj.send_mailfile("", toadd, mailtitle, MailContext, null, null);
            }
            #endregion
        }
Esempio n. 4
0
        private void getSUMhour(string sqlstr, string sqlstr_1)
        {
            NDcommon dbobj = new NDcommon();

            using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
            {
                ViewBag.otloghour = dbobj.get_dbvalue(comconn, sqlstr_1);
                using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                {
                    string txtosno = "", sqlstr_2 = "";
                    using (SqlCommand cmd = new SqlCommand(sqlstr, conn))
                    {
                        SqlDataReader dr = cmd.ExecuteReader();
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                txtosno += "'" + dbobj.get_dbnull2(dr["osno"]) + "',";
                            }
                            sqlstr_2 = "select isnull(sum(resthour),0) as resthour,isnull(sum(moneyhour),0) as moneyhour from resthourlog where osno in (" + txtosno.Substring(0, txtosno.Length - 1) + ") and comid='" + (string)Session["comid"] + "'";
                        }
                        else
                        {
                            sqlstr_2 = "select isnull(sum(resthour),0) as resthour,isnull(sum(moneyhour),0) as moneyhour from resthourlog where 1<>1";
                        }
                        dr.Close();
                    }
                    using (SqlCommand cmd = new SqlCommand(sqlstr_2, conn))
                    {
                        SqlDataReader dr = cmd.ExecuteReader();
                        if (dr.HasRows)
                        {
                            dr.Read();
                            ViewBag.sumresthour  = dbobj.get_dbnull2(dr["resthour"]);
                            ViewBag.summoneyhour = dbobj.get_dbnull2(dr["moneyhour"]);
                        }
                        else
                        {
                            ViewBag.sumresthour  = "0";
                            ViewBag.summoneyhour = "0";
                        }
                    }
                }
            }
        }
        public ActionResult List1(int?page, string orderdata, string orderdata1)
        {
            ViewBag.uplink = Int32.Parse(Request["uplink"]);

            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "corder";
            }

            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qsublevelname1 = "";

            if (!string.IsNullOrWhiteSpace(Request["qsublevelname1"]))
            {
                qsublevelname1         = Request["qsublevelname1"].Trim();
                ViewBag.qsublevelname1 = qsublevelname1;
            }

            IPagedList <sublevel1> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                NDcommon      dbobj   = new NDcommon();
                SqlConnection sysconn = dbobj.get_conn("Aitag_DBContext");
                ViewBag.uplinkname = dbobj.get_dbvalue(sysconn, "select sublevelname from sublevel1 where sid = '" + Request["uplink"] + "'");
                sysconn.Close();
                sysconn.Dispose();
                string sqlstr = "select * from sublevel1 where lid = '3' and uplink = '" + Request["uplink"] + "'  and ";
                if (qsublevelname1 != "")
                {
                    sqlstr += " sublevelname like '%" + qsublevelname1 + "%'  and";
                }

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.sublevel1.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <sublevel1>(page.Value - 1, (int)Session["pagesize"]);
            }
            return(View(result));
        }
        public ActionResult subreadwritelist(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "srwid";
            }

            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qsublevelname1 = "", tmpsid = "";

            if (!string.IsNullOrWhiteSpace(Request["qsublevelname1"]))
            {
                qsublevelname1         = Request["qsublevelname1"].Trim();
                ViewBag.qsublevelname1 = qsublevelname1;
            }

            tmpsid = Request["tmpsid"];
            IPagedList <subreadwrite> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                NDcommon      dbobj   = new NDcommon();
                SqlConnection sysconn = dbobj.get_conn("Aitag_DBContext");
                ViewBag.uplinkname = dbobj.get_dbvalue(sysconn, "select sublevelname from sublevel1 where sid = '" + tmpsid + "'");
                sysconn.Close();
                sysconn.Dispose();
                string sqlstr = "select * from subreadwrite where sid = '" + tmpsid + "'  and ";

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by srwid";

                var query = con.subreadwrite.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <subreadwrite>(page.Value - 1, (int)Session["pagesize"]);
            }
            return(View(result));
        }
Esempio n. 7
0
        public ActionResult DeleteConfirmed(string id, int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "mcno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qmcno = "", qmctitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qmcno"]))
            {
                qmcno         = Request["qmcno"].Trim();
                ViewBag.qmcno = qmcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qitemcode"]))
            {
                qmctitle         = Request["qmctitle"].Trim();
                ViewBag.qmctitle = qmctitle;
            }

            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("AitagBill_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string ebillsubjects = dbobj.get_dbvalue(conn1, "select mcno from mediaclass where mcno = '" + condtionArr[i].ToString() + "'");

                        sysnote += "代碼:" + ebillsubjects + "<br>";

                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM mediaclass where mcno = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/mediaclass/List' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qmcno' name='qmcno' value='" + qmcno + "'>";
                    tmpform += "<input type=hidden id='qmctitle' name='qmctitle' value='" + qmctitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
        public ActionResult yeardelConfirmed(string id, int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "yhid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qyhid = "", qyhtitle = "", yhid = "";

            if (!string.IsNullOrWhiteSpace(Request["qyhid"]))
            {
                qyhid         = Request["qyhid"].Trim();
                ViewBag.qyhid = qyhid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qyhtitle"]))
            {
                qyhtitle         = Request["qyhtitle"].Trim();
                ViewBag.qyhtitle = qyhtitle;
            }
            if (!string.IsNullOrWhiteSpace(Request["yhid"]))
            {
                yhid         = Request["yhid"].Trim();
                ViewBag.yhid = yhid;
            }


            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                NDcommon      dbobj   = new NDcommon();
                SqlConnection conn1   = dbobj.get_conn("Aitag_DBContext");
                string        sysnote = "";

                string yhid1   = dbobj.get_dbvalue(conn1, "select yhid from yearholidaydet where hdid ='" + Request["hdid"].ToString() + "' and comid='" + Session["comid"].ToString() + "'");
                string yhsyear = dbobj.get_dbvalue(conn1, "select yhsyear from yearholidaydet where hdid ='" + Request["hdid"].ToString() + "' and comid='" + Session["comid"].ToString() + "'");

                sysnote += "年假代碼:" + yhid1 + ",假別代碼:" + yhsyear + "<br>";

                dbobj.dbexecute("Aitag_DBContext", "DELETE FROM yearholidaydet where hdid = '" + Request["hdid"].ToString() + "'");



                conn1.Close();
                conn1.Dispose();
                string sysrealsid = Request["sysrealsid"].ToString();
                //系統LOG檔
                //================================================= //
                SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                string        sysflag    = "D";
                dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                sysconn.Close();
                sysconn.Dispose();
                //======================================================
                string tmpform = "";
                tmpform  = "<body onload=qfr1.submit();>";
                tmpform += "<form name='qfr1' action='/yearholiday/Edit' method='post'>";
                tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                tmpform += "<input type=hidden id='qyhid' name='qyhid' value='" + qyhid + "'>";
                tmpform += "<input type=hidden id='qyhtitle' name='qyhtitle' value='" + qyhtitle + "'>";
                tmpform += "<input type=hidden id='yhid' name='yhid' value='" + yhid + "'>";
                tmpform += "</form>";
                tmpform += "</body>";
                return(new ContentResult()
                {
                    Content = @"<script>alert('刪除成功!!')</script>" + tmpform
                });
                //return RedirectToAction("List");
            }
        }
        public ActionResult DeleteConfirmed(string schid)
        {
            if (!string.IsNullOrWhiteSpace(Request["year1"]))
            {
                ViewBag.year1 = Request["year1"].ToString();
            }
            else
            {
                ViewBag.year1 = "";
            }

            if (!string.IsNullOrWhiteSpace(Request["month1"]))
            {
                ViewBag.month1 = Request["month1"].ToString();
            }
            else
            {
                ViewBag.month1 = "";
            }

            if (!string.IsNullOrWhiteSpace(Request["qschdate"]))
            {
                ViewBag.qschdate = Request["qschdate"].ToString();
            }
            else
            {
                ViewBag.qschdate = "";
            }

            string schtype = Request["schtype"].ToString();

            ViewBag.schtype = schtype;
            ViewBag.Mflag   = Request["Mflag"].ToString();

            string tmptitle = "";

            switch (schtype)
            {
            case "0":
                tmptitle = "個人備忘";
                break;

            case "1":
                tmptitle = "個人行程";
                break;

            case "2":
                tmptitle = "公司行程";
                break;
            }

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                NDcommon      dbobj    = new NDcommon();
                SqlConnection conn1    = dbobj.get_conn("Aitag_DBContext");
                string        sysnote  = "";
                string        schtitle = dbobj.get_dbvalue(conn1, "select schtitle from schedule where schid =" + schid);
                sysnote = "類別:" + tmptitle + ",標題:" + schtitle + "<br>";
                dbobj.dbexecute("Aitag_DBContext", "DELETE FROM schedule where schid = " + schid);
                conn1.Close();
                conn1.Dispose();
                string sysrealsid = Request["sysrealsid"].ToString();
                //系統LOG檔
                //================================================= //
                SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                string        sysflag    = "D";
                dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                sysconn.Close();
                sysconn.Dispose();
                //======================================================

                string tmpform = "";
                tmpform  = "<body onload='qfr1.submit();'>";
                tmpform += "<form name='qfr1' action='/schedule/list' method='post'>";
                tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                tmpform += "<input type=hidden name='year1' id='year1' value='" + ViewBag.year1 + "'>";
                tmpform += "<input type=hidden name='month1' id='month1' value='" + ViewBag.month1 + "'>";
                tmpform += "<input type=hidden name='Mflag' id='Mflag' value='" + ViewBag.Mflag + "'>";
                tmpform += "<input type=hidden name='qschdate' id='qschdate' value='" + ViewBag.qschdate + "'>";
                tmpform += "</form>";
                tmpform += "</body>";

                return(new ContentResult()
                {
                    Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                });
            }
        }
Esempio n. 10
0
        public ActionResult newlogin(string comidrid, string comid)
        {
            string tmppath1   = "";
            string tmpsid     = "";
            string tmprealsid = "";

            tmppath1   = Request["path1"];
            tmpsid     = Request["sid"];
            tmprealsid = Request["realsid"];

            if (!string.IsNullOrWhiteSpace(comidrid))
            {
                Session["rid"]       = comidrid;
                Session["mplayrole"] = "'" + comidrid + "'";
            }

            if (!string.IsNullOrWhiteSpace(comid))
            {
                Session["comid"] = comid;
                NDcommon dbobj = new NDcommon();

                SqlConnection tmpconn = dbobj.get_conn("Aitag_DBContext");
                Session["logopic"] = dbobj.get_dbvalue(tmpconn, "select logopic from company where comid = '" + comid + "'");
                tmpconn.Close();
                tmpconn.Dispose();
            }

            if (tmppath1 == "" || tmppath1 == null)
            {
                if (Session["mtid"] == "A0032")
                {
                    return(new ContentResult()
                    {
                        Content = @"<script>location.href='/paybill'</script>"
                    });
                }
                else
                {
                    return(new ContentResult()
                    {
                        Content = @"<script>location.href='/main'</script>"
                    });
                }
            }
            else
            {
                if (tmpsid == "510")
                {
                    Session["mtid"] = "A0032";
                }
                else
                {
                    Session["mtid"] = "A004";
                }

                Session["sid"]     = tmpsid;
                Session["realsid"] = tmprealsid;

                return(new ContentResult()
                {
                    Content = @"<script>location.href='/" + tmppath1 + "'</script>"
                });
            }
            //return View();
        }
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string orderdata = "", orderdata1 = "";

            if (!string.IsNullOrWhiteSpace(Request["orderdata"]))
            {
                orderdata = Request["orderdata"].Trim();
            }
            if (!string.IsNullOrWhiteSpace(Request["orderdata1"]))
            {
                orderdata1 = Request["orderdata1"].Trim();
            }

            string qotstatus = "", qempname = "", qdptid = "", otlogsdate = "", otlogedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qotstatus"]))
            {
                qotstatus         = Request["qotstatus"].Trim();
                ViewBag.qotstatus = qotstatus;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            if (!string.IsNullOrWhiteSpace(Request["otlogsdate"]))
            {
                otlogsdate         = Request["otlogsdate"].Trim();
                ViewBag.otlogsdate = otlogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["otlogedate"]))
            {
                otlogedate         = Request["otlogedate"].Trim();
                ViewBag.otlogedate = otlogedate;
            }


            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/otworklog/List' method='post'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";


            tmpform += "<input type=hidden id='qotstatus' name='qotstatus' value='" + qotstatus + "'>";
            tmpform += "<input type=hidden id='qempname' name='qempname' value='" + qempname + "'>";
            tmpform += "<input type=hidden id='qdptid' name='qdptid' value='" + qdptid + "'>";
            tmpform += "<input type=hidden id='otlogsdate' name='otlogsdate' value='" + otlogsdate + "'>";
            tmpform += "<input type=hidden id='otlogedate' name='otlogedate' value='" + otlogedate + "'>";

            tmpform += "</form>";
            tmpform += "</body>";

            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');</script>" + tmpform
                });
            }
            else
            {
                Int16  tmpcount   = 0;
                string tmpcomment = "";
                string sql        = "select * from otworklog";
                string sqlwhere   = " where otlogid in (" + cdel + ") and comid='" + (string)Session["comid"] + "'";
                sql += sqlwhere;
                NDcommon dbobj = new NDcommon();
                using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                {
                    using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        using (SqlCommand cmd = new SqlCommand(sql, conn))
                        {
                            string xotlogstime = "", xotlogetime = "";
                            string otcomment = "", mailtitle = "", MailContext = "";
                            string fromadd = "", fromaddname = "", toadd = "";
                            string rolestampid = "", sql_m = "";
                            int    bloghour = 0;


                            SqlDataReader dr = cmd.ExecuteReader();
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    xotlogstime = "(" + dr["otlogstime"] + ")";
                                    xotlogetime = "(" + dr["otlogetime"] + ")";

                                    #region  寄信(通知給目前簽核角色)
                                    if (dbobj.get_dbnull2(dr["otcomment"]) != "")
                                    {
                                        otcomment = dbobj.get_dbnull2(dr["otcomment"]).Replace(Environment.NewLine, "<br>");
                                    }
                                    else
                                    {
                                        otcomment = "&nbsp;";
                                    }
                                    mailtitle = "加班確認單撤回通知";

                                    MailContext = "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=BIG5'></HEAD><body>";
                                    MailContext = MailContext + "以下為明細資料:<BR>";
                                    MailContext = MailContext + "<table cellpadding=3 cellspacing=0 bordercolorlight=#000000 bordercolordark=ffffff border=1 width=400 bgcolor=ffffff style='FONT-SIZE: 11pt;FONT-FAMILY:Tahoma,Arial'>";
                                    MailContext = MailContext + "<tr><td align=right width=130>申請人:</td><td>" + dbobj.get_dbnull2(dr["empname"]) + "</td></tr>";
                                    MailContext = MailContext + "<tr><td align=right>起迄日期:</td><td>自 " + dbobj.get_dbnull2(dr["otlogsdate"]) + xotlogstime + "<BR>至 " + dbobj.get_dbnull2(dr["otlogedate"]) + xotlogetime + "</td></tr>";
                                    MailContext = MailContext + "<tr><td align=right>共計小時:</td><td>" + dbobj.get_dbnull2(dr["otloghour"]) + "時</td></tr>";
                                    MailContext = MailContext + "<tr><td align=right>事由:</td><td>" + otcomment + "+nbsp;</td></tr>";
                                    MailContext = MailContext + "</table>";
                                    MailContext = MailContext + "</body></HTML>";

                                    //寄件者
                                    fromadd     = dbobj.get_dbvalue(comconn, "select enemail from employee where empid='" + (string)Session["empid"] + "'");
                                    fromaddname = (string)Session["empname"];

                                    //'寄給申請人
                                    toadd = dbobj.get_dbvalue(comconn, "select enemail from employee where empid='" + dbobj.get_dbnull2(dr["empid"]) + "'");

                                    if (toadd != "")
                                    {
                                        //#include file=../inc/mail.asp
                                        dbobj.send_mail(mfrom, toadd, mailtitle, MailContext);
                                    }
                                    //收件者
                                    if (dbobj.get_dbnull2(dr["rolestampid"]) != "")
                                    {
                                        rolestampid = dbobj.get_dbnull2(dr["rolestampid"]);
                                        sql_m       = "select enemail from viewemprole where rid in (" + rolestampid + ") and empstatus <> '4' and enemail<>'' and comid='" + (string)Session["comid"] + "'";
                                        using (SqlCommand cmd2 = new SqlCommand(sql, conn))
                                        {
                                            SqlDataReader dr2 = cmd2.ExecuteReader();
                                            while (dr.Read())
                                            {
                                                toadd = dbobj.get_dbnull2(dr2["enemail"]);
                                                //#include file=../inc/mail.asp
                                                dbobj.send_mail(mfrom, toadd, mailtitle, MailContext);
                                            }
                                            dr.Close();
                                        }
                                    }
                                    #endregion

                                    sql  = "UPDATE otworklog SET otstatus = 'D'";
                                    sql += sqlwhere;
                                    sql += ";delete from resthourlog";
                                    sql += sqlwhere;
                                    dbobj.dbexecute("Aitag_DBContext", sql);


                                    tmpcount++;
                                    tmpcomment += "姓名:" + dbobj.get_dbnull2(dr["empname"]) + "申請單號:" + dbobj.get_dbnull2(dr["osno"]) + ",";
                                }
                                tmpcomment = tmpcomment.Substring(0, tmpcomment.Length - 1);
                            }


                            //系統LOG檔
                            string sysnote = tmpcomment + "的資料" + tmpcount + "筆";
                            if (sysnote.Length > 4000)
                            {
                                sysnote = sysnote.Substring(0, 4000);
                            }
                            //================================================= //
                            string        sysrealsid = Request["sysrealsid"].ToString();
                            SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                            string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2") + "(撤回)";
                            string        sysflag    = "D";
                            dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                            sysconn.Close();
                            sysconn.Dispose();
                            //======================================================
                            dr.Close();
                        }
                    }
                }

                return(new ContentResult()
                {
                    Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                });
            }
        }
Esempio n. 12
0
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string orderdata = "", orderdata1 = "";

            if (!string.IsNullOrWhiteSpace(Request["orderdata"]))
            {
                orderdata = Request["orderdata"].Trim();
            }
            if (!string.IsNullOrWhiteSpace(Request["orderdata1"]))
            {
                orderdata1 = Request["orderdata1"].Trim();
            }

            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogsdate"]))
            {
                qclogsdate         = Request["qclogsdate"].Trim();
                ViewBag.qclogsdate = qclogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogedate"]))
            {
                qclogedate         = Request["qclogedate"].Trim();
                ViewBag.qclogedate = qclogedate;
            }

            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/cardreallog/List' method='post'>";
            //tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";

            tmpform += "<input type=hidden id='qdptid' name='qdptid' value='" + qdptid + "'>";
            tmpform += "<input type=hidden id='qempname' name='qempname' value='" + qempname + "'>";
            tmpform += "<input type=hidden id='qclogsdate' name='qclogsdate' value='" + qclogsdate + "'>";
            tmpform += "<input type=hidden id='qclogedate' name='qclogedate' value='" + qclogedate + "'>";

            tmpform += "</form>";
            tmpform += "</body>";


            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');</script>" + tmpform
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string ecardreallogs = dbobj.get_dbvalue(conn1, "select empname from cardreallog where crid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "代碼名稱:" + ecardreallogs + ",序號:" + condtionArr[i].ToString() + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM cardreallog where crid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });
                    //return RedirectToAction("List");
                }
            }
        }
Esempio n. 13
0
        public ActionResult chkEdit(sales_competition chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "ccid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qprodtitle = "", qcusttitlename = "";

            if (!string.IsNullOrWhiteSpace(Request["qprodtitle"]))
            {
                qprodtitle         = Request["qprodtitle"].Trim();
                ViewBag.qprodtitle = qprodtitle;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcusttitlename"]))
            {
                qcusttitlename     = Request["qcusttitlename"].Trim();
                ViewBag.qprodtitle = qcusttitlename;
            }

            if (sysflag != "E")
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    var data = con.sales_competition.Where(r => r.ccid == chks.ccid).FirstOrDefault();

                    sales_competition competitionlogs = con.sales_competition.Find(chks.ccid);
                    if (competitionlogs == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(competitionlogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];



                    NDcommon          dbobj = new NDcommon();
                    sales_competition col   = new sales_competition();
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        col = con.sales_competition.Find(chks.ccid);
                    }

                    string sysnote = "";
                    if (dbobj.get_dbnull2(Request["slogstatus"]) == "1")
                    {
                        string tmprolestampid = col.rolestampid;
                        string rolea_1        = col.rolestampidall;
                        string roleall        = rolea_1 + "," + tmprolestampid; //'簽核過角色(多個)
                        string billflowid     = col.billflowid.ToString();

                        //找出下一個角色是誰
                        string tmprole = dbobj.getnewcheck1("G", tmprolestampid, roleall, "", "", billflowid);

                        if (tmprole == "'topman'")
                        {
                            tmprole = "";
                        }
                        string slogstatus = "";
                        if (tmprole == "")
                        {
                            slogstatus = "1";// '己簽核
                        }
                        else
                        {
                            slogstatus = "0";
                            //'找往上呈核長管級數
                            //'==========================
                            string tmpflowlevel = "";
                            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                            {
                                tmpflowlevel = dbobj.get_dbvalue(conn, "select billflow from flowlevel where bid=" + billflowid);
                            }
                            if (tmpflowlevel == "")
                            {
                                tmpflowlevel = "0";
                            }
                            string[] tmpa      = rolea_1.Split(',');
                            int      tmpacount = tmpa.Length;
                            if (int.Parse(tmpflowlevel) == (tmpacount + 1))
                            {
                                tmprole    = "";
                                slogstatus = "1"; // '己簽核
                            }
                            //'==========================
                        }

                        col.slogstatus     = slogstatus;
                        col.rolestampid    = tmprole;
                        col.rolestampidall = roleall;
                        col.empstampidall  = col.empstampidall + ",'" + (string)Session["empid"] + "'"; //'所有人員帳號
                        col.bmodid         = (string)Session["empid"];
                        col.bmoddate       = DateTime.Now;
                        col.billtime       = col.billtime + "," + DateTime.Now.ToString();
                        col.lawcomment     = Request["lawcomment"].ToString();
                        col.fincomment     = Request["fincomment"].ToString();
                        if (tmprole != "")
                        {
                            //寄信
                            //holidaycheckmainEditMail(col, tmprole);
                        }
                        else
                        {
                            //沒有下一個承辦人  (己通過)
                            ////資料通過後 搬移到cardreallog
                            //battacheckmainEditMove(col);

                            //(己通過)  寄信
                            //holidaycheckmainEditMailPass(col);
                        }
                        sysnote = "請假單審核通過作業";
                    }
                    else
                    {
                        col.slogstatus = "2";
                        col.rback      = Request["hback1"].ToString();
                        col.bmodid     = (string)Session["empid"];
                        col.bmoddate   = DateTime.Now;
                        col.billtime   = col.billtime + "," + DateTime.Now.ToString();

                        ////資料通過後 搬移到cardreallog
                        //battacheckmainEditMove(col);

                        //(己通過)  寄信
                        //holidaycheckmainEditMailBack(col);
                        sysnote = "新業務及競業退回作業";
                    }

                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;

                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.Entry(col).State = EntityState.Modified;
                        con.SaveChanges();
                    }



                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    //string sysnote = "承辦人:" + chks.empid + "產品名稱:" + chks.prodtitle;
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/sales_competition/chk' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qprodtitle' name='qprodtitle' value='" + qprodtitle + "'>";
                    tmpform += "<input type=hidden id='qcusttitlename' name='qcusttitlename' value='" + qcusttitlename + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    //return RedirectToAction("List");
                }
            }
        }
Esempio n. 14
0
        public ActionResult Delete(string id, int?page, string orderdata, string orderdata1)
        {
            page               = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page       = page;
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qbseason = "", qslyear = "", qslmonth = "", qvtype = "", qvendcomid = "";

            if (!string.IsNullOrWhiteSpace(Request["qbseason"]))
            {
                qbseason         = Request["qbseason"].Trim();
                ViewBag.qbseason = qbseason;
            }
            if (!string.IsNullOrWhiteSpace(Request["qslyear"]))
            {
                qslyear         = Request["qslyear"].Trim();
                ViewBag.qslyear = qslyear;
            }
            if (!string.IsNullOrWhiteSpace(Request["qslmonth"]))
            {
                qslmonth         = Request["qslmonth"].Trim();
                ViewBag.qslmonth = qslmonth;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvtype"]))
            {
                qvtype         = Request["qvtype"].Trim();
                ViewBag.qvtype = qvtype;
            }

            if (!string.IsNullOrWhiteSpace(Request["qvendcomid"]))
            {
                qvendcomid         = Request["qvendcomid"].Trim();
                ViewBag.qvendcomid = qvendcomid;
            }


            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("AitagBill_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string vcno = dbobj.get_dbvalue(conn1, "select ('年/月:' + convert(char,slyear)+ '/'+convert(char,slmonth)+ ',廠商:' + vendcomid) as st1 from vend_monthmoney where vsid='" + condtionArr[i].ToString() + "'");

                        sysnote += vcno + "<br>";
                        //刪除憑單
                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM vend_monthmoney where vsid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================


                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/vend_monthmoney/list' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qbseason' name='qbseason' value='" + qbseason + "'>";
                    tmpform += "<input type=hidden id='qslyear' name='qslyear' value='" + qslyear + "'>";
                    tmpform += "<input type=hidden id='qslmonth' name='qslmonth' value='" + qslmonth + "'>";
                    tmpform += "<input type=hidden id='qvendcomid' name='qvendcomid' value='" + qvendcomid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";

                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });
                }
            }
        }
Esempio n. 15
0
        public ActionResult otworklogrpt(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "otlogsdate";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qotstatus = "", qempname = "", qdptid = "", otlogsdate = "", otlogedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qotstatus"]))
            {
                qotstatus         = Request["qotstatus"].Trim();
                ViewBag.qotstatus = qotstatus;
            }
            else
            {
                qotstatus         = "1";
                ViewBag.qotstatus = qotstatus;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            otlogsdate         = NullStDate(Request["otlogsdate"]);
            ViewBag.otlogsdate = otlogsdate;
            otlogedate         = NullTeDate(Request["otlogedate"]);
            ViewBag.otlogedate = otlogedate;
            //NullStDate 跟 NullTeDate 會判斷格式,有錯誤就 修改全域的DateEx
            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }
            NDcommon dbobj = new NDcommon();
            string   Excel = "", Excel2 = "";
            string   sqlstr = "", sqlstr_1 = "";

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string   viewid = "";
                string[] mpriv  = (string[])Session["priv"];
                //viewid = get_viewpriv(int.Parse(funcpriv(2)), int.Parse(mpriv(realsid, 2)));
                string tmpall = "";
                //tmpall = dbobj.get_allempid((string)Session["rid"]);
                tmpall = "%";


                if (tmpall == "%")
                {
                    sqlstr   = "SELECT * FROM otworklog where comid='" + (string)Session["comid"] + "'  and";
                    sqlstr_1 = "SELECT isnull(sum(otloghour),0) as otloghour FROM otworklog where comid='" + (string)Session["comid"] + "'  and";
                }
                else
                {
                    sqlstr   = "SELECT * FROM otworklog where empid in(" + tmpall + ") and comid='" + (string)Session["comid"] + "'  and";
                    sqlstr_1 = "SELECT isnull(sum(otloghour),0) as otloghour FROM otworklog where empid in(" + tmpall + ") and comid='" + (string)Session["comid"] + "'  and";
                }

                if (qotstatus != "all")
                {
                    string sql_otstatus = " otstatus like '" + qotstatus + "'  and";
                    sqlstr   = sqlstr + sql_otstatus;
                    sqlstr_1 = sqlstr_1 + sql_otstatus;
                }
                if (otlogsdate != "" && otlogedate != "")
                {
                    string sql_date = " (( '" + otlogsdate + "' <= otlogsdate and otlogsdate <= '" + otlogedate + "' ) or " +
                                      "( '" + otlogsdate + "' <= otlogedate and otlogedate <= '" + otlogedate + "'  ))  and";
                    sqlstr   = sqlstr + sql_date;
                    sqlstr_1 = sqlstr_1 + sql_date;
                }
                if (qempname != "")
                {
                    string sql_empname = " empname like N'%" + qempname + "%'  and";
                    sqlstr   = sqlstr + sql_empname;
                    sqlstr_1 = sqlstr_1 + sql_empname;
                }
                if (qdptid != "")
                {
                    string sql_dptid = " dptid='" + qdptid + "'  and";
                    sqlstr   = sqlstr + sql_dptid;
                    sqlstr_1 = sqlstr_1 + sql_dptid;
                }


                sqlstr   = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr_1 = sqlstr_1.Substring(0, sqlstr_1.Length - 5);
                getSUMhour(sqlstr, sqlstr_1);
                sqlstr += " order by " + orderdata + " " + orderdata1;
            }
            #region 組 Excel 格式
            Excel += "<HTML>";
            Excel += "<HEAD>";
            Excel += @"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">";
            Excel += "</HEAD>";
            Excel += "<body>";
            Excel += "<table  border=1  cellpadding=0 cellspacing=0 bordercolor=#000000 bordercolordark=#ffffff width=900 >";
            Excel += "<tr align=center>";
            Excel += @"<td colspan=""9"" style=""font-size:14pt"">加班明細表";
            Excel += "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            int count = 8;
            Excel += "<td colspan='" + count + "' ></td><td>列印日期:" + DateTime.Now.ToString("yyyy/MM/dd") + "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            Excel += "<td>狀態</td>";
            Excel += "<td>核銷</td>";
            Excel += "<td>員工編號</td>";
            Excel += "<td>姓名</td>";
            Excel += "<td>部門</td>";
            Excel += "<td>加班起迄日期</td>";
            Excel += "<td>加班時數</td>";
            Excel += "<td>補休時數</td>";
            Excel += "<td>請款時數</td>";
            Excel += "</tr>";
            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
            {
                using (SqlCommand cmd = new SqlCommand(sqlstr, conn))
                {
                    SqlDataReader dr = cmd.ExecuteReader();

                    string blogstatus = "", ifhdell = "", empno = "", dpttitle = "";
                    string SEtime = "自{0}({1}時)<br>至{2}({3}時)";
                    string blogsdate = "", blogstime = "", blogedate = "", blogetime = "";
                    string resthour = "", moneyhour = "", sql = "";

                    while (dr.Read())
                    {
                        blogstatus = dbobj.get_dbnull2(dr["otstatus"]);
                        switch (blogstatus)
                        {
                        case "0":
                            blogstatus = "簽核中";
                            break;

                        case "1":
                            blogstatus = "已核准";
                            break;

                        case "2":
                            blogstatus = "退回";
                            break;

                        case "D":
                            blogstatus = "撤回";
                            break;

                        default:
                            break;
                        }
                        ifhdell = dbobj.get_dbnull2(dr["ifotdell"]);
                        if (ifhdell == "y")
                        {
                            ifhdell = "是";
                        }
                        else if (ifhdell == "n")
                        {
                            ifhdell = "否";
                        }
                        blogsdate = Convert.ToDateTime(dbobj.get_dbnull2(dr["otlogsdate"])).ToString("yyyy/MM/dd");
                        blogstime = int.Parse(dbobj.get_dbnull2(dr["otlogstime"])).ToString("00");
                        blogedate = Convert.ToDateTime(dbobj.get_dbnull2(dr["otlogedate"])).ToString("yyyy/MM/dd");
                        blogetime = int.Parse(dbobj.get_dbnull2(dr["otlogetime"])).ToString("00");

                        using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
                        {
                            empno    = "select empno from employee where empid='" + dbobj.get_dbnull2(dr["empid"]) + "'"; empno = dbobj.get_dbvalue(comconn, empno);
                            dpttitle = "select dpttitle from Department where dptid='" + dbobj.get_dbnull2(dr["dptid"]) + "' and comid='" + (string)Session["comid"] + "'"; dpttitle = dbobj.get_dbvalue(comconn, dpttitle);
                            sql      = "select * from resthourlog where osno = '" + dbobj.get_dbnull2(dbobj.get_dbnull2(dr["osno"])) + "' and comid='" + (string)Session["comid"] + "'";
                            using (SqlCommand cmd1 = new SqlCommand(sql, comconn))
                            {
                                SqlDataReader dr1 = cmd1.ExecuteReader();
                                if (dr1.HasRows)
                                {
                                    dr1.Read();
                                    resthour  = dbobj.get_dbnull2(dr1["resthour"]);
                                    moneyhour = dbobj.get_dbnull2(dr1["moneyhour"]);
                                }
                                else
                                {
                                    resthour  = "0";
                                    moneyhour = "0";
                                }
                                dr1.Close();
                            }
                        }


                        Excel2 += "<tr>";
                        Excel2 += "<td>" + blogstatus + "</td>";
                        Excel2 += "<td>" + ifhdell + "</td>";
                        Excel2 += "<td>" + empno + "</td>";
                        Excel2 += "<td>" + dbobj.get_dbnull2(dr["empname"]) + "</td>";
                        Excel2 += "<td>" + dpttitle + "</td>";
                        Excel2 += "<td>" + String.Format(SEtime, blogsdate, blogstime, blogedate, blogetime) + "</td>";
                        Excel2 += "<td>" + dbobj.get_dbnull2(dr["otloghour"]) + "</td>";
                        Excel2 += "<td>" + resthour + "</td>";
                        Excel2 += "<td>" + moneyhour + "</td>";
                        Excel2 += "</tr>";
                    }
                    if (Excel2 == "")
                    {
                        Excel += "<tr align=left><td colspan=6>目前沒有資料</td></tr>";
                    }
                    else
                    {
                        Excel2 += "<tr>";
                        Excel2 += "<td>總計</td>";
                        Excel2 += "<td>&nbsp;</td>";
                        Excel2 += "<td>&nbsp;</td>";
                        Excel2 += "<td>&nbsp;</td>";
                        Excel2 += "<td>&nbsp;</td>";
                        Excel2 += "<td>&nbsp;</td>";
                        Excel2 += "<td>" + ViewBag.otloghour + "</td>";
                        Excel2 += "<td>" + ViewBag.sumresthour + "</td>";
                        Excel2 += "<td>" + ViewBag.summoneyhour + "</td>";
                        Excel2 += "</tr>";
                        Excel  += Excel2;
                    }
                    dr.Close();
                }
            }
            Excel        += "</table>";
            Excel        += "</body>";
            Excel        += "</HTML>";
            ViewBag.Excel = Excel;
            #endregion

            return(View());
        }
Esempio n. 16
0
        public ActionResult mvclogin()
        {
            string   mtid  = Request["mtid"];
            string   empid = Request["empid"];
            NDcommon dbobj = new NDcommon();

            SqlConnection conn    = dbobj.get_conn("Aitag_DBContext");
            SqlConnection tmpconn = dbobj.get_conn("Aitag_DBContext");

            SqlDataReader dr;
            SqlCommand    sqlsmd = new SqlCommand();

            sqlsmd.Connection = conn;
            //加密比對登入
            //string sqlstr = "select * from Company where comid = '" + UserName.Trim() + "'  and ifstop='y'";
            //一般沒加密登入
            //string sqlstr = "select * from Company where comid = '" + UserName.Trim() + "' and compwd='" + Password.Trim() + "' and ifstop='y'";
            string sqlstr = "select * from Employee where empid = '" + empid.Trim() + "' and empstatus<>'4'and ifuse = 'y'";

            sqlsmd.CommandText = sqlstr;
            dr = sqlsmd.ExecuteReader();

            if (dr.Read())
            {
                Session["tempid"]   = dr["empid"].ToString();
                Session["empid"]    = dr["empid"].ToString();
                Session["tempname"] = dr["empname"].ToString();
                Session["empname"]  = dr["empname"].ToString();
                Session["Dptid"]    = dr["empworkdepid"].ToString();
                Session["comid"]    = dr["empworkcomp"].ToString();
                Session["Msid"]     = dr["Msid"].ToString();
                Session["Dpttitle"] = dbobj.get_dbvalue(tmpconn, "select dpttitle from department where ID = '" + dr["empworkdepid"].ToString() + "'");
                Session["sldate"]   = DateTime.Now;
                Session["sfip"]     = Request.ServerVariables["REMOTE_ADDR"].ToString();
                Session["pagesize"] = 20;
                Session["mtid"]     = dr["etab"].ToString();
                Session["logopic"]  = dbobj.get_dbvalue(tmpconn, "select logopic from company where comid = '" + dr["empworkcomp"].ToString() + "'");
                dr.Close();

                //抓最大角色
                sqlstr             = "select TOP (1) rid from emprole where empid = '" + Session["tempid"].ToString().Trim() + "' order by rid";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();
                while (dr.Read())
                {
                    Session["rid"]       = dr["rid"].ToString();
                    Session["mplayrole"] = "'" + dr["rid"].ToString() + "'";
                }
                dr.Close();

                string[] privtb = new string[999];
                for (int i = 0; i < 999; i++)
                {
                    privtb[i] = "0";
                }
                sqlstr             = "select * from privtb where bid = '" + empid.Trim() + "'";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();
                while (dr.Read())
                {
                    privtb[int.Parse(dr["sid"].ToString())] = "1";
                }
                Session["privtb"] = privtb;
                dr.Close();
                dr.Dispose();
                return(new ContentResult()
                {
                    Content = @"<script>location.href='/main'</script>"
                });
            }

            sqlsmd.Dispose();
            conn.Close();
            conn.Dispose();
            tmpconn.Close();
            tmpconn.Dispose();
            dbobj = null;



            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            // ModelState.AddModelError("", "所提供的使用者名稱或密碼不正確。");
            // return View(model);
            return(new ContentResult()
            {
                Content = @"<script>alert('使用者帳號密碼不正確或停止使用!!');location.href='/'</script>"
            });
        }
Esempio n. 17
0
        public ActionResult Index(employee col, Logoin model, string UserName, string Password)
        {
            ModelState.Clear();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                NDcommon dbobj = new NDcommon();

                SqlConnection conn    = dbobj.get_conn("Aitag_DBContext");
                SqlConnection tmpconn = dbobj.get_conn("Aitag_DBContext");

                SqlDataReader dr;
                SqlCommand    sqlsmd = new SqlCommand();
                sqlsmd.Connection = conn;
                //加密比對登入
                //string sqlstr = "select * from Company where comid = '" + UserName.Trim() + "'  and ifstop='y'";
                //一般沒加密登入
                //string sqlstr = "select * from Company where comid = '" + UserName.Trim() + "' and compwd='" + Password.Trim() + "' and ifstop='y'";
                string sqlstr = "select * from Employee where empid = '" + UserName.Trim() + "' and emppasswd ='" + Password.Trim() + "' and empstatus<>'4'and ifuse = 'y'";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();

                if (dr.Read())
                {
                    Session["comcon"]    = dr["comcon"].ToString().Replace("#", "\'");
                    Session["tempid"]    = dr["empid"].ToString();
                    Session["empid"]     = dr["empid"].ToString();
                    Session["tempname"]  = dr["empname"].ToString();
                    Session["empname"]   = dr["empname"].ToString();
                    Session["Dptid"]     = dr["empworkdepid"].ToString();
                    Session["comid"]     = dr["empworkcomp"].ToString();
                    Session["Msid"]      = dr["Msid"].ToString();
                    Session["Dpttitle"]  = dbobj.get_dbvalue(tmpconn, "select dpttitle from department where dptid = '" + dr["empworkdepid"].ToString() + "'");
                    Session["sldate"]    = DateTime.Now;
                    Session["sfip"]      = Request.ServerVariables["REMOTE_ADDR"].ToString();
                    Session["pagesize"]  = 20;
                    Session["epagesize"] = 100;
                    Session["mcid"]      = "";
                    Session["mtid"]      = dr["etab"].ToString();
                    Session["logopic"]   = dbobj.get_dbvalue(tmpconn, "select logopic from company where comid = '" + dr["empworkcomp"].ToString() + "'");
                    dr.Close();

                    //抓最大角色
                    sqlstr             = "select  TOP (1) rid from emprole where empid = '" + Session["tempid"].ToString().Trim() + "' order by rid";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();
                    while (dr.Read())
                    {
                        Session["rid"]       = dr["rid"].ToString();
                        Session["mplayrole"] = "'" + dr["rid"].ToString() + "'";
                    }
                    dr.Close();
                    string[] privtb = new string[999];
                    for (int i = 0; i < 999; i++)
                    {
                        privtb[i] = "0";
                    }
                    sqlstr             = "select * from privtb where bid = '" + UserName.Trim() + "'";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();
                    while (dr.Read())
                    {
                        privtb[int.Parse(dr["sid"].ToString())] = "1";
                    }
                    Session["privtb"] = privtb;
                    dr.Close();
                    dr.Dispose();
                    return(RedirectToAction("Index", "main"));
                }
                else
                {
                    String wrongID = "查無此帳號資訊!!";
                    //if (Session["comclass"] == "2")//國外
                    //{
                    //    wrongID = "Please check your userid and password";
                    //}
                    //ModelState.AddModelError("", wrongID);
                    dr.Close();
                    dr.Dispose();
                }

                sqlsmd.Dispose();
                conn.Close();
                conn.Dispose();
                tmpconn.Close();
                tmpconn.Dispose();
                dbobj = null;
            }


            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            // ModelState.AddModelError("", "所提供的使用者名稱或密碼不正確。");
            // return View(model);
            return(new ContentResult()
            {
                Content = @"<script>alert('使用者帳號密碼不正確或停止使用!!');location.href='/'</script>"
            });
        }
Esempio n. 18
0
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string qbillid = "", qcomclass = "";

            if (!string.IsNullOrWhiteSpace(Request["qbillid"]))
            {
                qbillid         = Request["qbillid"].Trim();
                ViewBag.qbillid = qbillid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcomclass"]))
            {
                qcomclass         = Request["qcomclass"].Trim();
                ViewBag.qcomclass = qcomclass;
            }
            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string billid        = dbobj.get_dbvalue(conn1, "select billid from billflow where bid ='" + condtionArr[i].ToString() + "'");
                        string flowcheck     = dbobj.get_dbvalue(conn1, "select flowcheck from billflow where bid ='" + condtionArr[i].ToString() + "'");
                        string flowcheck1    = "";
                        string tmpbillidname = dbobj.get_dbvalue(conn1, "select doctitle from docgroup where docid ='" + billid + "' and comid='" + Session["comid"] + "'");
                        if (!string.IsNullOrWhiteSpace(flowcheck))
                        {
                            string     sqlstr1 = "select roletitle from roleplay where rid in (" + flowcheck + ")";
                            SqlCommand cmd     = new SqlCommand();
                            cmd.Connection  = conn1;
                            cmd.CommandText = sqlstr1;
                            SqlDataReader dr1 = cmd.ExecuteReader();
                            while (dr1.Read())
                            {
                                flowcheck1 = flowcheck1 + dr1["roletitle"].ToString() + " → ";
                            }
                            if (flowcheck1 != "")
                            {
                                flowcheck1 = flowcheck1.Substring(0, flowcheck1.Length - 2);
                            }
                            dr1.Close();
                            dr1.Dispose();
                        }
                        sysnote += "呈核單類別:" + tmpbillidname + ",呈核流程:" + flowcheck1 + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM billflow where bid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/billflow/List?page=" + page + "&qbillid=" + qbillid + "&qcomclass=" + qcomclass;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
Esempio n. 19
0
        public ActionResult Edit(billflow chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "bid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qbillid = "", qcomclass = "";

            if (!string.IsNullOrWhiteSpace(Request["qbillid"]))
            {
                qbillid         = Request["qbillid"].Trim();
                ViewBag.qbillid = qbillid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcomclass"]))
            {
                qcomclass         = Request["qcomclass"].Trim();
                ViewBag.qcomclass = qcomclass;
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var      data       = con.billflow.Where(r => r.bid == chks.bid).FirstOrDefault();
                    billflow ebillflows = con.billflow.Find(chks.bid);
                    if (ebillflows == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(ebillflows));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldbillid = Request["oldbillid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();

                        chks.addr             = Request["addr"];
                        chks.billtype         = Request["billtype"];
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;

                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn       = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid    = Request["sysrealsid"].ToString();
                        string        syssubname    = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        tmpbillidname = dbobj.get_dbvalue(sysconn, "select doctitle from docgroup where docid ='" + Request["billid"].Trim() + "' and comid='" + Session["comid"] + "'");
                        string        flowcheck     = "";
                        if (!string.IsNullOrWhiteSpace(Request["flowcheck"].Trim()))
                        {
                            string     sqlstr1 = "select * from roleplay where rid in (" + Request["flowcheck"].Trim() + ")";
                            SqlCommand cmd     = new SqlCommand();
                            cmd.Connection  = sysconn;
                            cmd.CommandText = sqlstr1;
                            SqlDataReader dr1 = cmd.ExecuteReader();
                            while (dr1.Read())
                            {
                                flowcheck = flowcheck + dr1["roletitle"].ToString() + " → ";
                            }
                            if (flowcheck != "")
                            {
                                flowcheck = flowcheck.Substring(0, flowcheck.Length - 2);
                            }
                            dr1.Close();
                            dr1.Dispose();
                        }
                        string sysnote = "呈核單類別:" + tmpbillidname + "<br>呈核人員:" + flowcheck;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/billflow/List' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden id='qbillid' name='qbillid' value='" + qbillid + "'>";
                        tmpform += "<input type=hidden id='qcomclass' name='qcomclass' value='" + qcomclass + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Esempio n. 20
0
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string qkeyword = "", qsmdate = "", qemdate = "", qmclassid = "";

            if (!string.IsNullOrWhiteSpace(Request["qkeyword"]))
            {
                qkeyword         = Request["qkeyword"].Trim();
                ViewBag.qkeyword = qkeyword;
            }
            if (!string.IsNullOrWhiteSpace(Request["qsmdate"]))
            {
                qsmdate         = Request["qsmdate"].Trim();
                ViewBag.qsmdate = qsmdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qemdate"]))
            {
                qemdate         = Request["qemdate"].Trim();
                ViewBag.qemdate = qemdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qmclassid"]))
            {
                qmclassid         = Request["qmclassid"].Trim();
                ViewBag.qmclassid = qmclassid;
            }
            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                string tgourl = "/oa/maincontent?page=" + page + "&qkeyword=" + qkeyword + "&qsmdate=" + qsmdate + "&qemdate=" + qemdate + "&qmclassid=" + qmclassid;
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon dbobj = new NDcommon();

                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string maincontent1 = dbobj.get_dbvalue(conn1, "select mctitle from maincontent where mcid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "標題名稱:" + maincontent1 + ",序號:" + condtionArr[i].ToString() + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM maincontent where mcid = '" + condtionArr[i].ToString() + "'");

                        //砍檔案
                        string     sql = "select * from contupload where mcid = '" + condtionArr[i].ToString() + "'";
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn1;
                        cmd.CommandText = sql;
                        SqlDataReader rs1 = cmd.ExecuteReader();
                        while (rs1.Read())
                        {
                            //砍檔案
                            try
                            {
                                System.IO.File.Delete(Server.MapPath("/upload/" + rs1["cupfile"].ToString()));
                                System.IO.File.Delete(Server.MapPath("/downfile/" + rs1["cfilename"].ToString()));
                            }
                            catch (Exception e)
                            {; }
                        }
                        rs1.Close();
                        rs1.Dispose();

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM contupload where mcid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/oa/maincontent?page=" + page + "&qkeyword=" + qkeyword + "&qsmdate=" + qsmdate + "&qemdate=" + qemdate + "&qmclassid=" + qmclassid;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
Esempio n. 21
0
        public ActionResult Delete(string id, int?page, string orderdata, string orderdata1)
        {
            page               = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page       = page;
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qpdno = "", qallcomid = "", qvcno = "", qvcsdate = "", qvcedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qallcomid"]))
            {
                qallcomid       = Request["qallcomid"].Trim();
                ViewBag.qvendno = qallcomid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcno"]))
            {
                qvcno         = Request["qvcno"].Trim();
                ViewBag.qvcno = qvcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcsdate"]))
            {
                qvcsdate         = Request["qvcsdate"].Trim();
                ViewBag.qvcsdate = qvcsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcedate"]))
            {
                qvcedate         = Request["qvcedate"].Trim();
                ViewBag.qvcedate = qvcedate;
            }

            if (!string.IsNullOrWhiteSpace(Request["qpdno"]))
            {
                qpdno         = Request["qpdno"].Trim();
                ViewBag.qpdno = qpdno;
            }

            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("AitagBill_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string vcno = dbobj.get_dbvalue(conn1, "select vcno from vend_contract where vcid='" + condtionArr[i].ToString() + "'");

                        sysnote += "單號:" + vcno + "<br>";
                        //刪除憑單
                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM vend_contract where vcid = '" + condtionArr[i].ToString() + "'");
                        //刪除明細
                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM vend_contractdet where vcid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================


                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/custcontract/list' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    // tmpform += "<input type=hidden id='qpdno' name='qpdno' value='" + qpdno + "'>";
                    tmpform += "<input type=hidden id='qallcomid' name='qallcomid' value='" + qallcomid + "'>";
                    tmpform += "<input type=hidden id='qvcno' name='qvcno' value='" + qvcno + "'>";
                    // tmpform += "<input type=hidden id='qpcomment' name='qpcomment' value='" + qpcomment + "'>";
                    tmpform += "<input type=hidden id='qvcsdate' name='qvcsdate' value='" + qvcsdate + "'>";
                    tmpform += "<input type=hidden id='qvcedate' name='qvcedate' value='" + qvcedate + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";

                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });
                }
            }
        }
Esempio n. 22
0
        public ActionResult cardlogtransfer3(string sysflag, conbudgetdet col, HttpPostedFileBase upfile)
        {
            // ViewBag.pid = Request["pid"].ToString();

            if (sysflag != "A")
            {
                return(View());
            }
            else
            {
                NDcommon dbobj  = new NDcommon();
                string   errmsg = "";
                if (upfile != null)
                {
                    String sernonum = "";
                    //重新命名,存入檔案
                    DateTime myDate = DateTime.Now;
                    sernonum = myDate.ToString("yyyyMMddHHmmss");
                    string BasicPath = Server.MapPath("~/upload/");
                    string fileName  = upfile.FileName.Substring(upfile.FileName.IndexOf("."), upfile.FileName.Length - upfile.FileName.IndexOf("."));

                    if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                    {
                        fileName = "cust-" + sernonum.ToString() + fileName;
                        upfile.SaveAs(Server.MapPath("~/upload/") + fileName);

                        string tmppath = BasicPath + fileName;


                        StreamReader sr     = new StreamReader(@tmppath, System.Text.Encoding.Default);
                        string       allstr = sr.ReadToEnd(); //從資料流末端存取檔案
                        sr.Close();

                        string[] tmpstridno; //匯入資料

                        allstr     = allstr.Replace(Environment.NewLine, "\"");
                        allstr     = allstr.Substring(0, allstr.Length - 1);
                        tmpstridno = allstr.Split('\"');

                        //tmpstridno[0] = GetBytesCount1(tmpstridno[0]);


                        #region

                        string        tempcard = "", tempcard1 = "", tempdatetime = "", tmptime = "";
                        SqlConnection comconn = dbobj.get_conn("Aitag_DBContext");
                        foreach (string tmptxt in tmpstridno)
                        {
                            if (tmptxt != "")
                            {
                                tempcard     = tmptxt.Trim().Substring(0, 10);
                                tempcard1    = tmptxt.Trim().Substring(11, 4);
                                tempdatetime = tmptxt.Trim().Substring(16, 8);
                                tmptime      = tmptxt.Trim().Substring(25, 4);

                                if (tempcard != "" && tempcard1 != "" && tempdatetime != "" && tmptime != "")
                                {
                                    string date1 = tempdatetime.Substring(0, 4) + "/" + tempdatetime.Substring(4, 2) + "/" + tempdatetime.Substring(6, 2);
                                    tmptime = tmptime + "00";

                                    string rs1_Open = ""; rs1_Open = dbobj.get_dbvalue(comconn, "select * from cardreallog where clogtime = '" + tmptime + "' and clogdate = '" + date1 + "' and tmpcardno = '" + tempcard1 + "'");
                                    if (rs1_Open == "")
                                    {
                                        using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                                        {
                                            string sql = "select empid,empname,empworkdepid,empworkcomp from employee where empno = '" + tempcard1 + "'";
                                            using (SqlCommand cmd = new SqlCommand(sql, conn))
                                            {
                                                SqlDataReader dr = cmd.ExecuteReader();
                                                if (dr.HasRows)
                                                {
                                                    cardreallog rs = new cardreallog();
                                                    dr.Read();

                                                    rs.empid     = dr["empid"] + "";
                                                    rs.empname   = dr["empname"] + "";
                                                    rs.dptid     = dr["empworkdepid"] + "";
                                                    rs.comid     = dr["empworkcomp"] + "";
                                                    rs.clogdate  = DateTime.Parse(date1);
                                                    rs.clogtime  = tmptime;
                                                    rs.tmpcardno = tempcard1;
                                                    rs.tmpdepid  = dbobj.get_dbvalue(comconn, "select dpttitle from department where dptid='" + dr["empworkdepid"] + "'");

                                                    using (Aitag_DBContext con = new Aitag_DBContext())
                                                    {
                                                        con.cardreallog.Add(rs);
                                                        con.SaveChanges();
                                                    }
                                                }
                                                else
                                                {
                                                    errmsg += tempcard1 + ",";
                                                }
                                                dr.Close();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        comconn.Close();
                        comconn.Dispose();
                        #endregion
                    }
                    else
                    {
                        ViewBag.AddModelError = @"alert('上傳格式錯誤!');";
                        return(View());
                    }
                }


                string tmpform = "";
                if (errmsg != "")
                {
                    tmpform += "<script>";
                    tmpform += "function SetParentOpener() {";
                    tmpform += "alert('以下員編尚未轉檔,請確認!!" + errmsg + "');";
                    tmpform += "parent.opener.location.href='/cardreallog/List';";
                    tmpform += "window.close();";
                    tmpform += "}";
                    tmpform += "</script>";
                    tmpform += "<body onload=SetParentOpener();>";
                    //tmpform += errmsg;
                    tmpform += "</body>";
                }
                else
                {
                    tmpform += "<script>";
                    tmpform += "function SetParentOpener() {";
                    tmpform += "alert('轉檔成功!!');";
                    tmpform += "parent.opener.location.href='/cardreallog/List';";
                    tmpform += "window.close();";
                    tmpform += "}";
                    tmpform += "</script>";
                    tmpform += "<body onload=SetParentOpener();>";
                    tmpform += "</body>";
                }


                return(new ContentResult()
                {
                    Content = @"" + tmpform
                });
            }
        }
Esempio n. 23
0
        public ActionResult contuploaddel(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string vcno = "", billtype = "";

            if (!string.IsNullOrWhiteSpace(Request["vcno"]))
            {
                vcno            = Request["vcno"].Trim();
                ViewBag.qsmdate = vcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["billtype"]))
            {
                billtype         = Request["billtype"].Trim();
                ViewBag.billtype = billtype;
            }

            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon dbobj = new NDcommon();

                    SqlConnection conn1       = dbobj.get_conn("AitagBill_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    string        mcid        = "";
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string maincontent1 = dbobj.get_dbvalue(conn1, "select cfilename from erpbilldoc where cupid ='" + condtionArr[i].ToString() + "'");
                        mcid = dbobj.get_dbvalue(conn1, "select vcno from erpbilldoc where cupid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "檔案名稱:" + maincontent1 + ",序號:" + condtionArr[i].ToString() + ",單據編號" + mcid + "<br>";

                        dbobj.dbexecute("AitagBill_DBContext", "DELETE FROM erpbilldoc where cupid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Session["realsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/filemain/filemain?vcno=" + vcno + "&billtype=" + billtype + "&sid=" + Session["sid"] + "&realsid=" + Session["realsid"];
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
        private void delholidayMode(delholidaylog col, string hdellogstatus)
        {
            NDcommon dbobj = new NDcommon();

            using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
            {
                if (col.hdayid == "A04")
                {
                    #region  '請補假部分
                    resthourlog chks = new resthourlog();
                    chks.empid      = col.empid;
                    chks.rsdeaddate = col.hlogsdate;

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        var   eresthourlogs = con.resthourlog.Where(r => r.empid == chks.empid && r.rsdeaddate >= chks.rsdeaddate).OrderBy(r => r.rsdeaddate);
                        float tmphloghour   = float.Parse(col.hloghour.ToString());
                        foreach (resthourlog es in eresthourlogs)
                        {
                            var lefthour = es.usehour - tmphloghour;
                            if (lefthour >= 0)
                            {
                                es.usehour -= tmphloghour;
                                using (Aitag_DBContext con2 = new Aitag_DBContext())
                                {
                                    con2.Entry(es).State = EntityState.Modified;
                                    con2.SaveChanges();
                                }
                                if (lefthour == 0)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                es.usehour = 0;
                                using (Aitag_DBContext con2 = new Aitag_DBContext())
                                {
                                    con2.Entry(es).State = EntityState.Modified;
                                    con2.SaveChanges();
                                }
                                tmphloghour = float.Parse(Math.Abs(decimal.Parse(lefthour.ToString())).ToString());
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region  事實發生假部分
                    string   mergehdayid = dbobj.get_dbvalue(comconn, "select * from holidaycode where hdayid = '" + col.hdayid + "'");;
                    string   sql         = "";
                    emphdlog chks        = new emphdlog();


                    if (mergehdayid != "")
                    {
                        chks.empid  = col.empid;
                        chks.hdayid = mergehdayid;
                    }
                    else
                    {
                        chks.empid  = col.empid;
                        chks.hdayid = col.hdayid;
                    }
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        emphdlog eemphdlogs = con.emphdlog.Where(r => r.empid == chks.empid && r.hdayid == chks.hdayid).FirstOrDefault();

                        if (eemphdlogs != null)
                        {
                            eemphdlogs.usehour          = eemphdlogs.usehour - decimal.Parse(col.hloghour.ToString());
                            con.Entry(eemphdlogs).State = EntityState.Modified;
                            con.SaveChanges();

                            if (eemphdlogs.usehour == 0)
                            {
                                if (mergehdayid != "")
                                {
                                    sql = "delete emphdlog where empid = '" + col.empid + "' and hdayid = '" + mergehdayid + "'";
                                }
                                else
                                {
                                    sql = "delete emphdlog where empid = '" + col.empid + "' and hdayid = '" + col.hdayid + "'";
                                }
                                dbobj.dbexecute("Aitag_DBContext", sql);
                            }
                        }
                    }
                    #endregion
                }
            }
        }
        public ActionResult logcheckEdit(delholidaylog chks, string sysflag, int?page, string orderdata, string orderdata1, HttpPostedFileBase logopic1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "hdellogid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qhlogsdate = "", qhlogedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qhlogsdate"]))
            {
                qhlogsdate         = Request["qhlogsdate"].Trim();
                ViewBag.qhlogsdate = qhlogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qhlogedate"]))
            {
                qhlogedate         = Request["qhlogedate"].Trim();
                ViewBag.qhlogedate = qhlogedate;
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    //var data = con.delholidaylog.Where(r => r.hdellogid == chks.hdellogid).FirstOrDefault();
                    delholidaylog edelholidaylogs = con.delholidaylog.Find(chks.hdellogid);
                    if (edelholidaylogs == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(edelholidaylogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    NDcommon      dbobj   = new NDcommon();
                    delholidaylog col     = new delholidaylog();
                    string        sysnote = "";
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        col = con.delholidaylog.Find(chks.hdellogid);
                    }

                    string hdellogstatus = "";
                    if (dbobj.get_dbnull2(Request["hdellogstatus"]) == "1")
                    {
                        string tmprolestampid = col.rolestampid;
                        string rolea_1        = col.rolestampidall;
                        string roleall        = rolea_1 + "," + tmprolestampid; //'簽核過角色(多個)
                        string billflowid     = col.billflowid.ToString();

                        //找出下一個角色是誰
                        string tmprole = dbobj.getnewcheck1("H", tmprolestampid, roleall, "0", "", billflowid);

                        if (tmprole == "'topman'")
                        {
                            tmprole = "";
                        }
                        if (tmprole == "")
                        {
                            hdellogstatus = "1";// '己簽核
                        }
                        else
                        {
                            hdellogstatus = "0";
                            //'找往上呈核長管級數
                            //'==========================
                            string tmpflowlevel = "";
                            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                            {
                                tmpflowlevel = dbobj.get_dbvalue(conn, "select billflow from flowlevel where bid=" + billflowid);
                            }
                            if (tmpflowlevel == "")
                            {
                                tmpflowlevel = "0";
                            }
                            string[] tmpa      = rolea_1.Split(',');
                            int      tmpacount = tmpa.Length;
                            if (int.Parse(tmpflowlevel) == (tmpacount + 1))
                            {
                                tmprole       = "";
                                hdellogstatus = "1"; // '己簽核
                            }
                            //'==========================
                        }

                        col.hdellogstatus  = hdellogstatus;
                        col.rolestampid    = tmprole;
                        col.rolestampidall = roleall;
                        col.empstampidall  = col.empstampidall + ",'" + (string)Session["empid"] + "'"; //'所有人員帳號
                        col.bmodid         = (string)Session["empid"];
                        col.bmoddate       = DateTime.Now;
                        col.billtime       = col.billtime + "," + DateTime.Now.ToString();

                        if (tmprole != "")
                        {
                            //寄信
                            logcheckEditMail(col, tmprole);
                        }
                        else
                        {
                            //(己通過)  寄信
                            logcheckEditMailPass(col);
                        }
                    }
                    else
                    {
                        col.hdellogstatus = "2";
                        col.delback       = chks.delback;
                        col.bmodid        = (string)Session["empid"];
                        col.bmoddate      = DateTime.Now;
                        //  col.billtime = col.billtime + "," + DateTime.Now.ToString();

                        //(己通過)  寄信
                        logcheckEditMailBack(col);
                    }

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.Entry(col).State = EntityState.Modified;
                        con.SaveChanges();
                    }


                    if (hdellogstatus == "1")
                    {
                        //銷假時數補回
                        delholidayMode(col, hdellogstatus);
                    }



                    //系統LOG檔

                    if (sysnote.Length > 4000)
                    {
                        sysnote = sysnote.Substring(0, 4000);
                    }
                    ////================================================= //

                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/delholiday/logcheckList' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";

                    tmpform += "<input type=hidden id='qhlogsdate' name='qhlogsdate' value='" + qhlogsdate + "'>";
                    tmpform += "<input type=hidden id='qhlogedate' name='qhlogedate' value='" + qhlogedate + "'>";

                    tmpform += "</form>";
                    tmpform += "</body>";

                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Esempio n. 26
0
        public ActionResult Edit(empfunction chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "funorder";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qempdid = "", funid = "";

            if (!string.IsNullOrWhiteSpace(Request["qempdid"]))
            {
                qempdid         = Request["qempdid"].Trim();
                ViewBag.qempdid = qempdid;
            }
            if (!string.IsNullOrWhiteSpace(Request["funid"]))
            {
                funid         = Request["funid"].Trim();
                ViewBag.funid = funid;
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var         data          = con.empfunction.Where(r => r.empdid == chks.empdid).FirstOrDefault();
                    empfunction eempfunctions = con.empfunction.Find(chks.empdid);
                    if (eempfunctions == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(eempfunctions));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string empdid = Request["empdid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.empid            = "99999999";
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        dbdata     = dbobj.get_dbvalue(sysconn, "select chkitem from checkcode where chkclass='08' and chkcode='" + chks.funid + "'");
                        string        sysnote    = "共用首頁設定:" + dbdata + "的資料";
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/empfunction/List' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden id='qempdid' name='qempdid' value='" + qempdid + "'>";
                        tmpform += "<input type=hidden id='funid' name='funid' value='" + funid + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
        public ActionResult DeleteConfirmed1(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string qsublevelname1 = "";
            string uplink         = "";

            if (!string.IsNullOrWhiteSpace(Request["qsublevelname1"]))
            {
                qsublevelname1         = Request["qsublevelname1"].Trim();
                ViewBag.qsublevelname1 = qsublevelname1;
            }
            if (!string.IsNullOrWhiteSpace(Request["uplink"]))
            {
                uplink         = Request["uplink"].Trim();
                ViewBag.uplink = uplink;
            }

            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string esid          = dbobj.get_dbvalue(conn1, "select sid from sublevel1 where sid ='" + condtionArr[i].ToString() + "'");
                        string esublevelname = dbobj.get_dbvalue(conn1, "select sublevelname from sublevel1 where sid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "表單代碼:" + esid + ",主目錄名稱:" + esublevelname + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM sublevel1 where sid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    // string tgourl = "/sublevel1/List1?page=" + page + "&qsublevelname1=" + qsublevelname1 + "&uplink=" + uplink;
                    // return new ContentResult() { Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>" };

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/sublevel1/List1' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='uplink' id='uplink' value='" + uplink + "'>";
                    tmpform += "<input type=hidden id='qsublevelname1' name='qsublevelname1' value='" + qsublevelname1 + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });

                    //return RedirectToAction("List");
                }
            }
        }
        public ActionResult logadd(delholidaylog col, string sysflag, int?page, string orderdata, string orderdata1, HttpPostedFileBase logopic1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "hdellogid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;


            if (sysflag != "A")
            {
                delholidaylog newcol = new delholidaylog();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    NDcommon dbobj = new NDcommon();
                    //簽核
                    string tmparolestampid = "";
                    if (dbobj.get_dbnull2(Request["arolestampid"]) != "")
                    {
                        tmparolestampid = "'" + Request["arolestampid"].ToString() + "'";
                    }
                    else
                    {
                        tmparolestampid = "'" + Request["arolestampid1"].ToString() + "'";
                    }

                    string tmpmoney = "0", tmprole = "", tmpbillid = "";
                    //找出下一個角色是誰
                    string impallstring = dbobj.getnewcheck1("H", tmparolestampid, tmparolestampid, Request["hloghour"], "", "");
                    tmprole   = impallstring.Split(';')[0].ToString();
                    tmpbillid = impallstring.Split(';')[1].ToString();
                    string errmsg = "";
                    if (tmprole == "")
                    {
                        errmsg         = "請先至表單流程設定中設定首長信箱的呈核流程!";
                        ViewBag.errmsg = "<script>alert('" + errmsg + "');</script>";
                        return(View(col));
                    }
                    //簽核
                    //if ((string)Session["mplayrole"] == "")
                    //{
                    //    errmsg = "您並未設定呈核角色!";
                    //    ViewBag.errmsg = "<script>alert('" + errmsg + "');</script>";
                    //    return View(col);
                    //}


                    //'找單據編號(自動產生編號)
                    string tmpbsno = "select hdno from delholidaylog where year(cdate) = " + DateTime.Now.Year + " and month(cdate) = " + DateTime.Now.Month + "  and hdno is not null order by hdno desc";
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        tmpbsno = dbobj.get_dbvalue(conn, tmpbsno);
                    }

                    if (tmpbsno != "")
                    {
                        tmpbsno = tmpbsno.Substring(tmpbsno.Length - 3, 3);
                        tmpbsno = (int.Parse(tmpbsno) + 1).ToString("000");
                    }
                    else
                    {
                        tmpbsno = "001";
                    }
                    string tmpyear  = (DateTime.Now.Year - 1911).ToString();
                    string tmpmonth = DateTime.Now.Month.ToString("00");
                    tmpbsno = "A" + tmpyear + tmpmonth + tmpbsno;
                    //======


                    col.hdellogstatus = "0";
                    col.hdno          = tmpbsno;


                    //呈核人員
                    //======
                    if (dbobj.get_dbnull2(col.arolestampid) == "")
                    {
                        col.arolestampid = Request["arolestampid1"];
                    }
                    col.rolestampid    = tmprole;                      //'下個呈核角色
                    col.rolestampidall = tmparolestampid;              //'所有呈核角色
                    col.empstampidall  = "'" + Request["empid"] + "'"; //'所有人員帳號
                    col.billflowid     = int.Parse(tmpbillid);
                    //======

                    col.comid    = (string)Session["comid"];
                    col.bmodid   = (string)Session["empid"];
                    col.bmoddate = DateTime.Now;
                    col.deldate  = DateTime.Now;
                    col.billtime = DateTime.Now.ToString();

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.delholidaylog.Add(col);
                        con.SaveChanges();
                    }



                    //    '寄信
                    //'======================
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        string fromadd = "", fromaddname = "", mailtitle = "", MailContext = "";
                        fromadd     = dbobj.get_dbvalue(conn, "select enemail from employee where empid='" + Request["empid"] + "'");
                        fromaddname = dbobj.get_dbvalue(conn, "select empname from employee where empid='" + Request["empid"] + "'");

                        //'寄送mail給下一個審核角色
                        #region 寄送mail給下一個審核角
                        mailtitle   = "銷假單資料要求簽核通知";
                        MailContext = "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=BIG5'></HEAD><body>";
                        MailContext = MailContext + "以下為明細資料:<BR>";
                        MailContext = MailContext + "<table cellpadding=3 cellspacing=0 bordercolorlight=#000000 bordercolordark=ffffff border=1 width=400 bgcolor=ffffff style='FONT-SIZE: 11pt;FONT-FAMILY:Tahoma,Arial'>";
                        MailContext = MailContext + "<tr><td align=right width=130>申請單號:</td><td>" + tmpbsno + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>請假單號:</td><td>" + col.hsno + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>申請人:</td><td>" + col.empname + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>假別:</td><td>" + Request["hdaytitle"] + "</td></tr>";

                        string hlogsdate = dbobj.get_dbDate(col.hlogsdate, "yyyy/MM/dd");
                        string hlogedate = dbobj.get_dbDate(col.hlogedate, "yyyy/MM/dd");
                        string SEDate    = "自{0} ({1})<br>至{2} ({3})";
                        SEDate      = string.Format(SEDate, hlogsdate, col.hlogstime, hlogedate, col.hlogetime);
                        MailContext = MailContext + "<tr><td align=right width=130>日期起訖:</td><td>" + SEDate + "</td></tr>";

                        if (dbobj.get_dbnull2(col.hlogcomment) != "")
                        {
                            MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>" + col.hlogcomment.ToString().Trim().Replace(Environment.NewLine, "<br>") + "</td></tr>";
                        }
                        else
                        {
                            MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>&nbsp;</td></tr>";
                        }


                        MailContext = MailContext + "</table>";
                        MailContext = MailContext + "</body></HTML>";

                        string tmproleid = tmprole.Replace("'", "");
                        string sql       = "select enemail from viewemprole where rid = '" + tmproleid + "' and empstatus <> '4' and enemail<>''";
                        using (SqlCommand cmd = new SqlCommand(sql, conn))
                        {
                            SqlDataReader dr     = cmd.ExecuteReader();
                            string        tomail = "";
                            while (dr.Read())
                            {
                                tomail += dr["enemail"] + ",";
                            }
                            dbobj.send_mailfile("", tomail, mailtitle, MailContext, null, null);

                            dr.Close();
                        }
                        #endregion
                    }


                    //系統LOG檔
                    string sysnote = "申請人:{0}<br>申請單號:{1}的資料";
                    sysnote = string.Format(sysnote, Request["empid"], tmpbsno);
                    if (sysnote.Length > 4000)
                    {
                        sysnote = sysnote.Substring(0, 4000);
                    }
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/delholiday/logcheckList' method='post'>";
                    //tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    //tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    //tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    //tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";
                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }