Ejemplo n.º 1
0
        private void logcheckEditMail(delholidaylog col, string tmprole)
        {
            NDcommon dbobj = new NDcommon();

            #region 寄給下一個承辦人
            string mailtitle = "", MailContext = "";
            mailtitle   = "【" + col.empname + "】出差單資料要求審核通知";
            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>";

            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
            {
                tmprole = tmprole.Replace("'", "");
                string sql = "select enemail from viewemprole where rid = '" + tmprole + "' 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
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
        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
                    });
                }
            }
        }