/// <summary> /// 更新AD的Table狀態(2:送審 3:核准 4:駁回) /// </summary> /// <param name="AD">A事先/D事後</param> /// <param name="OTStatus">狀態</param> /// <param name="FlowCaseID">FlowCaseID</param> /// <param name="sb">回傳SQL語法</param> public static void UpdateOverTime(string AD, string OTStatus, string FlowCaseID, ref CommandHelper sb) { AD = CustVerify.ADTable(AD); sb.Append(" UPDATE " + AD + " SET OTStatus='" + OTStatus + "',"); //審核人員 sb.Append(" OTValidDate='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"); sb.Append(" OTValidID='" + UserInfo.getUserInfo().UserID + "' "); ////最後異動人員(Kat說不更新) //sb.Append(" LastChgDate='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"); //sb.Append(" LastChgID='" + UserInfo.getUserInfo().UserID + "', "); //sb.Append(" LastChgComp='" + UserInfo.getUserInfo().CompID + "' "); sb.Append(" WHERE FlowCaseID=").AppendParameter("FlowCaseID", FlowCaseID); }
/// <summary> ///Judy切割出來多筆審核撈取FlowLogID /// </summary> public static string getFlowLogID(string FlowCaseID, string AD) { FlowExpress tbFlow = new FlowExpress(Aattendant._AattendantFlowID); AD = CustVerify.ADTable(AD); DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); sb.AppendStatement(" SELECT top 1 AL.FlowLogID,* FROM " + AD + " OT "); sb.Append(" LEFT JOIN " + tbFlow.FlowCustDB + "FlowFullLog AL ON OT.FlowCaseID=AL.FlowCaseID "); sb.Append(" WHERE OT.FlowCaseID =").AppendParameter("FlowCaseID", FlowCaseID); sb.Append(" Order by AL.FlowLogID desc "); return(db.ExecuteScalar(sb.BuildCommand()).ToString()); }
/// <summary> /// 原本不允許送審重複主管,現在又改成可以,所以把這方法註解,改成不檢核直接查詢 /// </summary> /// <param name="SignID">下一關主管ID</param> /// <param name="SignIDComp">下一關主管公司</param> /// <param name="oAssDic">回傳Dictionary格式給永豐流程使用</param> // private void oAssDicCheck(string SignID, string SignIDComp, ref Dictionary<string, string> oAssDic) //{ // if (SignID.Trim().Equals(UserInfo.getUserInfo().UserID.Trim())) // { // oAssDic.Clear(); // } // else // { // oAssDic = CustVerify.getEmpID_Name_Dictionary(SignID, SignIDComp); // } //} protected void Page_Load(object sender, EventArgs e) { //代辦畫面傳來的多筆審核資料 DataTable dtOverTimeAdvance = (DataTable)Session["dtOverTimeAdvance"]; DataTable dtOverTimeDeclaration = (DataTable)Session["dtOverTimeDeclaration"]; //永豐流程相關資料 FlowExpress oFlow = new FlowExpress(Aattendant._AattendantFlowID, Request["FlowLogID"], true); //錯誤訊息儲存 string ErrMsg = ""; CustVerify CV = new CustVerify(); Dictionary <string, string> toUserData = (Dictionary <string, string>)Session["toUserData"]; //EmpInfo.QueryOrganData || EmpInfo.QueryFlowOrganData 使用 //string SignOrganID = "", SignID = "", SignIDComp = ""; if (!IsPostBack) { if (Session["FlowVerifyInfo"] != null) { #region "變數" //TrtCatchIsFlowVerify()使用 DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); //撈取該筆加班單相關資料 DataTable dtOverTime; //預設下關待辦人(會變,沒變代表沒找到相關資料) Dictionary <string, string> oVerifyInfo = (Dictionary <string, string>)Session["FlowVerifyInfo"]; Util.setJSContent(oVerifyInfo["FlowVerifyJS"]); Session["FlowVerifyInfo"] = null; Dictionary <string, string> oAssDic = Util.getDictionary(oVerifyInfo["FlowStepAssignToList"]); //共用檔 Aattendant _Aattendant = new Aattendant(); //Para撈取參數設定 DataTable dtOverTimePara_All = db.ExecuteDataSet(CommandType.Text, string.Format("SELECT DISTINCT CompID,Para FROM OverTimePara ")).Tables[0]; string AD = ""; #endregion "變數" switch (oVerifyInfo["FlowStepBtnID"].ToString()) { case "btnClose": case "btnReApprove": case "FlowReassign": case "btnApprove": //審核 //單筆審核(使用oFlow.FlowCaseID判斷) if (dtOverTimeAdvance == null && dtOverTimeDeclaration == null) { #region "單筆審核" //給IsFlowVerify的下一關簽核主管 //oAssDicCheck(toUserData["SignID"], toUserData["SignIDComp"], ref oAssDic); //原本要檢核主管是否重複,後來說不要了 oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]); switch (oFlow.FlowCurrStepID) { //事先 case "A10": case "A20": AD = "A"; break; //事後 case "A30": case "A40": AD = "D"; break; } dtOverTime = CustVerify.OverTime_find_by_FlowCaseID(oFlow.FlowCaseID, AD); if (oVerifyInfo["FlowStepBtnID"].ToString() == "btnClose") //結案 { sb.Reset(); CustVerify.UpdateOverTime(AD, "3", oFlow.FlowCaseID, ref sb); CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "2", ref sb); CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb); if (AD == "A") { CustVerify.insertFromAdvanceToData(oFlow.FlowCaseID, ref sb); } if (TryCatchIsFlowVerify(Request["FlowLogID"], oVerifyInfo["FlowStepBtnID"], oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true)) { CV.MailLogContent(oFlow.FlowCaseID, "3", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } else //沒結案 { sb.Reset(); DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(oFlow.FlowCaseID, false); CustVerify.UpdateOverTime(AD, "2", oFlow.FlowCaseID, ref sb); CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "2", ref sb); FlowUtility.InsertHROverTimeLogCommand( oFlow.FlowCaseID, CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()), CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()), AD, dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(), dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(), dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(), UserInfo.getUserInfo().UserID, dtHROverTimeLog.Rows[0]["FlowCode"].ToString(), dtHROverTimeLog.Rows[0]["FlowSN"].ToString(), CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()), toUserData["SignLine"], toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1 ); if (TryCatchIsFlowVerify(Request["FlowLogID"], oVerifyInfo["FlowStepBtnID"], oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true)) { CV.MailLogContent(oFlow.FlowCaseID, "2", AD, "", "", false); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } #endregion "單筆審核" } /*================================================*/ //多筆審核有四個迴圈,事先兩個是後兩個 //UpdateAD、HROverTimeLog、MailLog在第一迴圈 //其他在第二迴圈 //多筆審核按鈕(非印章) else { #region "事先多筆" if (dtOverTimeAdvance.Rows.Count > 0) { AD = "A"; for (int i = 0; i < dtOverTimeAdvance.Rows.Count; i++) { if (dtOverTimeAdvance.Rows[i]["OTSeqNo"].ToString() == "1") { oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "A"), true); string btnName = dtOverTimeAdvance.Rows[i]["btnName"].ToString(); //oAssDicCheck(dtOverTimeAdvance.Rows[i]["SignID"].ToString(), dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString(), ref oAssDic); oAssDic = CustVerify.getEmpID_Name_Dictionary(dtOverTimeAdvance.Rows[i]["SignID"].ToString(), dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString()); if (btnName == "btnClose") //結案 { sb.Reset(); CustVerify.UpdateOverTime(AD, "3", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb); CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", ref sb); CustVerify.CloseHROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), AD, ref sb); CustVerify.insertFromAdvanceToData(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false)) { CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "3", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } else //沒結案 { sb.Reset(); DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), false); CustVerify.UpdateOverTime(AD, "2", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb); CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", ref sb); FlowUtility.InsertHROverTimeLogCommand( dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()), CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()), AD, dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(), dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(), dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(), UserInfo.getUserInfo().UserID, dtHROverTimeLog.Rows[0]["FlowCode"].ToString(), dtHROverTimeLog.Rows[0]["FlowSN"].ToString(), CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()), //toUserData start dtOverTimeAdvance.Rows[i]["SignLine"].ToString(), dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString(), dtOverTimeAdvance.Rows[i]["SignID"].ToString(), dtOverTimeAdvance.Rows[i]["SignOrganID"].ToString(), dtOverTimeAdvance.Rows[i]["SignFlowOrganID"].ToString(), //toUserData end "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1 ); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false)) { CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", AD, "", "", false); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } } } } #endregion "事先多筆" /*------------------*/ #region "事後多筆" if (dtOverTimeDeclaration.Rows.Count > 0) { AD = "D"; for (int i = 0; i < dtOverTimeDeclaration.Rows.Count; i++) { if (dtOverTimeDeclaration.Rows[i]["OTSeqNo"].ToString() == "1") { oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "D"), true); string btnName = dtOverTimeDeclaration.Rows[i]["btnName"].ToString(); //oAssDicCheck(dtOverTimeDeclaration.Rows[i]["SignID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString(), ref oAssDic); oAssDic = CustVerify.getEmpID_Name_Dictionary(dtOverTimeDeclaration.Rows[i]["SignID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString()); if (btnName == "btnClose") //結案 { sb.Reset(); CustVerify.UpdateOverTime(AD, "3", dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), ref sb); CustVerify.UpdateHROrverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", ref sb); CustVerify.CloseHROverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), AD, ref sb); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false)) { CV.MailLogContent(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "3", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } else //沒結案 { sb.Reset(); DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), false); CustVerify.UpdateOverTime(AD, "2", dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), ref sb); CustVerify.UpdateHROrverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", ref sb); FlowUtility.InsertHROverTimeLogCommand( dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()), CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()), AD, dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(), dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(), dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(), UserInfo.getUserInfo().UserID, dtHROverTimeLog.Rows[0]["FlowCode"].ToString(), dtHROverTimeLog.Rows[0]["FlowSN"].ToString(), CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()), //toUserData start dtOverTimeDeclaration.Rows[i]["SignLine"].ToString(), dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString(), dtOverTimeDeclaration.Rows[i]["SignID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignOrganID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignFlowOrganID"].ToString(), //toUserData end "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1 ); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false)) { CV.MailLogContent(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", AD, "", "", false); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } } } } #endregion "事後多筆" } break; /*=================================================*/ case "btnReject": //駁回 if (dtOverTimeAdvance == null && dtOverTimeDeclaration == null) //true 印章 false 多筆審核按鈕 { #region "單筆駁回" switch (oFlow.FlowCurrStepID) { //事先 case "A10": case "A20": AD = "A"; break; //事後 case "A30": case "A40": AD = "D"; break; } dtOverTime = CustVerify.OverTime_find_by_FlowCaseID(oFlow.FlowCaseID, AD); sb.Reset(); CustVerify.UpdateOverTime(AD, "4", oFlow.FlowCaseID, ref sb); CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "3", ref sb); CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb); if (AD == "D") { CustVerify.AfterReject_CheckAndInsert(oFlow.FlowCaseID, ref sb); } //ClearBtn(oFlow.FlowCurrLogAssignTo); if (TryCatchIsFlowVerify(Request["FlowLogID"], "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true)) { CV.MailLogContent(oFlow.FlowCaseID, "4", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } #endregion "單筆駁回" } else //多筆審核按鈕 { #region "多筆駁回" if (dtOverTimeAdvance.Rows.Count > 0) { AD = "A"; for (int i = 0; i < dtOverTimeAdvance.Rows.Count; i++) { if (dtOverTimeAdvance.Rows[i]["OTSeqNo"].ToString() == "1") { oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "A"), true); sb.Reset(); CustVerify.UpdateOverTime(AD, "4", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb); CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "3", ref sb); CustVerify.CloseHROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), AD, ref sb); //ClearBtn(oFlow.FlowCurrLogAssignTo); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false)) { CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "4", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } } } if (dtOverTimeDeclaration.Rows.Count > 0) { AD = "D"; for (int i = 0; i < dtOverTimeDeclaration.Rows.Count; i++) { if (dtOverTimeDeclaration.Rows[i]["OTSeqNo"].ToString() == "1") { oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "D"), true); sb.Reset(); CustVerify.UpdateOverTime(AD, "4", oFlow.FlowCaseID, ref sb); CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "3", ref sb); CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb); CustVerify.AfterReject_CheckAndInsert(oFlow.FlowCaseID, ref sb); //ClearBtn(oFlow.FlowCurrLogAssignTo); if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false)) { CV.MailLogContent(oFlow.FlowCaseID, "4", AD, "", "", true); labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); } } } } #endregion "多筆駁回" } break; /*==============================*/ } if (txtErrMsg.Text != "") { txtErrMsg.Text = "審核失敗清單:" + txtErrMsg.Text; txtErrMsg.Visible = true; } } else { //參數錯誤 labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.ParaError); } } }
/// <summary> ///遇到什麼奇怪狀況沒辦法知道現在關卡實際簽核人(非代理人)時,使用 /// </summary> private string getLastAssignTo(string FlowCaseID) { return(CustVerify.HROverTimeLog(FlowCaseID, false).Rows[0]["SignID"].ToString()); }
/// <summary> /// 寄信範本套用前區別狀態 /// </summary> /// <param name="FlowCase">依FlowCaseID找尋相關資料</param> /// <param name="OTStatus">(2、3核准) (4駁回)</param> /// <param name="AD">A事先/D事後</param> /// <param name="nextAssignID">下一關待辦人ID</param> /// <param name="nextAssignCompID">下一關待辦人CompID</param> /// <param name="isLastFlow">是否最後一關結案(判斷是否送下一關待辦人)</param> /// <returns>是否成功</returns> public bool MailLogContent(string FlowCase, string OTStatus, string AD, string nextAssignID, string nextAssignCompID, bool isLastFlow) { //DataTable ADBatchdt = FlowCaseToAD(FlowCase, AD); DataTable dtLastAssign = CustVerify.HROverTimeLogAD(FlowCase, AD); DataTable dtOverTime = CustVerify.OverTime_find_by_FlowCaseID(FlowCase, AD); DataTable dtMail; string OTEmpID = dtOverTime.Rows[0]["OTEmpID"].ToString(); string OTCompID = dtOverTime.Rows[0]["OTCompID"].ToString(); string AssignID = dtLastAssign.Rows[0]["SignID"].ToString(); string AssignCompID = dtLastAssign.Rows[0]["SignIDComp"].ToString(); string FromDT = ""; string Subject1 = "", Subject2 = "", Subject3 = ""; string Content1 = "", Content2 = "", Content3 = ""; string Title1 = "", Title2 = "", Title3 = ""; string Mail1 = "", Mail2 = "", Mail3 = ""; //string Name1 = "", Name2 = "", Name3 = ""; //DataTable Maildt; //Maildt = getMailInfo(OTEmpID); DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); CommandHelper sb2 = db.CreateCommandHelper(); switch (AD) { case "A": case "0": FromDT = "申請"; break; case "D": case "1": FromDT = "申報"; break; } if (OTStatus == "2" || OTStatus == "3") //核准 { if (isLastFlow) //最後一關結案 { Subject1 = "加班單流程案件結案通知"; //(主管) Title1 = "您簽核的加班單已經完成『結案』!"; dtMail = getMailInfo(AssignCompID, AssignID); if (dtMail.Rows.Count > 0) { Mail1 = dtMail.Rows[0]["EMail"].ToString(); //Name1 = Maildt.Rows[0]["Name"].ToString(); } Subject2 = "加班單流程案件核准通知";//(申請人) Title2 = "您" + FromDT + "的加班單已『核准』!"; dtMail = getMailInfo(OTCompID, OTEmpID); if (dtMail.Rows.Count > 0) { Mail2 = dtMail.Rows[0]["EMail"].ToString(); //Name2 = Maildt.Rows[0]["Name"].ToString(); } } else //非最後一關+待辦 { Subject1 = "加班單流程案件簽核通知";//(主管) Title1 = "您簽核的加班單已送簽至下一關主管簽核"; dtMail = getMailInfo(AssignCompID, AssignID); if (dtMail.Rows.Count > 0) { Mail1 = dtMail.Rows[0]["EMail"].ToString(); //Name1 = Maildt.Rows[0]["Name"].ToString(); } Subject2 = "加班單流程案件核准通知";//(申請人) Title2 = "您" + FromDT + "的加班單已送簽下一關主管簽核"; dtMail = getMailInfo(OTCompID, OTEmpID); if (dtMail.Rows.Count > 0) { Mail2 = dtMail.Rows[0]["EMail"].ToString(); //Name2 = Maildt.Rows[0]["Name"].ToString(); } Subject3 = "加班單流程待辦案件通知"; //(主管) dtMail = getMailInfo(nextAssignCompID, nextAssignID); if (dtMail.Rows.Count > 0) { Mail3 = dtMail.Rows[0]["EMail"].ToString(); //Name3 = Maildt.Rows[0]["Name"].ToString(); Title3 = dtMail.Rows[0]["Name"].ToString(); //代辦第一個欄位直接放BossName } } } else if (OTStatus == "4") //駁回 { Subject1 = "加班單流程案件駁回通知"; //(主管) Title1 = "您簽核的加班單已完成『駁回』!"; dtMail = getMailInfo(AssignCompID, AssignID); if (dtMail.Rows.Count > 0) { Mail1 = dtMail.Rows[0]["EMail"].ToString(); //Name1 = Maildt.Rows[0]["Name"].ToString(); } Subject2 = "加班單流程案件駁回通知";//(申請人) Title2 = "您" + FromDT + "的加班單已被『駁回』!"; dtMail = getMailInfo(OTCompID, OTEmpID); if (dtMail.Rows.Count > 0) { Mail2 = dtMail.Rows[0]["EMail"].ToString(); //Name2 = Maildt.Rows[0]["Name"].ToString(); } } else { Subject1 = ""; Title1 = ""; Mail1 = ""; Subject2 = ""; Title2 = ""; Mail2 = ""; Subject3 = ""; Title3 = ""; Mail3 = ""; //Name1 = ""; Name2 = ""; Name3 = ""; } //測試用 //Subject1 = "(leo)" + Subject1; //Subject2 = "(leo)" + Subject2; //Subject3 = "(leo)" + Subject3; if (dtOverTime.Rows.Count > 0) { //主管 Content1 = "NoticeOverTime" + "||BM@QuitMailContent1||" + Title1 + "||BM@QuitMailContent2||" + dtOverTime.Rows[0]["OTFormNo"].ToString() + "||BM@QuitMailContent3||" + dtOverTime.Rows[0]["OTEmpID"].ToString() + "||BM@QuitMailContent4||" + dtOverTime.Rows[0]["Name"].ToString() + "||BM@QuitMailContent5||" + dtOverTime.Rows[0]["OTDate"].ToString() + "||BM@QuitMailContent6||" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(2, 2) + "||BM@QuitMailContent7||" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(2, 2); if (Mail1 != "") { InsertMailLogCommand("人力資源處", AssignCompID, AssignID, Mail1, Subject1, Content1, false, ref sb2); try { db.ExecuteNonQuery(sb2.BuildCommand()); sb2.Reset(); } catch (Exception ex) { Util.MsgBox("加班人E-Mail寄送失敗-" + ex); return(false); } } else { MailisNull(Subject1, Content1, OTCompID, OTEmpID); } //申請人 Content2 = "NoticeOverTime" + "||BM@QuitMailContent1||" + Title2 + "||BM@QuitMailContent2||" + dtOverTime.Rows[0]["OTFormNo"].ToString() + "||BM@QuitMailContent3||" + dtOverTime.Rows[0]["OTEmpID"].ToString() + "||BM@QuitMailContent4||" + dtOverTime.Rows[0]["Name"].ToString() + "||BM@QuitMailContent5||" + dtOverTime.Rows[0]["OTDate"].ToString() + "||BM@QuitMailContent6||" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(2, 2) + "||BM@QuitMailContent7||" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(2, 2); if (Mail2 != "") { InsertMailLogCommand("人力資源處", OTCompID, OTEmpID, Mail2, Subject2, Content2, false, ref sb2); try { db.ExecuteNonQuery(sb2.BuildCommand()); sb2.Reset(); } catch (Exception ex) { Util.MsgBox("審核人E-Mail寄送失敗-" + ex); return(false); } } else { MailisNull(Subject2, Content2, AssignCompID, AssignID); } //下一關主管 if (OTStatus == "2" || OTStatus == "3") //核准 { if (!isLastFlow && nextAssignID != "") //最後一關結案 { Content3 = "OverTimeTodoList" + "||BM@QuitMailContent1||" + Title3 + "||BM@QuitMailContent2||" + dtOverTime.Rows[0]["OTFormNo"].ToString() + "||BM@QuitMailContent3||" + dtOverTime.Rows[0]["OTEmpID"].ToString() + "||BM@QuitMailContent4||" + dtOverTime.Rows[0]["Name"].ToString() + "||BM@QuitMailContent5||" + dtOverTime.Rows[0]["OTDate"].ToString() + "||BM@QuitMailContent6||" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTStartTime"].ToString().Substring(2, 2) + "||BM@QuitMailContent7||" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(0, 2) + ":" + dtOverTime.Rows[0]["OTEndTime"].ToString().Substring(2, 2) + "||BM@QuitMailContent8||" + "Total"; if (Mail3 != "") { InsertMailLogCommand("人力資源處", nextAssignCompID, nextAssignID, Mail3, Subject3, Content3, false, ref sb2); try { db.ExecuteNonQuery(sb2.BuildCommand()); } catch (Exception ex) { Util.MsgBox("下一關主管E-Mail寄送失敗-" + ex); return(false); } } else { MailisNull(Subject3, Content3, nextAssignCompID, nextAssignID); } } } } return(true); }
/// <summary> /// CancelVisitForm /// 公出查詢 /// 送簽後取消流程 /// </summary> /// <param name="model">畫面model</param> /// <param name="datas">回傳資料</param> /// <param name="msg">回傳訊息</param> /// <returns>bool</returns> public static bool CancelVisitForm(List <OnBizPublicOutModel> model, out long seccessCount, out string msg) { bool result = false; seccessCount = 0; msg = ""; try { Dictionary <string, string> ValidUserData = new Dictionary <string, string>(); FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_OnBiz/")); DbHelper db = new DbHelper(_attendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); string flowCaseIDForRollBack = ""; try { using (var trans = cn.BeginTransaction()) { try { foreach (OnBizPublicOutModel item in model) { OnBizPublicOutBean dataBean = new OnBizPublicOutBean() { CompID = item.CompID, EmpID = item.EmpID, WriteDate = item.OBWriteDate, FormSeq = item.OBFormSeq, FlowCaseID = item.FlowCaseID, FlowLogID = item.FlowLogID, ValidID = item.ValidID, LastChgComp = item.OBLastChgComp, LastChgID = item.OBLastChgID, LastChgDate = item.OBLastChgDate }; ValidUserData = CustVerify.getEmpID_Name_Dictionary(dataBean.ValidID, dataBean.CompID); if (FlowExpress.IsFlowVerify(flow.FlowID, dataBean.FlowLogID, "btnCancel", ValidUserData, "取消")) { sb.Reset(); flowCaseIDForRollBack += dataBean.FlowCaseID + ","; OBFlowUtility.ChangeFlowFlag(dataBean.FlowCaseID, "OB01", "0001", dataBean.CompID, dataBean.ValidID, "0", ref sb); SqlCommand.CancelVisitFormSql(dataBean, ref sb); SqlCommand.UpdateHROtherFlowLogSql(dataBean, ref sb); } } seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), trans); //執行新增,成功筆數回傳,並做Transaction機制 trans.Commit(); //成功Transaction直接Commit } catch (Exception) { trans.Rollback(); //失敗Transaction Rollback string[] flowCaseIDAry = flowCaseIDForRollBack.Split(","); for (int i = 0; i < flowCaseIDAry.Length - 1; i++) { FlowExpress.IsFlowRollBack(flow.FlowID, flowCaseIDAry[i]); } throw; } } } catch (Exception) { throw; } result = true; } catch (Exception ex) { msg = ex.Message; } return(result); }
/// <summary> /// Insert_UpdateVisitFormSign /// 公出申請、公出修改 /// 申請後送簽流程 /// </summary> /// <param name="model">畫面model</param> /// <param name="datas">回傳資料</param> /// <param name="msg">回傳訊息</param> /// <returns>bool</returns> public static bool Insert_UpdateVisitFormSign(OnBizPublicOutModel model, string regStr, out long seccessCount, out string msg) { bool result = false; seccessCount = 0; msg = ""; try { Dictionary <string, string> ValidUserData = new Dictionary <string, string>(); FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_OnBiz/")); string KeyValue = "";//字串 string[] strarray = null; string strFlowCaseID = ""; Dictionary <string, string> empData = new Dictionary <string, string>(); Dictionary <string, string> toUserData = new Dictionary <string, string>(); string flowCode = ""; string flowSN = ""; bool nextIsLastFlow = false; string meassge = ""; DbHelper db = new DbHelper(_attendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); OnBizPublicOutBean dataBean = new OnBizPublicOutBean() { CompID = model.CompID, oldCompID = model.oldCompID, EmpID = model.EmpID, oldEmpID = model.oldEmpID, EmpNameN = model.EmpNameN, WriteDate = model.OBWriteDate, WriteTime = model.OBWriteTime, WriterID = model.OBWriterID, oldWriteDate = model.oldOBWriteDate, WriterName = model.OBWriterName, FormSeq = model.OBFormSeq, oldFormSeq = model.oldOBFormSeq, FlowCaseID = "", TransactionSeq = "", OBFormStatus = "2", ValidDate = "", ValidID = "", ValidName = "", RejectReasonID = "", RejectReasonCN = "", DeptID = model.OBDeptID, DeptName = model.OBDeptName, OrganID = model.OBOrganID, OrganName = model.OBOrganName, WorkTypeID = model.OBWorkTypeID, WorkType = model.OBWorkType, FlowOrganID = model.OBFlowOrganID, FlowOrganName = model.OBFlowOrganName, TitleID = model.OBTitleID, TitleName = model.OBTitleName, PositionID = model.OBPositionID, Position = model.OBPosition, Tel_1 = model.OBTel_1, Tel_2 = model.OBTel_2, VisitBeginDate = model.OBVisitBeginDate, BeginTime = model.OBBeginTime, VisitEndDate = model.OBVisitEndDate, EndTime = model.OBEndTime, DeputyID = model.OBDeputyID, DeputyName = model.OBDeputyName, LocationType = model.OBLocationType, InterLocationID = model.OBInterLocationID, InterLocationName = model.OBInterLocationName, ExterLocationName = model.OBExterLocationName, VisiterName = model.OBVisiterName, VisiterTel = model.OBVisiterTel, VisitReasonID = model.OBVisitReasonID, VisitReasonCN = model.OBVisitReasonCN, VisitReasonDesc = model.OBVisitReasonDesc, LastChgComp = model.OBLastChgComp, LastChgID = model.OBLastChgID, }; OBFlowUtility.QueryFlowDataAndToUserData_First(dataBean.CompID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.EmpID, dataBean.WriterID, dataBean.VisitBeginDate, out empData, out toUserData, out flowCode, out flowSN, out nextIsLastFlow, out meassge); dataBean.ValidID = toUserData["SignID"].ToString(); dataBean.ValidName = SelectSupervisor(toUserData["SignIDComp"], toUserData["SignID"]); KeyValue = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.WriteDate + "," + dataBean.FormSeq; strarray = (dataBean.EmpID + "," + dataBean.EmpNameN + "," + dataBean.VisitBeginDate + "," + dataBean.BeginTime + "," + dataBean.EndTime).Split(","); ValidUserData = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]); if (FlowExpress.IsFlowInsVerify(flow.FlowID, KeyValue.Split(","), strarray, "btnBefore", ValidUserData, "")) { strFlowCaseID = FlowExpress.getFlowCaseID(flow.FlowID, KeyValue); dataBean.FlowCaseID = strFlowCaseID; switch (regStr) { case "Addes": { SqlCommand.InesrtVisitFormSendSql(dataBean, ref sb); break; } case "Modify": { SqlCommand.UpdateVisitFormSend(dataBean, ref sb); break; } } OBFlowUtility.InsertHROtherFlowLogCommand(strFlowCaseID, "1", strFlowCaseID + "1".PadLeft(5, '0'), "B", dataBean.EmpID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.WriterID, flowCode, flowSN, "1", "1", toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb); sendEMail(dataBean, ref sb); } try { using (var trans = cn.BeginTransaction()) { try { seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), trans); //執行新增,成功筆數回傳,並做Transaction機制 trans.Commit(); //成功Transaction直接Commit } catch (Exception) { trans.Rollback(); //失敗Transaction Rollback FlowExpress.IsFlowRollBack(flow.FlowID, dataBean.FlowCaseID); throw; } } } catch (Exception) { throw; } result = true; } catch (Exception ex) { msg = ex.Message; } return(result); }
/// <summary> /// 審核 /// </summary> private void DoRelease() { DbHelper db = new DbHelper(_attendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); FlowExpress oFlow = new FlowExpress("OnBizReqAppd_ITRD"); string FlowCustDB = oFlow.FlowID; Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(UserInfo.getUserInfo().UserID, UserInfo.getUserInfo().CompID); try { for (int introw = 0; introw < gvCheckVisitForm.Rows.Count; introw++) { CheckBox objchk = (CheckBox)gvCheckVisitForm.Rows[introw].FindControl("chkChoiced"); if (objchk.Checked == true) { RadioButton rdoApp = (RadioButton)gvCheckVisitForm.Rows[introw].FindControl("rbnApproved"); RadioButton rdoRej = (RadioButton)gvCheckVisitForm.Rows[introw].FindControl("rbnReject"); TextBox txtReson = (TextBox)gvCheckVisitForm.Rows[introw].FindControl("txtReson"); string rowCompID = gvCheckVisitForm.DataKeys[introw].Values["CompID"].ToString(); string rowEmpID = gvCheckVisitForm.DataKeys[introw].Values["EmpID"].ToString(); string rowWriteDate = gvCheckVisitForm.DataKeys[introw].Values["WriteDate"].ToString(); string rowFormSeq = gvCheckVisitForm.DataKeys[introw].Values["FormSeq"].ToString(); string rowFlowCaseID = gvCheckVisitForm.DataKeys[introw].Values["FlowCaseID"].ToString(); string rowFlowLogID = gvCheckVisitForm.DataKeys[introw].Values["FlowLogID"].ToString(); string btnAct = ""; string OBFormStatus = ""; string HRLogStatus = ""; if (rdoApp.Checked == true) { btnAct = "btnClose"; OBFormStatus = "3"; HRLogStatus = "2"; } else if (rdoRej.Checked == true) { btnAct = "btnReject"; OBFormStatus = "4"; HRLogStatus = "3"; } OnBizReqAppdOperationSql.UpdateVisitForm(rowCompID, rowEmpID, rowWriteDate, rowFormSeq, OBFormStatus, txtReson.Text.ToString(), ref sb); OnBizReqAppdOperationSql.UpdateHROverTimeLog(rowFlowCaseID, HRLogStatus, ref sb); FlowUtility.ChangeFlowFlag(rowFlowCaseID, "OB01", "0001", UserInfo.getUserInfo().CompID, UserInfo.getUserInfo().UserID, "0", ref sb); //先執行SQL,if(永豐流程成功)則Commit,else則RollBack。 //20170613 leo modify db.ExecuteNonQuery(sb.BuildCommand(), tx); if (FlowExpress.IsFlowVerify(FlowCustDB, rowFlowLogID, btnAct, oAssDic, txtReson.Text.ToString())) { tx.Commit(); Util.MsgBox("審核成功!"); } else { throw new Exception("審核失敗!"); } } } } catch (Exception ex) { tx.Rollback(); Util.MsgBox(ex.Message); } }
private void DoSubmit() { if (Session["FlowVerifyInfo"] != null) { Dictionary <string, string> oVerifyInfo = (Dictionary <string, string>)Session["FlowVerifyInfo"]; Dictionary <string, string> dic = (Dictionary <string, string>)Session["PunchAppdOperation_GridView"]; Dictionary <string, string> toUserData = (Dictionary <string, string>)Session["PunchAppdOperation_toUserData"]; Util.setJSContent(oVerifyInfo["FlowVerifyJS"]); Session["FlowVerifyInfo"] = null; Punch_Confirm_Remedy_Bean model = new Punch_Confirm_Remedy_Bean() { //跟共用條件 CompID = dic["CompID"], EmpID = dic["EmpID"], EmpName = dic["EmpName"], LastChgComp = UserInfo.getUserInfo().CompID.Trim(), LastChgID = UserInfo.getUserInfo().UserID.Trim(), LastChgDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), //預存所需資料 PunchTime = dic["PunchTime"], ConfirmPunchFlag = dic["ConfirmPunchFlag"], DutyTime = dic["DutyTime"], RestBeginTime = dic["RestBeginTime"], RestEndTime = dic["RestEndTime"], //Remedy所需資料 PunchDate = dic["PunchDate"], PunchRemedySeq = dic["PunchRemedySeq"], FlowCaseID = dic["FlowCaseID"], ValidDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), ValidCompID = UserInfo.getUserInfo().CompID.Trim(), ValidID = UserInfo.getUserInfo().UserID.Trim(), ValidName = UserInfo.getUserInfo().UserName.Trim(), //Confirm所需資料 DutyDate = dic["DutyDate"], PunchConfirmSeq = dic["PunchConfirmSeq"], RemedyReasonID = dic["RemedyReasonID"], RemedyReasonCN = dic["RemedyReasonCN"], RemedyPunchTime = dic["RemedyPunchTime"], Remedy_MAFT10_FLAG = dic["Remedy_MAFT10_FLAG"], Remedy_AbnormalFlag = dic["Remedy_AbnormalFlag"], Remedy_AbnormalReasonID = dic["Remedy_AbnormalReasonID"], Remedy_AbnormalReasonCN = dic["Remedy_AbnormalReasonCN"], Remedy_AbnormalDesc = dic["Remedy_AbnormalDesc"] }; switch (oVerifyInfo["FlowStepBtnID"].ToString()) { //PORemedyStatus。0:未處理,1:未送簽,2:送簽中,3:核准,4:駁回 //ConfirmStatus。0:正常,1:異常,2:送簽中,3:異常不控管 case "btnClose": model.PORemedyStatus = "3"; string strConfirmStatus = "", strAbnormalType = ""; if (!PunchUpdate.PunchAppdOperation_EXEC_PunchCheckData(model, out strConfirmStatus, out strAbnormalType)) { Util.MsgBox("打卡異常檢核失敗!!"); return; } model.ConfirmStatus = strConfirmStatus; //0 or 1記得用John的TSQL model.AbnormalType = strAbnormalType; break; case "btnApprove": case "btnReApprove": model.PORemedyStatus = "2"; model.ConfirmStatus = "2"; break; case "btnReject": model.PORemedyStatus = "4"; model.ConfirmStatus = "1"; break; } Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]); DataTable LastHROtherFlowLog = PunchUpdate.HROtherFlowLog(model.FlowCaseID, true); long seccessCount = 0; string msg = ""; bool result = false; result = PunchUpdate.PunchAppdOperation_SaveData(model, oAssDic, oVerifyInfo["FlowStepBtnID"].ToString(), oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), out seccessCount, out msg, LastHROtherFlowLog.Rows[0]["FlowCode"].ToString(), LastHROtherFlowLog.Rows[0]["FlowSN"].ToString(), LastHROtherFlowLog.Rows[0]["FlowSeq"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogBatNo"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogID"].ToString(), toUserData); if (result) { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!"); } else { labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗"); txtErrMsg.Text = msg; txtErrMsg.Visible = true; } } }
private bool boolUpEmpRankID(string AD, string FlowCaseID, string UpEmpRankID) { DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); DataTable dt; string MapEmpRankID, OTEmpID; sb.Append(" SELECT Top 1 isnull(P.CompID,'') as CompID,isnull(P.RankID,'')as RankID FROM " + CustVerify.ADTable(AD) + " OT "); sb.Append(" LEFT JOIN " + _eHRMSDB + ".[dbo].[Personal] P ON OT.OTEmpID=P.EmpID and OT.OTCompID=P.CompID"); sb.Append(" WHERE OT.FlowCaseID='" + FlowCaseID + "' and OTSeqNo='1'"); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; if (dt.Rows.Count == 0) { return(false); } MapEmpRankID = RankIDMapping(UserInfo.getUserInfo().CompID, UpEmpRankID); if (MapEmpRankID == "") { return(false); } OTEmpID = RankIDMapping(dt.Rows[0]["CompID"].ToString(), dt.Rows[0]["RankID"].ToString()); if (OTEmpID == "") { return(false); } return(int.Parse(MapEmpRankID) <= int.Parse(OTEmpID) ? true : false); }
protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow clickedRow = ((ImageButton)e.CommandSource).NamingContainer as GridViewRow; switch (e.CommandName) { case "Detail": string flowCode = "", flowSN = "", msg = "", btnName = ""; Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> toUserData; PunchUpdate.GridViewToDictionary(gvMain, out dic, clickedRow.RowIndex, strDataKeyNames); FlowExpress oFlow = new FlowExpress(FlowCustDB, dic["FlowCaseID"], false); Punch_Confirm_Remedy_Bean model = new Punch_Confirm_Remedy_Bean() { //跟共用條件 CompID = dic["CompID"], EmpID = dic["EmpID"], EmpName = dic["EmpName"], LastChgComp = UserInfo.getUserInfo().CompID.Trim(), LastChgID = UserInfo.getUserInfo().UserID.Trim(), LastChgDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), //預存所需資料 PunchTime = dic["PunchTime"], ConfirmPunchFlag = dic["ConfirmPunchFlag"], DutyTime = dic["DutyTime"], RestBeginTime = dic["RestBeginTime"], RestEndTime = dic["RestEndTime"], //Remedy所需資料 PunchDate = dic["PunchDate"], PunchRemedySeq = dic["PunchRemedySeq"], FlowCaseID = dic["FlowCaseID"], ValidDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), ValidCompID = UserInfo.getUserInfo().CompID.Trim(), ValidID = UserInfo.getUserInfo().UserID.Trim(), ValidName = UserInfo.getUserInfo().UserName.Trim(), //Confirm所需資料 DutyDate = dic["DutyDate"], PunchConfirmSeq = dic["PunchConfirmSeq"], RemedyReasonID = dic["RemedyReasonID"], RemedyReasonCN = dic["RemedyReasonCN"], RemedyPunchTime = dic["RemedyPunchTime"], Remedy_MAFT10_FLAG = dic["Remedy_MAFT10_FLAG"], Remedy_AbnormalFlag = dic["Remedy_AbnormalFlag"], Remedy_AbnormalReasonID = dic["Remedy_AbnormalReasonID"], Remedy_AbnormalReasonCN = dic["Remedy_AbnormalReasonCN"], Remedy_AbnormalDesc = dic["Remedy_AbnormalDesc"] }; //按鈕清單 ClearBtn(model.FlowCaseID); //下一關邏輯判斷,產生審核按鈕資訊,給出Ken流程相關資訊 if (!nextFlowBtn(model, out flowCode, out flowSN, ref btnName, out toUserData, out msg)) //判斷審核按鈕 { Util.MsgBox(msg); return; } CustVerify.setFlowSignID_CompID(toUserData["SignID"].ToString() + "," + toUserData["SignIDComp"].ToString()); //傳給審核畫面-單筆審核使用 Session["PunchAppdOperation_toUserData"] = toUserData; Session["PunchAppdOperation_GridView"] = dic; //產生審核按鈕 FlowExpress.getFlowTodoList(FlowExpress.TodoListAssignKind.All, model.ValidID.Trim(), FlowCustDB.Split(','), "".Split(','), false, "", ""); //跳轉畫面 Response.Redirect(string.Format(FlowExpress._FlowPageVerifyURL + "?FlowID={0}&FlowLogID={1}&ProxyType={2}&IsShowBtnComplete={3}&IsShowCheckBoxList={4}&ChkMaxKeyLen={5}", oFlow.FlowID, oFlow.FlowCurrLastLogID, "Self", "N", "N", "")); break; } }
private void SaveData() { string ErrorIndex = ""; for (int index = 0; index < gvMain.Rows.Count; index++) { CheckBox objchk = (CheckBox)gvMain.Rows[index].FindControl("chkChoiced"); if (objchk.Checked == true) { bool result = false; long seccessCount = 0; string msg = "", flowCode = "", flowSN = ""; string btnName = ""; RadioButton rdoApp = (RadioButton)gvMain.Rows[index].FindControl("rbnApproved"); RadioButton rdoRej = (RadioButton)gvMain.Rows[index].FindControl("rbnReject"); TextBox txtReason = (TextBox)gvMain.Rows[index].FindControl("txtReason"); Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> toUserData = new Dictionary <string, string>(); PunchUpdate.GridViewToDictionary(gvMain, out dic, index, strDataKeyNames); Punch_Confirm_Remedy_Bean model = new Punch_Confirm_Remedy_Bean() { //跟共用條件 CompID = dic["CompID"], EmpID = dic["EmpID"], EmpName = dic["EmpName"], LastChgComp = UserInfo.getUserInfo().CompID.Trim(), LastChgID = UserInfo.getUserInfo().UserID.Trim(), LastChgDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), //預存所需資料 PunchTime = dic["PunchTime"], ConfirmPunchFlag = dic["ConfirmPunchFlag"], DutyTime = dic["DutyTime"], RestBeginTime = dic["RestBeginTime"], RestEndTime = dic["RestEndTime"], //Remedy所需資料 PunchDate = dic["PunchDate"], PunchRemedySeq = dic["PunchRemedySeq"], FlowCaseID = dic["FlowCaseID"], ValidDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), ValidCompID = UserInfo.getUserInfo().CompID.Trim(), ValidID = UserInfo.getUserInfo().UserID.Trim(), ValidName = UserInfo.getUserInfo().UserName.Trim(), //Confirm所需資料 DutyDate = dic["DutyDate"], PunchConfirmSeq = dic["PunchConfirmSeq"], RemedyReasonID = dic["RemedyReasonID"], RemedyReasonCN = dic["RemedyReasonCN"], RemedyPunchTime = dic["RemedyPunchTime"], Remedy_MAFT10_FLAG = dic["Remedy_MAFT10_FLAG"], Remedy_AbnormalFlag = dic["Remedy_AbnormalFlag"], Remedy_AbnormalReasonID = dic["Remedy_AbnormalReasonID"], Remedy_AbnormalReasonCN = dic["Remedy_AbnormalReasonCN"], Remedy_AbnormalDesc = dic["Remedy_AbnormalDesc"] }; if (rdoApp.Checked == true) //核准 { if (!nextFlowBtn(model, out flowCode, out flowSN, ref btnName, out toUserData, out msg)) //判斷審核按鈕 { Util.MsgBox(msg); return; } switch (btnName) { //PORemedyStatus。0:未處理,1:未送簽,2:送簽中,3:核准,4:駁回 //ConfirmStatus。0:正常,1:異常,2:送簽中,3:異常不控管 case "btnClose": model.PORemedyStatus = "3"; string strConfirmStatus = "", strAbnormalType = ""; if (!PunchUpdate.PunchAppdOperation_EXEC_PunchCheckData(model, out strConfirmStatus, out strAbnormalType)) { Util.MsgBox("打卡異常檢核失敗!!"); return; } model.ConfirmStatus = strConfirmStatus; //0 or 1記得用John的TSQL model.AbnormalType = strAbnormalType; break; case "btnApprove": case "btnReApprove": model.PORemedyStatus = "2"; model.ConfirmStatus = "2"; break; } } else if (rdoRej.Checked == true)//駁回 { btnName = "btnReject"; model.PORemedyStatus = "4"; model.ConfirmStatus = "1"; } DataTable LastHROtherFlowLog = PunchUpdate.HROtherFlowLog(model.FlowCaseID, true); Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]); if (!string.IsNullOrEmpty(btnName)) { //審核動作 result = PunchUpdate.PunchAppdOperation_SaveData(model, oAssDic, btnName, txtReason.Text, out seccessCount, out msg, flowCode, flowSN, LastHROtherFlowLog.Rows[0]["FlowSeq"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogBatNo"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogID"].ToString(), toUserData); } else { result = false; } if (!result) { //Util.MsgBox(msg); ErrorIndex += (index + 1).ToString() + ","; continue; } if (seccessCount == 0) { ErrorIndex += (index + 1).ToString() + ","; continue; } } } if (ErrorIndex.Length > 0) { ErrorIndex = ErrorIndex.Substring(0, ErrorIndex.Length - 1); Util.MsgBox("第" + ErrorIndex + "筆審核失敗"); } else { Util.MsgBox("審核成功"); } }
public static bool PunchAppdOperation_SaveData(Punch_Confirm_Remedy_Bean model, Dictionary <string, string> oAssDic, string btnName, string FlowStepOpinion, out long seccessCount, out string msg, string flowCode = "", string flowSN = "", string flowSeq = "", string FlowLogBatNo = "", string FlowLogID = "", Dictionary <string, string> toUserData = null) { seccessCount = 0; msg = ""; Punch_Confirm_Remedy_Bean datas = new Punch_Confirm_Remedy_Bean(); try { FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_PunchUpdate/"), model.FlowCaseID, false); string strFlowLogID = flow.FlowCurrLastLogID; //string strFlowLogID=PunchUpdate.getFlowLogID(Util.getAppSetting("app://AattendantDB_PunchUpdate/"), model.FlowCaseID); //FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_PunchUpdate/"), model.FlowCaseID); //FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_PunchUpdate/"), strFlowLogID); DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); Punch_Confirm_Remedy_Bean dataBean = new Punch_Confirm_Remedy_Bean() { FlowCaseID = model.FlowCaseID, CompID = model.CompID, EmpID = model.EmpID, EmpName = model.EmpName, DutyDate = model.DutyDate, DutyTime = model.DutyTime, PunchDate = model.PunchDate, PunchTime = model.PunchTime, PunchConfirmSeq = model.PunchConfirmSeq, DeptID = model.DeptID, DeptName = model.DeptName, OrganID = model.OrganID, OrganName = model.OrganName, FlowOrganID = model.FlowOrganID, FlowOrganName = model.FlowOrganName, ConfirmStatus = model.ConfirmStatus, PunchRemedySeq = model.PunchRemedySeq, RemedyReasonID = model.RemedyReasonID, RemedyReasonCN = model.RemedyReasonCN, RemedyPunchTime = model.RemedyPunchTime, AbnormalFlag = model.AbnormalFlag, AbnormalReasonID = model.AbnormalReasonID, AbnormalReasonCN = model.AbnormalReasonCN, AbnormalDesc = model.AbnormalDesc, Remedy_MAFT10_FLAG = model.Remedy_MAFT10_FLAG, Remedy_AbnormalFlag = model.Remedy_AbnormalFlag, Remedy_AbnormalReasonID = model.Remedy_AbnormalReasonID, Remedy_AbnormalReasonCN = model.Remedy_AbnormalReasonCN, Remedy_AbnormalDesc = model.Remedy_AbnormalDesc, LastChgComp = model.LastChgComp, LastChgID = model.LastChgID, LastChgDate = model.LastChgDate, //Remedy RemedyPunchFlag = model.RemedyPunchFlag, BatchFlag = model.BatchFlag, PORemedyStatus = model.PORemedyStatus, RejectReason = model.RejectReason, RejectReasonCN = model.RejectReasonCN, ValidDateTime = model.ValidDateTime, ValidCompID = model.ValidCompID, ValidID = model.ValidID, ValidName = model.ValidName }; try { SqlCommand.PunchAppdOperation_UpdatePunchRemedyLog(dataBean, ref sb); SqlCommand.PunchAppdOperation_UpdatePunchConfirm(dataBean, ref sb); //內部判定結案or駁回 SqlCommand.PunchAppdOperation_UpdateHROtherFlowLog(dataBean.FlowCaseID, dataBean.ConfirmStatus == "4" ? "3" : "2", ref sb); if (dataBean.PORemedyStatus == "2")//沒結案(送簽中) { OBFlowUtility.InsertHROtherFlowLogCommand(dataBean.FlowCaseID, CustVerify.addone(FlowLogBatNo), CustVerify.FlowLogIDadd(FlowLogID), "P", dataBean.EmpID, dataBean.OrganID, dataBean.FlowOrganID, UserInfo.getUserInfo().UserID, flowCode, flowSN, CustVerify.addone(flowSeq), toUserData["SignLine"], toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb); } else if (dataBean.PORemedyStatus == "3" || dataBean.PORemedyStatus == "4")//結案 { FlowUtility.ChangeFlowFlag(dataBean.FlowCaseID, flowCode, flowSN, UserInfo.getUserInfo().CompID, UserInfo.getUserInfo().UserID, "0", ref sb); } //======(test錯誤的存在)======= //sb.Append("test錯誤的存在"); msg = "注定失敗"; return(false); //======(test錯誤的存在)======= seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), tx); //執行新增,成功筆數回傳,並做Transaction機制 if (seccessCount > 0) { if (FlowExpress.IsFlowVerify(flow.FlowID, flow.FlowCurrLastLogID, btnName, oAssDic, FlowStepOpinion)) { tx.Commit(); //成功Transaction直接Commit } else { tx.Rollback(); //失敗Transaction Rollback msg = "永豐流程寫入失敗"; } } else { tx.Rollback(); //失敗Transaction Rollback msg = "審核失敗,更新0筆資料"; } } catch (Exception ex) { tx.Rollback(); //失敗Transaction Rollback msg = ex.Message; throw ex; } } catch (Exception ex) { //tx.Rollback(); //失敗Transaction Rollback msg = ex.Message; return(false); } return(true); }
/// <summary> /// 申請後送簽流程 /// </summary> /// <param name="model">畫面model</param> /// <param name="datas">回傳資料</param> /// <param name="msg">回傳訊息</param> /// <returns>bool</returns> public static bool PunchUpdateModify_SaveData(Punch_Confirm_Remedy_Bean model, out long seccessCount, out string msg) { bool result = false; seccessCount = 0; msg = ""; bool validResult = false; Punch_Confirm_Remedy_Bean datas = new Punch_Confirm_Remedy_Bean(); string validMsg = ""; try { Dictionary <string, string> empData = new Dictionary <string, string>(); Dictionary <string, string> toUserData = new Dictionary <string, string>(); Dictionary <string, string> ValidUserData = new Dictionary <string, string>(); string flowCode = ""; string flowSN = ""; bool nextIsLastFlow = false; string meassge = ""; FlowExpress flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_PunchUpdate/")); string KeyValue = "";//字串 string ShowValue = ""; string strFlowCaseID = ""; DbHelper db = new DbHelper(Aattendant._AattendantDBName); CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); Punch_Confirm_Remedy_Bean dataBean = new Punch_Confirm_Remedy_Bean() { FlowCaseID = model.FlowCaseID, CompID = model.CompID, EmpID = model.EmpID, EmpName = model.EmpName, DutyDate = model.DutyDate, DutyTime = model.DutyTime, PunchDate = model.PunchDate, PunchTime = model.PunchTime, PunchConfirmSeq = model.PunchConfirmSeq, DeptID = model.DeptID, DeptName = model.DeptName, OrganID = model.OrganID, OrganName = model.OrganName, FlowOrganID = model.FlowOrganID, FlowOrganName = model.FlowOrganName, MAFT10_FLAG = model.MAFT10_FLAG, ConfirmStatus = model.ConfirmStatus, PunchRemedySeq = model.PunchRemedySeq, RemedyReasonID = model.RemedyReasonID, RemedyReasonCN = model.RemedyReasonCN, RemedyPunchTime = model.RemedyPunchTime, AbnormalFlag = model.AbnormalFlag, AbnormalReasonID = model.AbnormalReasonID, AbnormalReasonCN = model.AbnormalReasonCN, AbnormalDesc = model.AbnormalDesc, Remedy_MAFT10_FLAG = model.Remedy_MAFT10_FLAG, Remedy_AbnormalFlag = model.Remedy_AbnormalFlag, Remedy_AbnormalReasonID = model.Remedy_AbnormalReasonID, Remedy_AbnormalReasonCN = model.Remedy_AbnormalReasonCN, Remedy_AbnormalDesc = model.Remedy_AbnormalReasonID == "99" ? model.Remedy_AbnormalDesc : "", LastChgComp = model.LastChgComp, LastChgID = model.LastChgID, LastChgDate = model.LastChgDate, //Remedy RemedyPunchFlag = model.RemedyPunchFlag, BatchFlag = model.BatchFlag, PORemedyStatus = model.PORemedyStatus, RejectReason = model.RejectReason, RejectReasonCN = model.RejectReasonCN, ValidDateTime = model.ValidDateTime, //ValidTime = model.ValidTime, ValidCompID = model.ValidCompID, ValidID = model.ValidID, ValidName = model.ValidName }; OBFlowUtility.QueryFlowDataAndToUserData_First(dataBean.CompID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.EmpID, dataBean.EmpID, dataBean.PunchDate, out empData, out toUserData, out flowCode, out flowSN, out nextIsLastFlow, out meassge, "PO01", "PO"); Punch_Confirm_Remedy_Model validInfo = new Punch_Confirm_Remedy_Model() { CompID = toUserData["SignIDComp"], EmpID = toUserData["SignID"] }; validResult = GetValidInfo(validInfo, out datas, out validMsg); if (!validResult) { throw new Exception(validMsg); } dataBean.ValidCompID = toUserData["SignIDComp"]; dataBean.ValidID = toUserData["SignID"]; dataBean.ValidName = datas.ValidName; KeyValue = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.PunchDate + "," + dataBean.PunchRemedySeq; ShowValue = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.PunchDate + "," + dataBean.PunchTime; ValidUserData = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]); if (FlowExpress.IsFlowInsVerify(flow.FlowID, KeyValue.Split(","), ShowValue.Split(","), nextIsLastFlow ? "btnSendLast" : "btnSend", ValidUserData, "")) { strFlowCaseID = FlowExpress.getFlowCaseID(flow.FlowID, KeyValue); dataBean.FlowCaseID = strFlowCaseID; SqlCommand.PunchUpdateModify_InsertPunchRemedyLog(dataBean, ref sb); OBFlowUtility.ChangeFlowFlag(strFlowCaseID, flowCode, flowSN, dataBean.ValidCompID, dataBean.ValidID, "1", ref sb); OBFlowUtility.InsertHROtherFlowLogCommand(strFlowCaseID, "1", strFlowCaseID + "." + "1".PadLeft(5, '0'), "P", dataBean.EmpID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.ValidID, flowCode, flowSN, "1", "1", toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb); try { //================ //sb.Append("錯誤製造"); //================= seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), tx); //執行新增,成功筆數回傳,並做Transaction機制 tx.Commit(); //成功Transaction直接Commit } catch (Exception) { FlowExpress.IsFlowCaseDeleted(flow.FlowID, strFlowCaseID, true); //送簽用IsFlowCaseDeleted //審核用IsFlowRollBack tx.Rollback(); //失敗Transaction Rollback throw; } result = true; } } catch (Exception ex) { msg = ex.Message; } return(result); }