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