/// <summary> /// 確認刪除主檔(自動刪除相關明細檔) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMainDelete_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Delete PO Where POID = ").AppendParameter("POID", _MainID); sb.AppendStatement("Delete PODetail Where POID = ").AppendParameter("POID", _MainID); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); _MainID = ""; _DetailSeq = -1; Refresh(true, true); Util.NotifyMsg("主檔及相關明細檔刪除成功", Util.NotifyKind.Success); } catch { tx.Rollback(); Util.NotifyMsg("主檔及相關明細檔刪除失敗", Util.NotifyKind.Error); } finally { cn.Close(); cn.Dispose(); tx.Dispose(); } }
/// <summary> /// 新增附件 /// </summary> /// <param name="AttachID"></param> /// <param name="attach"></param> /// <returns></returns> public bool InsertAttach(string AttachID, string attach) { bool isSuccess = false; try { DbHelper db = new DbHelper(_overtimeDBName); CommandHelper strSQL = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); strSQL.Reset(); strSQL.AppendStatement(" UPDATE AttachInfo SET FileSize = -1, FileBody = null WHERE AttachID = '" + AttachID + "'"); strSQL.AppendStatement(" INSERT INTO AttachInfo (AttachID, SeqNo, FileName, FileExtName, FileSize, AnonymousAccess, UpdUser, UpdDate, UpdTime, FileBody, MD5Check) "); strSQL.Append(" SELECT '" + AttachID + "'"); strSQL.Append(" , SeqNo, FileName, FileExtName, FileSize, AnonymousAccess, UpdUser, UpdDate, UpdTime, FileBody, MD5Check "); strSQL.Append(" FROM AttachInfo "); strSQL.Append(" WHERE AttachID = '" + attach + "'"); using (DataTable dtSchedule = db.ExecuteDataSet(strSQL.BuildCommand()).Tables[0]) { db.ExecuteNonQuery(strSQL.BuildCommand(), tx); tx.Commit(); } } catch (Exception ex) { Debug.Print(">>>InsertAttach: " + ex.Message); LogHelper.WriteSysLog(ex); //將 Exception 丟給 Log 模組 } return(isSuccess); }
protected void btnMainDelete_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); try { Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("AreaID", _AreaID); AclExpress.IsAclTableLog("AclAdminRuleArea", dicKey, LogHelper.AppTableLogType.Delete); AclExpress.IsAclTableLog("AclAdminRuleAreaGrantList", dicKey, LogHelper.AppTableLogType.Delete); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Delete AclAdminRuleAreaGrantList Where RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); sb.AppendStatement("Delete AclAdminRuleArea Where RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg("刪除成功", Util.NotifyKind.Success); _RuleID = ""; _AreaID = ""; _GrantID = ""; Refresh(true, true); } catch { throw; } }
protected void btnMainInsert_Click(object sender, EventArgs e) { //取得表單輸入資料 Dictionary <string, string> oDic = Util.getControlEditResult(fmMain); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Insert AclRule "); sb.Append("( "); sb.Append(" RuleID,RuleName,IsEnabled,Remark,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("RuleID", oDic["RuleID"]); sb.Append(" ,").AppendParameter("RuleName", oDic["RuleName"]); sb.Append(" ,").AppendParameter("IsEnabled", oDic["IsEnabled"]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); if (_IsADD && _RuleID != oDic["RuleID"]) { //Copy Detail sb.AppendStatement(Util.getDataCopySQL(AclExpress._AclDBName, _Main_KeyList, _RuleID.Split(','), oDic["RuleID"].Split(','), "AclRuleExp".Split(','))); } try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { _IsADD = false; _RuleID = oDic["RuleID"]; Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); AclExpress.IsAclTableLog("AclRule", dicKey, LogHelper.AppTableLogType.Create); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg(string.Format("[{0}]新增成功,可進行後續編修。", oDic["RuleID"]), Util.NotifyKind.Success); Refresh(true, true); } else { Util.NotifyMsg("新增失敗", Util.NotifyKind.Error); } } catch { Util.NotifyMsg("新增錯誤,請檢查資料是否重複", Util.NotifyKind.Error); } }
/// <summary> /// 確認新增明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailInsert_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); if (!string.IsNullOrEmpty(_MainID)) { //取出目前 PODetail最後一筆的 POSeq 備用(若無資料會傳回 -1) int intLastPOSeq = Util.getLastKeySeqNo(_DBName, "PODetail", "POID,POSeq".Split(','), _MainID.Split(',')); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //新增明細 sb.AppendStatement("Insert PODetail "); sb.Append("(POID,POSeq,ItemDesc,ItemExpDate,Unit,UnitPrice,Qty,Subtotal) "); sb.Append(" Values (").AppendParameter("POID", _MainID); sb.Append(" ,").AppendParameter("POSeq", (intLastPOSeq >= 0) ? intLastPOSeq + 1 : 1); sb.Append(" ,").AppendParameter("ItemDesc", oDic["ItemDesc"]); sb.Append(" ,").AppendParameter("ItemExpDate", oDic["ItemExpDate"]); sb.Append(" ,").AppendParameter("Unit", oDic["Unit"]); sb.Append(" ,").AppendParameter("UnitPrice", oDic["UnitPrice"]); sb.Append(" ,").AppendParameter("Qty", oDic["Qty"]); sb.Append(" ,").AppendParameter("Subtotal", int.Parse(oDic["UnitPrice"]) * int.Parse(oDic["Qty"])); sb.Append(")"); //重新計算加總值 sb.AppendStatement(string.Format(_ReCal_BaseUpdSQL, _MainID)); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); _DetailSeq = (intLastPOSeq >= 0) ? intLastPOSeq + 1 : 1; Util.NotifyMsg("明細新增成功", Util.NotifyKind.Success); Refresh(false, true); } catch { tx.Rollback(); Util.NotifyMsg("明細新增失敗", Util.NotifyKind.Error); } finally { cn.Close(); cn.Dispose(); tx.Dispose(); } } }
/// <summary> /// 明細整批刪除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailBatchDelete_Click(object sender, EventArgs e) { string[] CheckedKeyList = ucGridDetail1.ucCheckedKeyList; if (CheckedKeyList.Count() < 1) { Util.NotifyMsg(RS.Resources.Msg_NoDataToModify); } else { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); string[] oKey; sb.Reset(); //批次明細刪除(SQL Parameter名稱需 Unique) for (int i = 0; i < CheckedKeyList.Count(); i++) { oKey = CheckedKeyList[i].Split(','); sb.AppendStatement("Delete PODetail Where 0=0 "); sb.Append(" And POID =").AppendParameter("POID" + i, oKey[0]); sb.Append(" And POSeq =").AppendParameter("POSeq" + i, oKey[1]); } //重新計算加總值 sb.AppendStatement(string.Format(_ReCal_BaseUpdSQL, _MainID)); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); _DetailSeq = -1; Util.NotifyMsg("[選取項目]刪除成功", Util.NotifyKind.Success); } catch { tx.Rollback(); Util.NotifyMsg("[選取項目]刪除失敗", Util.NotifyKind.Error); } finally { cn.Close(); cn.Dispose(); tx.Dispose(); } } fmMainRefresh(); Refresh(true, true); }
/// <summary> /// 公司班表 /// </summary> /// <param name="compID">公司別</param> /// <param name="empID">員工編號</param> /// <param name="errMsg">錯誤訊息</param> /// <param name="schedule">班表</param> /// <returns>bool</returns> /// <remarks>目前不曉得該怎取得過去日期的班表,日後可能需要再修改</remarks> private bool GetCompSchedule(string compID, string empID, out StringBuilder errMsg, out DataTable schedule) { errMsg = new StringBuilder(); schedule = new DataTable(); try { DbHelper db = new DbHelper(_eHRMSDB); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("SELECT"); sb.Append(" WT.BeginTime, WT.EndTime, WT.RestBeginTime, WT.RestEndTime "); sb.Append(" FROM PersonalOther PO "); sb.Append(" LEFT JOIN WorkTime WT ON WT.CompID = PO.CompID AND WT.WTID = PO.WTID "); sb.Append(" WHERE 0 = 0 "); sb.Append(" AND PO.CompID = '" + compID + "' "); sb.Append(" AND PO.EmpID = '" + empID + "' "); sb.Append(" ; "); using (DataTable dtSchedule = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]) { schedule = dtSchedule; return(dtSchedule.Rows.Count > 0 ? true : false); } } catch (Exception ex) { Debug.Print(">>>GetCompSchedule: " + ex.Message); LogHelper.WriteSysLog(ex); //將 Exception 丟給 Log 模組 errMsg.AppendLine(ex.Message); schedule = null; return(false); } }
/// <summary> /// 取得個人班表 /// </summary> /// <param name="compID">公司別</param> /// <param name="empID">員工編號</param> /// <param name="SBStartDate">留守起日</param> /// <param name="SBEndDate">留守迄日</param> /// <param name="errMsg">錯誤訊息</param> /// <param name="schedule">班表</param> /// <remarks>StartDate:生效日</remarks> /// <returns>bool</returns> private bool GetPersonalSchedule(string compID, string empID, string SBStartDate, string SBEndDate, out StringBuilder errMsg, out DataTable schedule) { errMsg = new StringBuilder(); schedule = new DataTable(); try { DbHelper db = new DbHelper(_overtimeDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(" SELECT TOP 1 WT.BeginTime, WT.EndTime FROM EmpWorkTimeLog EL "); sb.Append(" LEFT JOIN [" + _eHRMSDB + "].[dbo].[WorkTime] WT ON WT.CompID = EL.CompID AND WT.WTID = EL.WTID "); sb.Append(" WHERE 1 = 1 "); sb.Append(" AND EL.CompID = '" + compID + "' "); sb.Append(" AND EL.EmpID = '" + empID + "' "); sb.Append(" AND CONVERT(VARCHAR, EL.StartDate, 111) <= '" + SBStartDate + "' "); sb.Append(" AND EL.LastChgDate = ( "); sb.Append(" SELECT TOP 1 LastChgDate FROM EmpWorkTimeLog WHERE 1 = 1 "); sb.Append(" AND CONVERT(VARCHAR, StartDate, 111) <= '" + SBStartDate + "' "); sb.Append(" AND ActionFlag <> 'D' "); sb.Append(" AND CompID = '" + compID + "' "); sb.Append(" AND EmpID = '" + empID + "' "); sb.Append(" ORDER BY StartDate DESC, LastChgDate DESC) "); //留守起迄日不同天需再取得迄日的班表 if (!SBStartDate.Equals(SBEndDate)) { sb.Append(" UNION ALL "); sb.Append(" SELECT TOP 1 WT.BeginTime, WT.EndTime FROM EmpWorkTimeLog EL "); sb.Append(" LEFT JOIN [" + _eHRMSDB + "].[dbo].[WorkTime] WT ON WT.CompID = EL.CompID AND WT.WTID = EL.WTID "); sb.Append(" WHERE 1 = 1 "); sb.Append(" AND EL.CompID = '" + compID + "' "); sb.Append(" AND EL.EmpID = '" + empID + "' "); sb.Append(" AND CONVERT(VARCHAR, EL.StartDate, 111) <= '" + SBEndDate + "' "); sb.Append(" AND EL.LastChgDate = ( "); sb.Append(" SELECT TOP 1 LastChgDate FROM EmpWorkTimeLog WHERE 1 = 1 "); sb.Append(" AND CONVERT(VARCHAR, StartDate, 111) <= '" + SBEndDate + "' "); sb.Append(" AND ActionFlag <> 'D' "); sb.Append(" AND CompID = '" + compID + "' "); sb.Append(" AND EmpID = '" + empID + "' "); sb.Append(" ORDER BY StartDate DESC, LastChgDate DESC) "); } using (DataTable dtSchedule = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]) { schedule = dtSchedule; return(dtSchedule.Rows.Count > 0 ? true : false); } } catch (Exception ex) { Debug.Print(">>>GetPersonalSchedule: " + ex.Message); LogHelper.WriteSysLog(ex); //將 Exception 丟給 Log 模組 errMsg.AppendLine(ex.Message); schedule = null; return(false); } }
/// <summary> /// 值勤班表 /// </summary> /// <param name="compID">公司別</param> /// <param name="empID">員工編號</param> /// <param name="SBStartDate">留守起日</param> /// <param name="SBEndDate">留守迄日</param> /// <param name="errMsg">錯誤訊息</param> /// <param name="schedule">班表</param> /// <returns></returns> private bool GetDutySchedule(string compID, string empID, string SBStartDate, string SBEndDate, out StringBuilder errMsg, out DataTable schedule) { errMsg = new StringBuilder(); schedule = new DataTable(); try { DbHelper db = new DbHelper(_overtimeDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("SELECT"); sb.Append(" WTBeginTime AS BeginTime, WTEndTime AS EndTime "); sb.Append(" FROM EmpGuardWorkTime "); sb.Append(" WHERE 0 = 0 "); sb.Append(" AND CompID = '" + compID + "' "); sb.Append(" AND EmpID = '" + empID + "' "); sb.Append(" AND DutyDate BETWEEN '" + SBStartDate + "' AND '" + SBEndDate + "' "); using (DataTable dtSchedule = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]) { schedule = dtSchedule; return(dtSchedule.Rows.Count > 0 ? true : false); } } catch (Exception ex) { Debug.Print(">>>GetDutySchedule: " + ex.Message); LogHelper.WriteSysLog(ex); //將 Exception 丟給 Log 模組 errMsg.AppendLine(ex.Message); schedule = null; return(false); } }
protected void fmMainRefresh() { DbHelper db = new DbHelper(LegalSample._LegalSysDBName); DataTable dt = null; CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(string.Format("Select * From {0} Where CaseNo = ", LegalSample._LegalConsultCaseTableName)).AppendParameter("CaseNo", _CurrCaseNo).Append(" and CaseStatus <> 'Draft' "); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; if (dt != null && dt.Rows.Count > 0) { //DataRow dr = dt.Rows[0]; if (string.IsNullOrEmpty(_CurrFlowID) && string.IsNullOrEmpty(_CurrFlowLogID)) { fmMain.ChangeMode(FormViewMode.ReadOnly); } else { fmMain.ChangeMode(FormViewMode.Edit); } fmMain.DataSource = dt; fmMain.DataBind(); } else { fmMain.Visible = false; labMsg.Visible = true; labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.ParaError, string.Format(RS.Resources.Msg_DataNotFound1, _CurrCaseNo) + "<br><br>"); return; } }
public static void PunchAppdOperation_UpdatePunchRemedyLog(Punch_Confirm_Remedy_Bean model, ref CommandHelper sb, bool isReset = false) { string UpdatePunchRemedyLog_ = "UpdatePunchRemedyLog_"; if (isReset) { sb.Reset(); } sb.AppendStatement(" Update PunchRemedyLog set "); //下一關審核主管 sb.Append(" ValidDateTime=").AppendParameter(UpdatePunchRemedyLog_ + "ValidDateTime", model.ValidDateTime).Append(","); sb.Append(" ValidCompID=").AppendParameter(UpdatePunchRemedyLog_ + "ValidCompID", model.ValidCompID).Append(","); sb.Append(" ValidID=").AppendParameter(UpdatePunchRemedyLog_ + "ValidID", model.ValidID).Append(","); sb.Append(" ValidName=").AppendParameter(UpdatePunchRemedyLog_ + "ValidName", model.ValidName).Append(","); sb.Append(" PORemedyStatus=").AppendParameter(UpdatePunchRemedyLog_ + "PORemedyStatus", model.PORemedyStatus).Append(","); //LastChange sb.Append(" LastChgComp=").AppendParameter(UpdatePunchRemedyLog_ + "LastChgComp", model.LastChgComp).Append(","); sb.Append(" LastChgID=").AppendParameter(UpdatePunchRemedyLog_ + "LastChgID", model.LastChgID).Append(","); sb.Append(" LastChgDate=").AppendParameter(UpdatePunchRemedyLog_ + "LastChgDate", model.LastChgDate); //Where sb.Append(" where "); sb.Append(" CompID=").AppendParameter(UpdatePunchRemedyLog_ + "CompID", model.CompID); sb.Append(" and EmpID=").AppendParameter(UpdatePunchRemedyLog_ + "EmpID", model.EmpID); sb.Append(" and PunchDate=").AppendParameter(UpdatePunchRemedyLog_ + "PunchDate", model.PunchDate); sb.Append(" and PunchRemedySeq=").AppendParameter(UpdatePunchRemedyLog_ + "PunchRemedySeq", model.PunchRemedySeq); }
protected void DeleteDocKind(string strKindNo) { if (string.IsNullOrEmpty(strKindNo)) { Util.MsgBox(Util.getHtmlMessage(Util.HtmlMessageKind.ParaDataError)); return; } else { try { //相關連的子類別會由 LegalDocKind 的 Trigger 自動遞迴刪除 DbHelper db = new DbHelper(LegalSample._LegalSysDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Delete LegalDocKind Where KindNo = ").AppendParameter("KindNo", strKindNo); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch (Exception ex) { Util.MsgBox(Util.getHtmlMessage(Util.HtmlMessageKind.Error, ex.ToString())); } } }
protected void fmMainRefresh() { DbHelper db = new DbHelper(_DBName); DataTable dt = null; if (!string.IsNullOrEmpty(_RuleID)) { CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Select * From AclAdminRuleArea Where RuleID = ").AppendParameter("RuleID", _RuleID); sb.Append(" and AreaID = ").AppendParameter("AreaID", _AreaID); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; } if (_IsADD) { // Add,Copy fmMain.ChangeMode(FormViewMode.Insert); fmMain.DataSource = dt; fmMain.DataBind(); } else { //Edit fmMain.ChangeMode(FormViewMode.Edit); fmMain.DataSource = dt; fmMain.DataBind(); } Util.setJS_AlertDirtyData(fmMain); }
protected void fmMainRefresh() { if (string.IsNullOrEmpty(_MainID)) { if (_IsADD) { //新增訂單模式 fmMain.ChangeMode(FormViewMode.Insert); //設定唯讀欄位 Util.setReadOnly("txtCompID", true); Util.setReadOnly("txtDeptID", true); Util.setReadOnly("txtUserID", true); Util.setReadOnly("txtCompName", true); Util.setReadOnly("txtDeptName", true); Util.setReadOnly("txtUserName", true); fmMain.DataSource = null; fmMain.DataBind(); } } else { //顯示既有訂單 DbHelper db = new DbHelper(_DBName); DataTable dt = null; CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Select * From PO Where POID = ").AppendParameter("POID", _MainID); dt = db.ExecuteDataSet(sb.BuildCommand()).Tables[0]; fmMain.ChangeMode(FormViewMode.Edit); fmMain.DataSource = dt; fmMain.DataBind(); } Util.setJS_AlertDirtyData(fmMain); }
public static void UpdateHROverTimeLog(string FlowCaseID, string FlowStatus, ref CommandHelper sb) { string SQL = @" UPDATE HROtherFlowLog SET FlowStatus = '{0}' WHERE FlowCaseID = '{1}' AND Seq = (SELECT TOP 1 Seq FROM HROtherFlowLog WHERE FlowCaseID = '{1}' ORDER BY Seq DESC) ;"; sb.AppendStatement(string.Format(SQL, FlowStatus, FlowCaseID)); }
//確定更新 protected void btnUpdate_Click(object sender, EventArgs e) { string strCaseNo = ((TextBox)Util.FindControlEx(fmMain, "txtCaseNo")).Text; string strIsUrgent = ((CheckBox)Util.FindControlEx(fmMain, "chkIsUrgent")).Checked ? "Y" : "N"; string strSubject = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucSubject")).ucTextData; string strOutlined = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucOutlined")).ucTextData; string strPropOpinion = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucPropOpinion")).ucTextData; string strExpectCloseDate = ((Util_ucDatePicker)Util.FindControlEx(fmMain, "ucExpectCloseDate")).ucSelectedDate; DbHelper db = new DbHelper(LegalSample._LegalSysDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(string.Format("Update {0} Set ", LegalSample._LegalConsultCaseTableName)); sb.Append(" IsUrgent = ").AppendParameter("IsUrgent", strIsUrgent); sb.Append(", Subject = ").AppendParameter("Subject", strSubject); sb.Append(", Outlined = ").AppendParameter("Outlined", strOutlined); sb.Append(", PropOpinion = ").AppendParameter("PropOpinion", strPropOpinion); if (!string.IsNullOrEmpty(strExpectCloseDate)) { sb.Append(", ExpectCloseDate = ").AppendParameter("ExpectCloseDate", strExpectCloseDate); } else { sb.Append(", ExpectCloseDate = null "); } UserInfo oUser = UserInfo.getUserInfo(); sb.Append(", UpdDept = ").AppendParameter("Dept", oUser.DeptID); sb.Append(", UpdDeptName = ").AppendParameter("DeptName", oUser.DeptName); sb.Append(", UpdUser = "******"User", oUser.UserID); sb.Append(", UpdUserName = "******"UserName", oUser.UserName); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where CaseNo = ").AppendParameter("CaseNo", strCaseNo); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success); //資料更新成功 fmMain.DataSource = null; fmMain.DataBind(); divMainFormView.Visible = false; ucGridView1.Refresh(true); divMainGridview.Visible = true; } } catch (Exception ex) { //將 Exception 丟給 Log 模組 LogHelper.WriteSysLog(ex); //資料更新失敗 Util.NotifyMsg(RS.Resources.Msg_EditFail, Util.NotifyKind.Error); } }
void ucGridView1_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e) { string strCmd = e.CommandName; DataTable dt = e.DataTable; if (dt != null && dt.Rows.Count > 0) { UserInfo oUser = UserInfo.getUserInfo(); DbHelper db = new DbHelper(LegalSample._LegalSysDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); for (int i = 0; i < dt.Rows.Count; i++) { switch (e.CommandName) { case "cmdUpdateAll": sb.AppendStatement(string.Format("Update {0} Set DocNo = DocNo ", LegalSample._LegalDocTableName)); for (int j = 1; j < dt.Columns.Count; j++) { sb.Append(" ," + dt.Columns[j].ColumnName + " = ").AppendParameter(dt.Columns[j].ColumnName + i, dt.Rows[i][j].ToString()); } sb.Append(" ,UpdUser = "******"UserID", oUser.UserID); sb.Append(" ,UpdUserName = "******"UserName", oUser.UserName); sb.Append(" ,UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where 0=0 "); sb.Append(" And DocNo =").AppendParameter("DocNo" + i, dt.Rows[i][0].ToString().Split(',')[0]); break; default: break; } } DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); Util.NotifyMsg(RS.Resources.Msg_Succeed, Util.NotifyKind.Success); //處理成功 } catch { tx.Rollback(); Util.NotifyMsg(RS.Resources.Msg_Error, Util.NotifyKind.Error); //處理失敗 } finally { cn.Close(); cn.Dispose(); tx.Dispose(); } } else { Util.MsgBox(RS.Resources.Msg_DataNotFound); } }
protected void btnQry_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(_QryBaseSQL).Append(" Where 0=0 "); Dictionary <string, string> oDicResult = Util.getControlEditResult(DivQryCondition); //組合查詢條件 if (!string.IsNullOrEmpty(oDicResult["LogApp"])) { sb.Append(" And LogApp = ").AppendParameter("LogApp", oDicResult["LogApp"]); } if (!string.IsNullOrEmpty(oDicResult["LogType"])) { sb.Append(" And LogType = ").AppendParameter("LogType", oDicResult["LogType"]); } if (!string.IsNullOrEmpty(oDicResult["LogUser"])) { sb.Append(" And LogUser = "******"LogUser", oDicResult["LogUser"]); } if (!string.IsNullOrEmpty(oDicResult["LogDate1"])) { if (string.IsNullOrEmpty(oDicResult["LogDate2"])) { sb.Append(" And convert(varchar(10),[LogDateTime],111) = ").AppendParameter("LogDateTime1", oDicResult["LogDate1"]); } else { if (string.Compare(oDicResult["LogDate1"], oDicResult["LogDate2"]) > 0) { //若起始日期 大於 終止日期,則自動交換 string tmpDate = oDicResult["LogDate1"]; oDicResult["LogDate1"] = oDicResult["LogDate2"]; oDicResult["LogDate2"] = tmpDate; LogDate1.ucSelectedDate = oDicResult["LogDate1"]; LogDate2.ucSelectedDate = oDicResult["LogDate2"]; } sb.Append(" And ( "); sb.Append(" convert(varchar(10),[LogDateTime],111) Between ").AppendParameter("LogDateTime1", oDicResult["LogDate1"]); sb.Append(" And ").AppendParameter("LogDateTime2", oDicResult["LogDate2"]); sb.Append(" ) "); } } //將查詢條件的SQL物件,還原為純 SQL 字串,以便存到 _QryResultSQL 變數 _QryResultSQL = Util.getPureSQL(sb); //Response.Write(_QryResultSQL); //顯示查結果 ShowQryResult(); }
/// <summary> /// 「更新」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); //去除不必要欄位 oEditResult.Remove("UpdUser"); oEditResult.Remove("UpdDateTime"); //組合SQL sb.Reset(); sb.AppendStatement("Update ").Append(_TableName).Append(" set "); //處理非鍵值欄位 bool isComma = false; foreach (var pair in oEditResult) { if (!_PKList.Contains(pair.Key)) { switch (pair.Key) { default: if (isComma) { sb.Append(" , "); } else { isComma = true; } sb.Append(pair.Key).Append(" = ").AppendParameter(pair.Key, pair.Value); break; } } } //處理鍵值欄位 sb.Append(" Where 0 = 0 "); sb.Append(Util.getDataQueryKeySQL(_PKList, oEditResult)); //執行SQL if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success); //更新成功 } else { Util.NotifyMsg(RS.Resources.Msg_EditFail, Util.NotifyKind.Error); //更新失敗 } divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(); }
/// <summary> /// 確認更新明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailUpdate_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //更新明細 sb.AppendStatement("Update PODetail Set "); sb.Append(" ItemDesc = ").AppendParameter("ItemDesc", oDic["ItemDesc"]); sb.Append(", ItemExpDate = ").AppendParameter("ItemExpDate", oDic["ItemExpDate"]); sb.Append(", Unit = ").AppendParameter("Unit", oDic["Unit"]); sb.Append(", UnitPrice = ").AppendParameter("UnitPrice", oDic["UnitPrice"]); sb.Append(", Qty = ").AppendParameter("Qty", oDic["Qty"]); sb.Append(" Where 0=0 "); sb.Append(" And POID =").AppendParameter("POID", _MainID); sb.Append(" And POSeq =").AppendParameter("POSeq", _DetailSeq); //重新計算加總值 sb.AppendStatement(string.Format(_ReCal_BaseUpdSQL, _MainID)); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); Util.NotifyMsg("明細更新成功", Util.NotifyKind.Success); Refresh(); } catch { tx.Rollback(); Util.NotifyMsg("明細更新失敗", Util.NotifyKind.Error); } finally { cn.Close(); cn.Dispose(); tx.Dispose(); } }
protected void btnMainUpdate_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmMain); string strFlowStepMailToList = ((Util_ucCheckBoxList)fmMain.FindControl("chkFlowStepMailToList")).ucSelectedIDList; strFlowStepMailToList = strFlowStepMailToList + "," + ((Util_ucTextBox)fmMain.FindControl("txtFlowStepMailToList")).ucTextData; strFlowStepMailToList = Util.getStringJoin(Util.getFixList(strFlowStepMailToList.Split(','))); UserInfo oUser = UserInfo.getUserInfo(); DbHelper db = new DbHelper(FlowExpress._FlowSysDB); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement("Update FlowStep Set "); sb.Append(" FlowStepName = ").AppendParameter("txtFlowStepName", oDic["txtFlowStepName"]); sb.Append(", FlowStepBatchEnabled = ").AppendParameter("chkFlowStepBatchEnabled", oDic["chkFlowStepBatchEnabled"]); sb.Append(", FlowStepMailToList = ").AppendParameter("FlowStepMailToList", strFlowStepMailToList); sb.Append(", FlowStepCustVerifyURL = ").AppendParameter("txtFlowStepCustVerifyURL", oDic["txtFlowStepCustVerifyURL"]); sb.Append(", FlowStepAttachMaxQty = ").AppendParameter("txtFlowStepAttachMaxQty", oDic["txtFlowStepAttachMaxQty"]); sb.Append(", FlowStepAttachMaxKB = ").AppendParameter("txtFlowStepAttachMaxKB", oDic["txtFlowStepAttachMaxKB"]); sb.Append(", FlowStepAttachTotKB = ").AppendParameter("txtFlowStepAttachTotKB", oDic["txtFlowStepAttachTotKB"]); sb.Append(", FlowStepAttachExtList = ").AppendParameter("txtFlowStepAttachExtList", oDic["txtFlowStepAttachExtList"]); sb.Append(", Remark = ").AppendParameter("txtRemark", oDic["txtRemark"]); sb.Append(", UpdUser = "******"UpdUser", oUser.UserID); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where FlowID = ").AppendParameter("txtFlowID", oDic["txtFlowID"]); sb.Append(" And FlowStepID = ").AppendParameter("txtFlowStepID", oDic["txtFlowStepID"]); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { //[更新]資料異動Log LogHelper.WriteAppDataLog(FlowExpress._FlowSysDB, "FlowStep", string.Format("{0},{1}", oDic["txtFlowID"], oDic["txtFlowStepID"]), LogHelper.AppDataLogType.Update, oDic); Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success); } } catch (Exception ex) { Util.MsgBox(ex.Message); } DataTable dt = db.ExecuteDataSet(string.Format("Select * From FlowStep Where FlowID = '{0}' and FlowStepID = '{1}';", _FlowID, _FlowStepID)).Tables[0]; if (dt != null && dt.Rows.Count > 0) { fmMain.ChangeMode(FormViewMode.Edit); fmMain.DataSource = dt; fmMain.DataBind(); } RefreshGridView(); }
/// <summary> /// /// </summary> /// <param name="CompID"></param> /// <param name="EmpID"></param> /// <param name="WriteDate"></param> /// <param name="FormSeq"></param> /// <param name="OBFormStatus"></param> /// <param name="RejectReasonCN"></param> /// <param name="sb"></param> public static void UpdateVisitForm(string CompID, string EmpID, string WriteDate, string FormSeq, string OBFormStatus, string RejectReasonCN, ref CommandHelper sb) { string SQL = @" UPDATE VisitForm SET OBFormStatus = '{0}' ,RejectReasonCN = '{1}' WHERE CompID = '{2}' AND EmpID = '{3}' AND WriteDate = '{4}' AND FormSeq = '{5}' ;"; sb.AppendStatement(string.Format(SQL, OBFormStatus, RejectReasonCN, CompID, EmpID, WriteDate, FormSeq)); }
/// <summary> /// 「新增」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInsert_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得 FormView 編輯控制項的編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); sb.Reset(); sb.AppendStatement("Insert ").Append(_TableName); sb.Append("( "); sb.Append(" MsgID,MsgKind,IsEnabled,MsgBody,MsgUrl,Remark"); sb.Append(" ,StartDateTime,EndDateTime"); sb.Append(" ,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("MsgID", oEditResult["MsgID"]); sb.Append(" ,").AppendParameter("MsgKind", oEditResult["MsgKind"]); sb.Append(" ,").AppendParameter("IsEnabled", oEditResult["IsEnabled"]); sb.Append(" ,").AppendParameter("MsgBody", oEditResult["MsgBody"]); sb.Append(" ,").AppendParameter("MsgUrl", oEditResult["MsgUrl"]); sb.Append(" ,").AppendParameter("Remark", oEditResult["Remark"]); if (oEditResult["StartDate"].CompareTo(oEditResult["EndDate"]) > 0) { sb.Append(" ,").AppendParameter("StartDateTime", oEditResult["EndDate"] + " " + oEditResult["EndTime"]); sb.Append(" ,").AppendParameter("EndDateTime", oEditResult["StartDate"] + " " + oEditResult["StartTime"]); } else { sb.Append(" ,").AppendParameter("StartDateTime", oEditResult["StartDate"] + " " + oEditResult["StartTime"]); sb.Append(" ,").AppendParameter("EndDateTime", oEditResult["EndDate"] + " " + oEditResult["EndTime"]); } sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_AddSucceed, Util.NotifyKind.Success); //新增成功 divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(true); } else { Util.NotifyMsg(RS.Resources.Msg_AddFail, Util.NotifyKind.Error); //新增失敗 } } catch (Exception ex) { Util.MsgBox(ex.Message); } }
protected void btnVerify_Click(object sender, EventArgs e) { Button oBtn = (Button)sender; //檢查流程意見是否為必需輸入 if (string.IsNullOrEmpty(txtFlowOpinion.ucTextData)) { if (oBtn.CommandArgument.ToUpper() == "Y") { //必需輸入 Util.NotifyMsg(WorkRS.Resources.FlowVerifyMsg_OpinionRequired, Util.NotifyKind.Error); return; } else { //非必需輸入,填入預設意見 txtFlowOpinion.ucTextData = WorkRS.Resources.FlowDefOpinion; } } //將意見暫存,方便審核畫面引用 2017.04.28 FlowExpress oFlow = new FlowExpress(); DbHelper dblog = new DbHelper(oFlow.FlowLogDB); CommandHelper sb = dblog.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(string.Format("Update {0}FlowOpenLog Set ", oFlow.FlowID)); sb.Append(" FlowStepOpinion = ").AppendParameter("FlowStepOpinion", txtFlowOpinion.ucTextData.Replace(",", "''")); sb.Append(" Where FlowLogID = ").AppendParameter("FlowLogID", oFlow.FlowLogID); if (dblog.ExecuteNonQuery(sb.BuildCommand()) <= 0) { Util.NotifyMsg(string.Format(RS.Resources.Msg_Error1, WorkRS.Resources.FlowVerifyTab_SaveFlowTempOpinion), Util.NotifyKind.Error); return; } Dictionary <string, string> dicPara = Util.getRequestQueryString(); if (dicPara.IsNullOrEmpty()) { //缺少流程參數 Util.NotifyMsg(WorkRS.Resources.FlowFullLogMsg_FlowParaError, Util.NotifyKind.Error); return; } else { ucModalPopup1.Reset(); ucModalPopup1.ucFrameURL = string.Format("{0}?FlowID={1}&FlowLogID={2}&FlowStepBtnID={3}", FlowExpress._FlowPageVerifyFrameURL, dicPara["FlowID"], dicPara["FlowLogID"], oBtn.CommandName); //FlowExpress._FlowPageVerifyFrameURL + "?Dummy=" + Util.getRandomCode(); ucModalPopup1.ucPopupWidth = 680; ucModalPopup1.ucPopupHeight = 580; ucModalPopup1.Show(); } }
/// <summary> /// 確認新增明細 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDetailInsert_Click(object sender, EventArgs e) { Dictionary <string, string> oDic = Util.getControlEditResult(fmDetail); if (!string.IsNullOrEmpty(_RuleID)) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); //新增明細 sb.AppendStatement("Insert AclRuleExp "); sb.Append("(RuleID,ChkGrpNo,ChkSeqNo,IsEnabled,ChkOrgUserObjectProperty,ChkOrgUserSW,ChkOrgUserExp,ChkOrgUserPropertyValue,ChkCodeMapSW,ChkCodeMapFldName,Remark,UpdUser,UpdDateTime) "); sb.Append(" Values (").AppendParameter("RuleID", _RuleID); sb.Append(" ,").AppendParameter("ChkGrpNo", oDic["ChkGrpNo"]); sb.Append(" ,").AppendParameter("ChkSeqNo", oDic["ChkSeqNo"]); sb.Append(" ,").AppendParameter("IsEnabled", oDic["IsEnabled"]); sb.Append(" ,").AppendParameter("ChkOrgUserObjectProperty", oDic["ChkOrgUserObjectProperty"]); sb.Append(" ,").AppendParameter("ChkOrgUserSW", oDic["ChkOrgUserSW"]); sb.Append(" ,").AppendParameter("ChkOrgUserExp", oDic["ChkOrgUserExp"]); sb.Append(" ,").AppendParameter("ChkOrgUserPropertyValue", oDic["ChkOrgUserPropertyValue"]); sb.Append(" ,").AppendParameter("ChkCodeMapSW", oDic["ChkCodeMapSW"]); sb.Append(" ,").AppendParameter("ChkCodeMapFldName", oDic["ChkCodeMapFldName"]); sb.Append(" ,").AppendParameter("Remark", oDic["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(")"); try { db.ExecuteNonQuery(sb.BuildCommand()); _ChkGrpNo = int.Parse(oDic["ChkGrpNo"]); _ChkSeqNo = int.Parse(oDic["ChkSeqNo"]); Dictionary <string, string> dicKey = new Dictionary <string, string>(); dicKey.Clear(); dicKey.Add("RuleID", _RuleID); dicKey.Add("ChkGrpNo", _ChkGrpNo.ToString()); dicKey.Add("ChkSeqNo", _ChkSeqNo.ToString()); AclExpress.IsAclTableLog("AclRuleExp", dicKey, LogHelper.AppTableLogType.Create); Util.NotifyMsg("條件新增成功", Util.NotifyKind.Success); } catch { Util.NotifyMsg("條件新增失敗", Util.NotifyKind.Error); } Refresh(false, true); } }
/// <summary> /// 確定更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { string strDocNo = ((TextBox)Util.FindControlEx(fmMain, "txtDocNo")).Text; string strIsRelease = ((CheckBox)Util.FindControlEx(fmMain, "chkIsRelease")).Checked ? "Y" : "N"; string strSubject = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucSubject")).ucTextData; string strUsage = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucUsage")).ucTextData; string strKeyword = ((Util_ucCheckBoxList)Util.FindControlEx(fmMain, "ucKeyword")).ucSelectedIDList; string strRemark = ((Util_ucTextBox)Util.FindControlEx(fmMain, "ucRemark")).ucTextData; Util_ucCascadingDropDown oCascading = (Util_ucCascadingDropDown)Util.FindControlEx(fmMain, "ucCascadingKind"); DbHelper db = new DbHelper(LegalSample._LegalSysDBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(string.Format("Update {0} Set ", LegalSample._LegalDocTableName)); sb.Append(" IsRelease = ").AppendParameter("IsRelease", strIsRelease); sb.Append(", Subject = ").AppendParameter("Subject", strSubject); sb.Append(", Kind1 = ").AppendParameter("Kind1", oCascading.ucSelectedValue01); sb.Append(", Kind2 = ").AppendParameter("Kind2", oCascading.ucSelectedValue02); sb.Append(", Kind3 = ").AppendParameter("Kind3", oCascading.ucSelectedValue03); sb.Append(", Usage = ").AppendParameter("Usage", strUsage); sb.Append(", Keyword = ").AppendParameter("Keyword", strKeyword); sb.Append(", Remark = ").AppendParameter("Remark", strRemark); UserInfo oUser = UserInfo.getUserInfo(); sb.Append(", UpdUser = "******"User", oUser.UserID); sb.Append(", UpdUserName = "******"UserName", oUser.UserName); sb.Append(", UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where DocNo = ").AppendParameter("DocNo", strDocNo); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success); //資料更新成功 fmMain.DataSource = null; fmMain.DataBind(); divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(true); } } catch (Exception ex) { //將 Exception 丟給 Log 模組 LogHelper.WriteSysLog(ex); //資料更新失敗 Util.NotifyMsg(RS.Resources.Msg_EditFail, Util.NotifyKind.Error); } }
/// <summary> /// 資料匯入 /// </summary> protected void DataImport() { //從暫存資料區(TestBulkQueue)搬移到正式資料區(TestBulk) string strWhereUserID = string.Format(" Where PUser = '******' ", UserInfo.getUserInfo().UserID); //暫存資料過濾條件 DbHelper db = new DbHelper(_DBName); int intCloneQty = int.Parse(db.ExecuteDataSet("Select Count(*) From TestBulkQueue " + strWhereUserID).Tables[0].Rows[0][0].ToString()); if (intCloneQty <= 0) { ShowMsg(Util.getHtmlMessage(Util.HtmlMessageKind.DataNotFound)); return; } CommandHelper sb = db.CreateCommandHelper(); DbConnection cn = db.OpenConnection(); DbTransaction tx = cn.BeginTransaction(); try { sb.Reset(); sb.AppendStatement("Insert TestBulk (PKey,TabName,FldName,Value,UpdUser,UpdTime) "); sb.Append(" Select PKey,TabName,FldName,Value,UpdUser,UpdTime From TestBulkQueue " + strWhereUserID); sb.AppendStatement("Delete From TestBulkQueue " + strWhereUserID); db.ExecuteNonQuery(sb.BuildCommand(), tx); tx.Commit(); ShowMsg("資料匯入成功"); } catch (SqlException ex) { tx.Rollback(); ShowMsg("資料匯入失敗<br/>" + ex.Message); } finally { cn.Close(); cn.Dispose(); tx.Dispose(); ucLightBox.Hide(); } }
/// <summary> /// 「新增」按鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInsert_Click(object sender, EventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); //取得 FormView 編輯控制項的編輯結果 Dictionary <string, string> oEditResult = Util.getControlEditResult(fmMain); sb.Reset(); sb.AppendStatement("Insert ").Append(_TableName); sb.Append("( "); sb.Append(" NodeID,NodeName,ParentNodeID,DefaultEnabledNodeID,IsEnabled,OrderSeq"); sb.Append(" ,TargetUrl,TargetPara,ChkGrantID,ImageUrl,ToolTip,Remark"); sb.Append(" ,UpdUser,UpdDateTime"); sb.Append(" ) Values ("); sb.Append(" ").AppendParameter("NodeID", oEditResult["NodeID"]); sb.Append(" ,").AppendParameter("NodeName", oEditResult["NodeName"]); sb.Append(" ,").AppendParameter("ParentNodeID", oEditResult["ParentNodeID"]); sb.Append(" ,").AppendParameter("DefaultEnabledNodeID", oEditResult["DefaultEnabledNodeID"]); sb.Append(" ,").AppendParameter("IsEnabled", oEditResult["IsEnabled"]); sb.Append(" ,").AppendParameter("OrderSeq", oEditResult["OrderSeq"]); sb.Append(" ,").AppendParameter("TargetUrl", oEditResult["TargetUrl"]); sb.Append(" ,").AppendParameter("TargetPara", oEditResult["TargetPara"]); sb.Append(" ,").AppendParameter("ChkGrantID", oEditResult["ChkGrantID"]); sb.Append(" ,").AppendParameter("ImageUrl", oEditResult["ImageUrl"]); sb.Append(" ,").AppendParameter("ToolTip", oEditResult["ToolTip"]); sb.Append(" ,").AppendParameter("Remark", oEditResult["Remark"]); sb.Append(" ,").AppendParameter("UpdUser", UserInfo.getUserInfo().UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(" )"); try { if (db.ExecuteNonQuery(sb.BuildCommand()) >= 0) { Util.NotifyMsg(RS.Resources.Msg_AddSucceed, Util.NotifyKind.Success); //新增成功 PageViewState["_Dic_DefaultEnabledNodeID"] = null; PageViewState["_Dic_ParentNodeID"] = null; divMainFormView.Visible = false; divMainGridview.Visible = true; ucGridView1.Refresh(true); } else { Util.NotifyMsg(RS.Resources.Msg_AddFail, Util.NotifyKind.Error); //新增失敗 } } catch (Exception ex) { Util.MsgBox(ex.Message); } }
/// <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()); }
public static void PunchAppdOperation_UpdateHROtherFlowLog(string FlowCaseID, string FlowStatus, ref CommandHelper sb, bool isReset = false) { string HROtherFlowLog_ = "HROtherFlowLog_"; if (isReset) { sb.Reset(); } sb.AppendStatement(" Update HROtherFlowLog set "); sb.Append(" FlowStatus=").AppendParameter(HROtherFlowLog_ + "FlowStatus", FlowStatus); sb.Append(" where FlowCaseID=").AppendParameter(HROtherFlowLog_ + "0_FlowCaseID", FlowCaseID); sb.Append(" and Seq= (select Top 1 Seq from HROverTimeLog where FlowCaseID=").AppendParameter(HROtherFlowLog_ + "1_FlowCaseID", FlowCaseID); sb.Append(" order by Seq desc) ; "); }