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
                });
            }
        }