protected void Page_Load(object sender, System.EventArgs e) { BUTTON_save.Attributes.Add("OnClick", "return j1()"); //如前端javascript檢查有問題,禁止提交頁面 //Page.Title = "EngineeringTest Add Page"; int count = 1; Int32.TryParse(Request.Form["idx"], out count); count = count; // Label1.Text = count.ToString(); string value = Request.Form["txtSymbol"]; //Label3.Text = value; DateTime dt = DateTime.Now; //呼叫日期函數 this.add_date.Text = dt.ToString("d"); //今天日期 this.add_user.Text = this.CurrentUser.Name.ToString(); SmoothEnterprise.Database.DataSet rdata = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rdata.Open("select comid from dguser where logonid='" + this.CurrentUser.LogonID.ToString() + "' "); if (!rdata.EOF) { this.plantid.Text = rdata["comid"].ToString(); } managerlevel aa = new managerlevel(); //引用managerlevel class this.FIELD_lsend.Text = aa.manager(this.CurrentUser.ID.ToString()).Split('@')[0]; SmoothEnterprise.Database.DataSet rsa = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); //Response.Write("select pname,pid from ERP_FLOW WHERE ERP_NAME='apmt420' and dep_name='acc' and no in (SELECT CASE WHEN pml04 IN ('MISC固資','MISC-雜項購置') THEN '2' ELSE '1' END ot_hr FROM APMT420_IN_BODY b,APMT420_IN_HEAD a where a.pmk01=b.pmk01 and a.plantid=b.plantID and b.pmk01='" + rs["pmk01"].ToString() + "' and pml02='1' AND a.plantid='" + rs["plantID"].ToString() + "')"); rsa.Open("select pname,pid from ERP_FLOW WHERE ERP_NAME='EngineeringTest' and dep_name='pmc' and no='1' "); if (!rsa.EOF) { this.FIELD_pmcsend.Text = rsa["pid"].ToString(); } //data2 = "["; //SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); //rs.Open("select top 10 email from dguser where name <> '' and email like 'ann%' group by email "); //while (!rs.EOF) //{ // data2 = data2 + "{\"id\":\"" + rs["email"].ToString() + "\",\"name\":\"" + rs["email"].ToString() + "\"},"; // rs.MoveNext(); //} //rs.Close(); //data2.Remove(data2.Length - 1, 1); //data2 = data2 + "]"; }
protected void BUTTON_SendRequest_Click(object sender, SmoothEnterprise.Flowwork.UI.WebControl.FlowButtonEventArgs e) { SmoothEnterprise.Database.DataSet rb = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rb.Open("SELECT * FROM " + db1 + "cxmt310_in_head WHERE id='" + Request.QueryString["id"] + "' "); if (!rb.EOF) { rb["STATUS"] = "Y"; rb["senduser"] = this.CurrentUser.ID.ToString(); rb.Update(); } rb.Close(); this.BUTTON_SendRequest.Flow = this.FlowClient1; managerlevel aa = new managerlevel(); //引用managerlevel class ArrayList all = new ArrayList(); //all arraylist ArrayList managerid = new ArrayList(); //主管id arraylist ArrayList managerlv = new ArrayList(); //主管階級 arraylist ArrayList managernm = new ArrayList(); //主管職稱 arraylist SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rs.Open("select b.id bid,b.name bname from " + db1 + "cxmt310_in_head a LEFT JOIN " + db2 + "DGUSER b ON oqa07=erpid WHERE a.id='" + Request.QueryString["id"] + "' "); if (!rs.EOF) { if (this.FIELD_plantid.Text.Trim() == "MAY") //MAY業務=業務主管, 故只簽一次 { managerid.Add(rs["bid"].ToString()); managernm.Add("業務主管"); } else { managerid.Add(rs["bid"].ToString()); managernm.Add("業務"); managerid.Add(aa.manager(rs["bid"].ToString()).Split('@')[0]); managernm.Add("業務主管"); // 如組織圖中無官副總, 要加----------------------------------------- string vinc = "4A2805A5-6BDB-446B-B1CA-6D181E222B3E"; //官副總id string checkvinc = ""; foreach (string i in managerid) //將簽核人員id塞進flow { if (i.ToString().ToUpper() == vinc) { checkvinc = "1"; } } if (checkvinc == "") { managerid.Add(vinc); managernm.Add("業務最高主管"); } //---------------------------------------------------------------------- } } sharflow12.Flowwork.sharflow121 flow = new sharflow12.Flowwork.sharflow121(); FlowClient1.Text = "報價單電子簽核 ERP單號:" + this.FIELD_oqa01.Text; //更改流程名稱 switch (managerid.Count) //依舊arraylist裡面有幾個,來判斷走那條flow { case 1: e.NextNode = flow.sharflow12Node1; break; case 2: e.NextNode = flow.sharflow12Node2; break; case 3: e.NextNode = flow.sharflow12Node4; break; case 4: e.NextNode = flow.sharflow12Node7; break; case 5: e.NextNode = flow.sharflow12Node11; break; case 6: e.NextNode = flow.sharflow12Node16; break; case 7: e.NextNode = flow.sharflow12Node22; break; case 8: e.NextNode = flow.sharflow12Node29; break; case 9: e.NextNode = flow.sharflow12Node37; break; case 10: e.NextNode = flow.sharflow12Node46; break; case 11: e.NextNode = flow.sharflow12Node56; break; case 12: e.NextNode = flow.sharflow12Node67; break; } e.NextNode.ReviewerURL = "/ERP_CXMT310/CXMT310VIEW.aspx"; #region 刪除簽核人員pur_risk_sign SmoothEnterprise.Database.DataSet delrs = new SmoothEnterprise.Database.DataSet(); delrs.ExecuteNonQuery("delete " + db1 + "CXMT310_sign where mid='" + Request.QueryString["id"] + "'"); #endregion int count = 0; foreach (string i in managerid) //將簽核人員id塞進flow { this.FlowClient1.AddParameter("USER" + count.ToString(), i); //Response.Write("USER" + count.ToString() + ")" + i + "<br>"); count++; #region 新增簽核人員至pur_risk_sign delrs.ExecuteNonQuery("INSERT INTO " + db1 + "CXMT310_sign (mid,user_id,number) VALUES ('" + Request.QueryString["id"] + "','" + i.ToString() + "','" + count.ToString() + "')"); #endregion } count = 0; foreach (string i in managernm) //將簽核人員職稱塞進flow { this.FlowClient1.AddParameter("USERTITLE" + count.ToString(), i); count++; } SmoothEnterprise.Database.DataSet rss = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rss.Open("select id bid,name,email from " + db2 + "dguser where id = '" + this.CurrentUser.ID + "' "); if (!rss.EOF) { ArrayList email_list = new ArrayList(); //email list email_list.Add(rss["name"].ToString() + '#' + rss["email"].ToString()); #region 代理人 SmoothEnterprise.Database.DataSet rs2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs2.Open(" SELECT b.name name,email FROM " + db2 + "dguserdeputy a left join " + db2 + "dguser b on a.deputyuid=b.id left join " + db2 + "dgflow c on a.sid=c.id " + " where a.uid='" + rss["bid"].ToString() + "' " + " and " + " ((a.sid is null and sdate < GETDATE() and edate is null) or " + " (c.typename like 'ERP_FLOW%' and sdate < GETDATE() and edate is null) or " + " (c.typename like 'ERP_FLOW%' and sdate < GETDATE() and edate > GETDATE()) or " + " a.sid is null and sdate < GETDATE() and edate > GETDATE()) group by b.name,email "); while (!rs2.EOF) { email_list.Add(rs2["name"].ToString() + '#' + rs2["email"].ToString()); rs2.MoveNext(); } rs2.Close(); #endregion foreach (string i in email_list) { String ques; MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); MailAddress to = new MailAddress(i.Split('#')[1]); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage(from, to); ques = i.Split('#')[0] + " 您好:" + "<br>" + "<br>" + "ERP報價電子簽核申請單現有一筆,正等待您的處理:" + "<br>" + "<br>" + "申請單號 : " + this.FIELD_no.Text + "<br>" + "ERP單號 : " + this.FIELD_oqa01.Text + "<br>" + "申請日期 : " + this.FIELD_oqa02.Text + "<br>" + "申請人員 : " + this.FIELD_g_name.Text + "<br>" + "申請內容 : " + "<a href=\"http://eip.minaik.com.tw/ERP_CXMT310/CXMT310View.aspx?id=" + Request.QueryString["id"] + "\" >至ERP報價電子簽核系統檢視並編輯內容</a>" + "<br>" + "如您想了解更多有關員工入口網站的資訊請點選以下連結進入" + "<br>" + "<a href=\"http://eip.minaik.com.tw/\">員工入口網站</a>" + "<br>" + "感謝您對員工入口網站的支持與愛護,<font Color='red'>。因本信件為系統自動發送,請勿直接以此郵件回覆。</font>"; message.Subject = "報價單號 - " + this.FIELD_no.Text + " ERP單號-" + this.FIELD_oqa01.Text + "等待您的處理"; message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Credentials = new NetworkCredential("eip", "eip1106"); client.Send(message); } } //讓更新能顯示------------------------------------------------------------------------------------ Response.Write("<script type=\"text/javascript\">"); Response.Write("location.href='CXMT310Edit.aspx?id=" + Request.QueryString["ID"] + "';"); Response.Write("</script>"); //------------------------------------------------------------------------------------------------- }
protected void BUTTON_SendRequest_Click(object sender, SmoothEnterprise.Flowwork.UI.WebControl.FlowButtonEventArgs e) { SmoothEnterprise.Database.DataSet rb = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rb.Open("SELECT * FROM " + db + "apmi255_in_head WHERE id='" + Request.QueryString["id"] + "' "); if (!rb.EOF) { rb["STATUS"] = "Y"; rb["senduser"] = this.CurrentUser.ID.ToString(); rb.Update(); } rb.Close(); this.BUTTON_SendRequest.Flow = this.FlowClient1; managerlevel aa = new managerlevel(); //引用managerlevel class ArrayList all = new ArrayList(); //all arraylist ArrayList managerid = new ArrayList(); //主管id arraylist ArrayList managerlv = new ArrayList(); //主管階級 arraylist ArrayList managernm = new ArrayList(); //主管職稱 arraylist managerid.Add(this.FIELD_lsend.Text); managernm.Add("直屬主管"); if (this.FIELD_lsend.Text != aa.manager(this.CurrentUser.ID.ToString()).Split('@')[0]) { managerid.Add(aa.manager(this.CurrentUser.ID.ToString()).Split('@')[0]); managernm.Add("直屬主管"); } if (this.FIELD_pmiuser.Text.Substring(0, 2) == "EF" && this.FIELD_flowstatus.Text.Trim().Substring(0, 1) == "1") //MAY人員且簽核流程為1 送跨廠即可 { SmoothEnterprise.Database.DataSet rsA = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rsA.Open("select * from ERP_FLOW where ERP_NAME='apmi255' and DEP_NAME='PUR' AND NO='MAT審核的採購' AND PID='" + this.FIELD_mpru.Text + "' "); //確認MAY選的採購是否為MAT人員 if (!rsA.EOF) { managerid.Add(this.FIELD_mpru.Text); managernm.Add("跨廠採購人員"); } else { managerid.Add("43AB27FF-E6C8-4A46-83AA-AB4590F252D3"); managernm.Add("跨廠採購人員"); } } sharflow12.Flowwork.sharflow121 flow = new sharflow12.Flowwork.sharflow121(); FlowClient1.Text = "採購核價單電子簽核 ERP單號:" + this.FIELD_pmi01.Text.ToString(); //更改流程名稱 switch (managerid.Count) //依舊arraylist裡面有幾個,來判斷走那條flow { case 1: e.NextNode = flow.sharflow12Node1; break; case 2: e.NextNode = flow.sharflow12Node2; break; case 3: e.NextNode = flow.sharflow12Node4; break; case 4: e.NextNode = flow.sharflow12Node7; break; case 5: e.NextNode = flow.sharflow12Node11; break; case 6: e.NextNode = flow.sharflow12Node16; break; case 7: e.NextNode = flow.sharflow12Node22; break; case 8: e.NextNode = flow.sharflow12Node29; break; case 9: e.NextNode = flow.sharflow12Node37; break; case 10: e.NextNode = flow.sharflow12Node46; break; case 11: e.NextNode = flow.sharflow12Node56; break; case 12: e.NextNode = flow.sharflow12Node67; break; } e.NextNode.ReviewerURL = "/ERP_APMI255/ERP_APMI255VIEW.aspx"; int count = 0; foreach (string i in managerid) //將簽核人員id塞進flow { this.FlowClient1.AddParameter("USER" + count.ToString(), i); //Response.Write("USER" + count.ToString() + ")" + i + "<br>"); count++; } count = 0; foreach (string i in managernm) //將簽核人員職稱塞進flow { this.FlowClient1.AddParameter("USERTITLE" + count.ToString(), i); //Response.Write("USERTITLE" + count.ToString() + ")" + i + "<br>"); count++; } SmoothEnterprise.Database.DataSet rss = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rss.Open("select id bid,name,email from dguser where id = '" + this.FIELD_lsend.Text + "' "); if (!rss.EOF) { ArrayList email_list = new ArrayList(); //email list email_list.Add(rss["name"].ToString() + '#' + rss["email"].ToString()); #region 代理人 SmoothEnterprise.Database.DataSet rs2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs2.Open(" SELECT b.name name,email FROM dguserdeputy a left join dguser b on a.deputyuid=b.id left join dgflow c on a.sid=c.id " + " where a.uid='" + rss["bid"].ToString() + "' " + " and " + " ((a.sid is null and sdate < GETDATE() and edate is null) or " + " (c.typename like 'ERP_FLOW%' and sdate < GETDATE() and edate is null) or " + " (c.typename like 'ERP_FLOW%' and sdate < GETDATE() and edate > GETDATE()) or " + " a.sid is null and sdate < GETDATE() and edate > GETDATE()) group by b.name,email "); while (!rs2.EOF) { //MyLibrary_AXMT610 Backsend = new MyLibrary_AXMT610(); email_list.Add(rs2["name"].ToString() + '#' + rs2["email"].ToString()); rs2.MoveNext(); } rs2.Close(); #endregion foreach (string i in email_list) { //Response.Write( i + "<br>"); //Response.Write(i.Split('#')[0] + "<br>"); //人員姓名 //Response.Write(i.Split('#')[1] + "<br>"); //人員email String ques; MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); MailAddress to = new MailAddress(i.Split('#')[1]); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage(from, to); ques = i.Split('#')[0] + " 您好:" + "<br>" + "<br>" + "ERP採購核價電子簽核申請單現有一筆,正等待您的處理:" + "<br>" + "<br>" + "申請單號 : " + this.FIELD_no.Text + "<br>" + "ERP單號 : " + this.FIELD_pmi01.Text + "<br>" + "申請日期 : " + this.FIELD_pmi02.Text + "<br>" + "申請人員 : " + this.FIELD_gen02_1.Text + "<br>" + "申請內容 : " + "<a href=\"http://eip.minaik.com.tw/ERP_APMI255/ERP_APMI255View.aspx?id=" + Request.QueryString["id"] + "\" >至ERP採購核價電子簽核系統檢視並編輯內容</a>" + "<br>" + "如您想了解更多有關員工入口網站的資訊請點選以下連結進入" + "<br>" + "<a href=\"http://eip.minaik.com.tw/\">員工入口網站</a>" + "<br>" + "感謝您對員工入口網站的支持與愛護,<font Color='red'>。因本信件為系統自動發送,請勿直接以此郵件回覆。</font>"; if (this.FIELD_quick.Text.Trim() == "Y") { message.Subject = "(急件)核價單號 - " + this.FIELD_no.Text + " ERP單號-" + this.FIELD_pmi01.Text + "等待您的處理"; } else { message.Subject = "核價單號 - " + this.FIELD_no.Text + " ERP單號-" + this.FIELD_pmi01.Text + "等待您的處理"; } message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Credentials = new NetworkCredential("eip", "eip1106"); client.Send(message); } } //讓更新能顯示------------------------------------------------------------------------------------ Response.Write("<script type=\"text/javascript\">"); Response.Write("location.href='erp_apmi255Edit.aspx?id=" + Request.QueryString["ID"] + "';"); Response.Write("</script>"); //------------------------------------------------------------------------------------------------- }
protected void Page_Load(object sender, System.EventArgs e) { try { BUTTON_save.Attributes.Add("OnClick", "return j1()"); //如前端javascript檢查有問題,禁止提交頁面 BUTTON_SendRequest.Attributes.Add("OnClick", "return j1()"); //如前端javascript檢查有問題,禁止提交頁面 if (!IsPostBack) { SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rs.Open("SELECT * FROM " + db + "APMI255_IN_HEAD WHERE id='" + Request.QueryString["id"] + "' "); if (!rs.EOF) { this.FIELD_no.Text = rs["no"].ToString(); this.FIELD_plantid.Text = rs["plantid"].ToString(); this.FIELD_CompanyName.Text = rs["CompanyName"].ToString(); this.FIELD_pmi01.Text = rs["pmi01"].ToString(); this.FIELD_pmi02.Text = rs["pmi02"].ToString(); this.FIELD_pmi03.Text = rs["pmi03"].ToString(); this.FIELD_pmc03_0.Text = rs["pmc03_0"].ToString(); this.FIELD_pmi04.Text = rs["pmi04"].ToString(); this.FIELD_pmi05.Text = rs["pmi05"].ToString(); pmr05 = rs["pmi05"].ToString(); this.FIELD_pmi08.Text = rs["pmi08"].ToString(); this.FIELD_pmi081.Text = rs["pmi081"].ToString(); this.FIELD_pmiuser.Text = rs["pmiuser"].ToString(); this.FIELD_gen02_1.Text = rs["gen02_1"].ToString(); this.FIELD_pmigrup.Text = rs["pmigrup"].ToString(); this.FIELD_gem02_2.Text = rs["gem02_2"].ToString(); this.FIELD_flowstatus.Text = rs["ta_pmi01"].ToString(); this.FIELD_lsend.Text = rs["lsend"].ToString(); this.FIELD_mpru.Text = rs["mpru"].ToString(); this.FIELD_rember.Text = rs["rember"].ToString(); this.FIELD_quick.Text = rs["quick"].ToString().Trim(); switch (rs["status"].ToString()) { case "N": InputText1.Text = "未送審"; this.InputButton1.Enabled = false; break; case "Y": InputText1.Text = "送審中"; this.BUTTON_save.Enabled = false; this.BUTTON_SendRequest.Enabled = false; this.BUTTON_ERP.Enabled = false; break; case "OK": InputText1.Text = "完成審核"; this.BUTTON_save.Enabled = false; this.BUTTON_ERP.Enabled = false; this.InputButton1.Enabled = false; if (this.CurrentUser.LogonID.ToString() != "ann.lin") { this.BUTTON_SendRequest.Visible = false; } break; //case "ERP": // InputText1.Text = "退回ERP修改"; // this.BUTTON_SendRequest.Enabled = false; // this.BUTTON_save.Enabled = false; // this.BUTTON_ERP.Enabled = false; // this.InputButton1.Enabled = false; // this.BUTTON_SendRequest.Visible = false; // break; case "NO": InputText1.Text = "退回單據至ERP修改"; this.BUTTON_ERP.Enabled = false; this.InputButton1.Enabled = false; this.BUTTON_SendRequest.Visible = false; this.BUTTON_save.Enabled = false; break; case "V": InputText1.Text = "作廢"; this.BUTTON_save.Enabled = false; this.BUTTON_SendRequest.Enabled = false; this.BUTTON_ERP.Enabled = false; this.InputButton1.Enabled = false; break; default: InputText1.Text = "未送審"; this.InputButton1.Enabled = false; break; } //SqlDataSource1.SelectCommand = "select bno,pmj02,pmj03,pmj031,pmj032,pmj04,pmj05,pmj06,pmj06t,pmj07,pmj07t,pmj08, "+ // "CONVERT(varchar(12) , pmj09, 111 ) pmj09,pmj10,CONVERT(varchar(12) , ta_pmj01, 111 ) ta_pmj01, "+ // "ima491,ima51,pmr03,pmr04,pmr05,pmr05t from " + db + "apmi255_in_body left join " + db + "apmi255_in_pmr " + // " on bno=cno and pmj02=pmr02 where bno='" + rs["no"].ToString() + "' order by pmr03,pmj02 "; //改變datalist的sql SqlDataSource1.SelectCommand = "select apmi255_in_head.ID id,case when pmj06>pmj07 then 'aaa.png' else 'bbb.png' end img1,bno,pmj02,pmj03,pmj031,pmj032,pmj04,pmj05,pmj06,pmj06t,pmj07,pmj07t,pmj08, " + " CONVERT(varchar(12) , pmj09, 111 ) pmj09,pmj10,CONVERT(varchar(12) , ta_pmj01, 111 ) ta_pmj01, " + " ima491,ima46,pmr03,pmr04,pmr05,pmr05t from " + db + "apmi255_in_body left join " + db + "apmi255_in_pmr on bno=cno and pmj02=pmr02 " + " left join [EIPB].[dbo].apmi255_in_head on no=bno where bno='" + rs["no"].ToString() + "' order by pmr03,CAST(pmj02 AS int) "; this.GridView1.DataBind(); //Response.Write(SqlDataSource1.SelectCommand.ToString()); if (this.FIELD_lsend.Text == "") { managerlevel aa = new managerlevel(); //引用managerlevel class this.FIELD_lsend.Text = aa.manager(this.CurrentUser.ID.ToString()).Split('@')[0]; } if (rs["status"].ToString() == "N") { this.AddWarning(this, "Page_Load()", "", "請記得將單據送審!"); this.AddWarning(this, "Page_Load()", "", "若修改資料,請先按儲存鈕將資料儲存!"); } } else { Response.Redirect("ERP_APMI255.aspx"); } } //附檔---------------------------------------------------- int i = 0; ContentPlaceHolder cnt; cnt = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1"); CheckBoxList chb = (CheckBoxList)cnt.FindControl("CheckBoxFile"); SmoothEnterprise.Database.DataSet rs2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rs2.Open("SELECT id,FileName FROM axmt610_File WHERE FileKey='" + Request.QueryString["ID"] + "' and usertype='1' "); while (!rs2.EOF) { chb.Items.Add(new ListItem("<a href=\"FileDownload.aspx?id=" + rs2["id"].ToString() + "\" target=\"_blank\">" + rs2["FileName"].ToString() + "</a>", rs2["id"].ToString())); rs2.MoveNext(); } rs2.Close(); } catch { //Response.Redirect("ERP_APMI255.aspx"); } }