protected override bool WfAppendUpdate() { icm_tb icmOrgModel; DataTable dtIcm; DataRow drIcm; CommonBLL boAppend; StringBuilder sbSql; try { icmOrgModel = DrMaster.ToItem <icm_tb>(); boAppend = new CommonBLL(BoMaster.OfGetConntion()); boAppend.TRAN = BoMaster.TRAN; boAppend.OfCreateDao("icm_tb", "*", ""); sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM icm_tb"); sbSql.AppendLine(string.Format("WHERE icm01='{0}'", icmOrgModel.icm02)); sbSql.AppendLine(string.Format("AND icm02='{0}'", icmOrgModel.icm01)); dtIcm = boAppend.OfGetDataTable(sbSql.ToString()); if (dtIcm.Rows.Count == 0)//新增 { drIcm = dtIcm.NewRow(); drIcm["icm01"] = icmOrgModel.icm02; drIcm["icm02"] = icmOrgModel.icm01; drIcm["icm03"] = icmOrgModel.icm04; drIcm["icm04"] = icmOrgModel.icm03; drIcm["icm05"] = ""; drIcm["icmvali"] = icmOrgModel.icmvali; drIcm["icmsecu"] = LoginInfo.UserNo; drIcm["icmsecg"] = LoginInfo.GroupNo; drIcm["icmcreu"] = LoginInfo.UserNo; drIcm["icmcreg"] = LoginInfo.DeptNo; drIcm["icmcred"] = Now; dtIcm.Rows.Add(drIcm); } else { drIcm = dtIcm.Rows[0]; drIcm["icm03"] = icmOrgModel.icm04; drIcm["icm04"] = icmOrgModel.icm03; drIcm["icmvali"] = icmOrgModel.icmvali; drIcm["icmmodu"] = LoginInfo.UserNo; drIcm["icmmodg"] = LoginInfo.DeptNo; drIcm["icmmodd"] = Now; } boAppend.OfUpdate(dtIcm); return(true); } catch (Exception ex) { throw ex; } }
protected override bool WfExecute() { vw_glab313 masterModel = null; int chkCnts = 0; StringBuilder sbResult = null; try { //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoGlab313.TRAN = BoMaster.TRAN; masterModel = DrMaster.ToItem <vw_glab313>(); var securityString = WfGetSecurityString(); var resultList = BoGlab313.OfGlab313Post(masterModel, securityString, "", LoginInfo); if (resultList == null || resultList.Count == 0) { WfShowBottomStatusMsg("無可過帳還原資料!"); BoGlab313.TRAN.Rollback(); return(true); } chkCnts = resultList.Where(p => p.Success == false).Count(); if (chkCnts > 0) { BoGlab313.TRAN.Rollback(); sbResult = new StringBuilder(); sbResult.AppendLine(string.Format("執行失敗!")); sbResult.AppendLine(string.Format("過帳還原傳票筆數【{0}】 成功:【{1}】 失敗【{2}】", resultList.Count, resultList.Count - chkCnts, chkCnts )); sbResult.AppendLine(); sbResult.AppendLine(string.Format("錯誤內容如下")); sbResult.AppendLine("===================================="); foreach (Result result in resultList.Where(p => p.Success == false)) { sbResult.AppendLine(string.Format("key1:【{0}】 錯誤訊息:【{1}】", result.Key1, result.Message)); } WfShowErrorMsg(sbResult.ToString()); BoGlab313.TRAN.Rollback(); return(false); } BoMaster.TRAN.Commit(); return(true); } catch (Exception ex) { if (BoMaster.TRAN != null) { BoMaster.TRAN.Rollback(); } throw ex; } }
protected override bool WfExecute() { vw_glab321 glab312Model = null; try { glab312Model = DrMaster.ToItem <vw_glab321>(); //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoGlab321.TRAN = BoMaster.TRAN; var result = BoGlab321.OfGlab321Post(glab312Model, LoginInfo); if (result == null) { WfShowBottomStatusMsg("查無可年結資料!"); BoMaster.TRAN.Rollback(); return(true); } if (result.Success == false) { WfShowErrorMsg(result.Message); BoMaster.TRAN.Rollback(); return(false); } BoMaster.TRAN.Commit(); return(true); } catch (Exception ex) { if (BoMaster.TRAN != null) { BoMaster.TRAN.Rollback(); } throw ex; } }
protected override bool WfExecute() { vw_glab311 glab311Model = null; vw_glab312 glab312Model = null; int chkCnts = 0; StringBuilder sbResult = null; DateTime dtStart, dtEnd; try { glab312Model = DrMaster.ToItem <vw_glab312>(); glab311Model = new vw_glab311(); if (BoGlab311.OfGetGlaYearPeriod(Convert.ToInt16(glab312Model.gfa08), Convert.ToInt16(glab312Model.gfa09), out dtStart, out dtEnd) == false) { WfShowErrorMsg("無法取得期數區間,請檢核!"); return(false); } glab311Model.gfa02_s = dtStart; glab311Model.gfa02_e = dtEnd; //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoGlab311.TRAN = BoMaster.TRAN; if (WfUpdatePostRelation(glab311Model, glab312Model) == false) { return(false); } var resultList = BoGlab311.OfGlab311Post(glab311Model, "Y", "", "", LoginInfo); if (resultList == null || resultList.Count == 0) { WfShowBottomStatusMsg("無可過帳資料!"); BoGlab311.TRAN.Rollback(); return(true); } chkCnts = resultList.Where(p => p.Success == false).Count(); if (chkCnts > 0) { BoGlab311.TRAN.Rollback(); sbResult = new StringBuilder(); sbResult.AppendLine(string.Format("執行失敗!")); sbResult.AppendLine(string.Format("過帳傳票筆數【{0}】 成功:【{1}】 失敗【{2}】", resultList.Count, resultList.Count - chkCnts, chkCnts )); sbResult.AppendLine(); sbResult.AppendLine(string.Format("錯誤內容如下")); sbResult.AppendLine("===================================="); foreach (Result result in resultList.Where(p => p.Success == false)) { sbResult.AppendLine(string.Format("key1:【{0}】 錯誤訊息:【{1}】", result.Key1, result.Message)); } WfShowErrorMsg(sbResult.ToString()); return(false); } BoMaster.TRAN.Commit(); return(true); } catch (Exception ex) { if (BoMaster.TRAN != null) { BoMaster.TRAN.Rollback(); } throw ex; } }
//檢查登入角色是否有執行該程式的權限 protected override bool WfAppendUpdate() { DataTable dtAddTb; AdmBLL boAppend; StringBuilder sbSql; vw_admi600 masterModel = null; List <SqlParameter> sqlParmList = null; try { masterModel = DrMaster.ToItem <vw_admi600>(); boAppend = new AdmBLL(BoMaster.OfGetConntion()); boAppend.TRAN = BoMaster.TRAN; boAppend.OfCreateDao("add_tb", "*", ""); sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM add_tb"); sbSql.AppendLine("WHERE add01=@add01"); sbSql.AppendLine("AND add02=@add02"); sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@add01", LoginInfo.UserRole)); sqlParmList.Add(new SqlParameter("@add02", masterModel.ado01)); dtAddTb = boAppend.OfGetDataTable(sbSql.ToString(), sqlParmList.ToArray()); if (masterModel.ado07.ToUpper() == "M")//menus 時 { if (dtAddTb != null && dtAddTb.Rows.Count > 0) { dtAddTb.Rows[0].Delete(); if (boAppend.OfUpdate(dtAddTb) < 1) { WfShowErrorMsg("刪除權限資料檔(add_tb)失敗!"); return(false); } } } else //報表或程式時 { if (dtAddTb.Rows.Count == 0 && GlobalFn.isNullRet(masterModel.ado16, "") != "Y") { var result = WfShowConfirmMsg("無此程式的權限,請問是否自動新增 ?"); //var i = WfShowConfirmMsg("無此程式的權限,請問是否自動新增"); //if (i == 1) if (result == DialogResult.Yes) { var drNew = dtAddTb.NewRow(); drNew["add01"] = LoginInfo.UserRole; drNew["add02"] = masterModel.ado01; drNew["add03"] = "Y"; drNew["add04"] = "Y"; drNew["add05"] = "Y"; drNew["add06"] = "Y"; drNew["add07"] = "Y"; drNew["add08"] = "Y"; drNew["add09"] = "Y"; drNew["add10"] = "Y"; drNew["add11"] = "Y"; drNew["add12"] = "Y"; dtAddTb.Rows.Add(drNew); if (boAppend.OfUpdate(dtAddTb) < 1) { WfShowErrorMsg("刪除權限資料檔(add_tb)失敗!"); return(false); } } } } return(true); } catch (Exception ex) { throw ex; } }
protected override bool WfExecute() { vw_invb600 invb600Model; List <QueryInfo> queryInfoList; QueryInfo queryModel; List <SqlParameter> sqlParmList; string strQueryRange, strWhere; DataTable dtMain; StringBuilder sbSql; int chkCnts = 0; try { //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoStp.TRAN = BoMaster.TRAN; invb600Model = DrMaster.ToItem <vw_invb600>(); #region range 查詢條件 queryInfoList = new List <QueryInfo>(); if (!GlobalFn.varIsNull(invb600Model.icc01)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc01"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc01"].DataType.Name; queryModel.Value = invb600Model.icc01; queryInfoList.Add(queryModel); } if (!GlobalFn.varIsNull(invb600Model.icc02)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc02"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc02"].DataType.Name; queryModel.Value = invb600Model.icc02; queryInfoList.Add(queryModel); } sqlParmList = new List <SqlParameter>(); strQueryRange = BoMaster.WfGetQueryString(queryInfoList, out sqlParmList); strWhere = strQueryRange; #endregion var strSecurity = WfGetSecurityString(); //暫時無權限問題,先保留 if (!GlobalFn.varIsNull(strSecurity)) { strWhere += strSecurity; } //取得單頭 sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM icc_tb"); sbSql.AppendLine("WHERE 1=1"); dtMain = BoMaster.OfGetDataTable(string.Concat(sbSql.ToString(), strWhere), sqlParmList.ToArray()); dtMain.TableName = "Master"; if (dtMain == null || dtMain.Rows.Count == 0) { WfShowErrorMsg("查無資料,請重新過濾條件!"); BoMaster.TRAN.Rollback(); return(false); } foreach (DataRow drIcc in dtMain.Rows) { var iccModel = drIcc.ToItem <vw_invb600>(); //取得ina_tb庫存歷史檔資料! sbSql = new StringBuilder(); sbSql.AppendLine(string.Format("SELECT SUM(CASE WHEN ina03='1' THEN ina10 ELSE ina10*-1 END)")); sbSql.AppendLine(string.Format("FROM ina_tb")); sbSql.AppendLine(string.Format("WHERE ina05=@ina05")); sbSql.AppendLine(string.Format("AND ina06=@ina06")); sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@ina05", iccModel.icc01)); sqlParmList.Add(new SqlParameter("@ina06", iccModel.icc02)); var compueQty = GlobalFn.isNullRet(BoStp.OfGetFieldValue(sbSql.ToString(), sqlParmList.ToArray()), 0); sbSql = new StringBuilder(); sbSql.AppendLine(string.Format("UPDATE icc_tb")); sbSql.AppendLine(string.Format("SET icc05=@icc05")); sbSql.AppendLine(string.Format("WHERE icc01=@icc01")); sbSql.AppendLine(string.Format("AND icc02=@icc02")); sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@icc01", iccModel.icc01)); sqlParmList.Add(new SqlParameter("@icc02", iccModel.icc02)); sqlParmList.Add(new SqlParameter("@icc05", compueQty)); chkCnts = BoStp.OfExecuteNonquery(sbSql.ToString(), sqlParmList.ToArray()); if (chkCnts <= 0) { WfShowErrorMsg("查無可異動icc_tb資料表,請檢核!"); BoMaster.TRAN.Rollback(); return(false); } } BoMaster.TRAN.Commit(); return(true); } catch (Exception ex) { BoMaster.TRAN.Rollback(); throw ex; } }
protected override bool WfAppendUpdate() { vw_admi611 admi611Model = null; int chkCnts = 0; StringBuilder sbSql = null; List <SqlParameter> sqlParmsList; CommonBLL boAppend; DataTable dtady = null; try { boAppend = new InvBLL(BoMaster.OfGetConntion()); boAppend.TRAN = BoMaster.TRAN; boAppend.OfCreateDao("ady_tb", "*", ""); admi611Model = DrMaster.ToItem <vw_admi611>(); //處理明細--均先刪後新增 if (FormEditMode != YREditType.新增) { sbSql = new StringBuilder(); sqlParmsList = new List <SqlParameter>(); sbSql.AppendLine("DELETE FROM ady_tb WHERE ady01=@ady01"); sqlParmsList.Add(new SqlParameter("@ady01", admi611Model.adx01)); chkCnts = boAppend.OfExecuteNonquery(sbSql.ToString(), sqlParmsList.ToArray()); sbSql = new StringBuilder(); sqlParmsList = new List <SqlParameter>(); sbSql.AppendLine("SELECT * FROM ady_tb"); sbSql.AppendLine("WHERE 1<>1"); dtady = boAppend.OfGetDataTable(sbSql.ToString()); foreach (vw_admi611s detailModel in Admi611sList) { var drady = dtady.NewRow(); drady["ady01"] = detailModel.ady01; drady["ady02"] = detailModel.ady02; drady["ady03"] = detailModel.ady03; drady["ady04"] = detailModel.ady04; drady["ady05"] = detailModel.ady05; drady["ady06"] = detailModel.ady06; drady["ady07"] = detailModel.ady07; drady["adycreu"] = detailModel.adycreu; drady["adycreg"] = detailModel.adycreg; if (detailModel.adycred == null) { drady["adycred"] = DBNull.Value; } else { drady["adycred"] = detailModel.adycred; } drady["adymodu"] = detailModel.adymodu; drady["adymodg"] = detailModel.adymodg; if (detailModel.adymodd == null) { drady["adymodd"] = DBNull.Value; } else { drady["adymodd"] = detailModel.adymodd; } dtady.Rows.Add(drady); } boAppend.OfUpdate(dtady); } return(true); } catch (Exception ex) { throw ex; } }
protected override bool WfExecute() { vw_invb600 invb600Model; sga_tb sgaModel; List <QueryInfo> queryInfoList; QueryInfo queryModel; List <SqlParameter> sqlParmList; string strQueryRange, strWhere; DataTable dtMain; StringBuilder sbSql; int chkCnts = 0; try { //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoInv.TRAN = BoMaster.TRAN; invb600Model = DrMaster.ToItem <vw_invb600>(); #region range 查詢條件 queryInfoList = new List <QueryInfo>(); if (!GlobalFn.varIsNull(invb600Model.icc01)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc01"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc01"].DataType.Name; queryModel.Value = invb600Model.icc01; queryInfoList.Add(queryModel); } if (!GlobalFn.varIsNull(invb600Model.icc02)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc02"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc02"].DataType.Name; queryModel.Value = invb600Model.icc02; queryInfoList.Add(queryModel); } sqlParmList = new List <SqlParameter>(); strQueryRange = BoMaster.WfGetQueryString(queryInfoList, out sqlParmList); strWhere = strQueryRange; #endregion var strSecurity = WfGetSecurityString(); //暫時無權限問題,先保留 if (!GlobalFn.varIsNull(strSecurity)) { strWhere += strSecurity; } //取得單頭 sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM sga_tb"); sbSql.AppendLine("WHERE sgaconf='N' "); dtMain = BoMaster.OfGetDataTable(string.Concat(sbSql.ToString(), strWhere), sqlParmList.ToArray()); dtMain.TableName = "Master"; if (dtMain == null || dtMain.Rows.Count == 0) { WfShowErrorMsg("查無資料,請重新過濾條件!"); BoMaster.TRAN.Rollback(); return(false); } foreach (DataRow drIga in dtMain.Rows) { var iccModel = drIga.ToItem <sga_tb>(); //取得ina_tb庫存歷史檔資料! sbSql = new StringBuilder(); chkCnts = BoInv.OfExecuteNonquery(sbSql.ToString(), sqlParmList.ToArray()); //if (chkCnts<=0) //{ // WfShowErrorMsg("查無可異動icc_tb資料表,請檢核!"); // BoMaster.TRAN.Rollback(); // return false; //} } BoMaster.TRAN.Commit(); return(true); } catch (Exception ex) { BoMaster.TRAN.Rollback(); throw ex; } }
protected override bool WfExecute() { vw_invb500 invb500Model; List <QueryInfo> queryInfoList; QueryInfo queryModel; List <SqlParameter> sqlParmList; string strQueryRange, strWhere, strOrderBy; DataTable dtMain, dtIpaInsert, dtIpbInsert; DataRow drIpa, drIpb; StringBuilder sbSql, sbInsert; int chkCnts = 0; string ipa01New = "", errMsg = ""; try { //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(IsolationLevel.ReadUncommitted); BoInv.TRAN = BoMaster.TRAN; BoBas.TRAN = BoMaster.TRAN; invb500Model = DrMaster.ToItem <vw_invb500>(); #region range 查詢條件 queryInfoList = new List <QueryInfo>(); if (!GlobalFn.varIsNull(invb500Model.icc01)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc01"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc01"].DataType.Name; queryModel.Value = invb500Model.icc01; queryInfoList.Add(queryModel); } if (!GlobalFn.varIsNull(invb500Model.icc02)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc02"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc02"].DataType.Name; queryModel.Value = invb500Model.icc02; queryInfoList.Add(queryModel); } if (!GlobalFn.varIsNull(invb500Model.icc03)) { queryModel = new QueryInfo(); queryModel.TableName = "icc_tb"; queryModel.ColumnName = "icc03"; queryModel.ColumnType = TabMaster.DtSource.Columns["icc03"].DataType.Name; queryModel.Value = invb500Model.icc02; queryInfoList.Add(queryModel); } sqlParmList = new List <SqlParameter>(); strQueryRange = BoMaster.WfGetQueryString(queryInfoList, out sqlParmList); strWhere = strQueryRange; #endregion var strSecurity = WfGetSecurityString(); //暫時無權限問題,先保留 if (!GlobalFn.varIsNull(strSecurity)) { strWhere += strSecurity; } //取得資料 sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM icc_tb"); sbSql.AppendLine("WHERE 1=1"); #region 加入排序 strOrderBy = ""; switch (invb500Model.order_by_1) { case "1": strOrderBy = " ORDER BY icc03,"; break; case "2": strOrderBy = " ORDER BY icc01,"; break; case "3": strOrderBy = " ORDER BY icc02,"; break; } switch (invb500Model.order_by_2) { case "1": strOrderBy += "icc03,"; break; case "2": strOrderBy += "icc01,"; break; case "3": strOrderBy += "icc02,"; break; } switch (invb500Model.order_by_3) { case "1": strOrderBy += "icc03"; break; case "2": strOrderBy += "icc01"; break; case "3": strOrderBy += "icc02"; break; } #endregion dtMain = BoMaster.OfGetDataTable(string.Concat(sbSql.ToString(), strWhere, strOrderBy), sqlParmList.ToArray()); dtMain.TableName = "Master"; if (dtMain == null || dtMain.Rows.Count == 0) { WfShowErrorMsg("查無資料,請重新過濾條件!"); BoMaster.TRAN.Rollback(); return(false); } #region 寫入盤點清冊 //新增單頭 if (BoBas.OfGetAutoNo(invb500Model.ipa01, ModuleType.stp, (DateTime)invb500Model.ipa02, out ipa01New, out errMsg) == false) { WfShowErrorMsg(errMsg); return(false); } BoInv.OfCreateDao("ipa_tb", "*", ""); sbInsert = new StringBuilder(); sbInsert.AppendLine("SELECT * FROM ipa_tb"); sbInsert.AppendLine("WHERE 1<>1"); dtIpaInsert = BoInv.OfGetDataTable(sbInsert.ToString()); drIpa = dtIpaInsert.NewRow(); drIpa["ipa01"] = ipa01New; drIpa["ipa02"] = invb500Model.ipa02; drIpa["ipa03"] = invb500Model.ipa03; drIpa["ipa04"] = invb500Model.ipa04; drIpa["ipa05"] = "N"; drIpa["ipa06"] = DBNull.Value; drIpa["ipa07"] = "N"; drIpa["ipa08"] = DBNull.Value; drIpa["ipacomp"] = LoginInfo.CompNo; drIpa["ipasecu"] = LoginInfo.UserNo; drIpa["ipasecg"] = LoginInfo.GroupNo; drIpa["ipacreu"] = LoginInfo.UserNo; drIpa["ipacreg"] = LoginInfo.DeptNo; drIpa["ipacred"] = Now; drIpa["ipamodu"] = DBNull.Value; drIpa["ipamodg"] = DBNull.Value; drIpa["ipamodd"] = DBNull.Value; dtIpaInsert.Rows.Add(drIpa); if (BoInv.OfUpdate(dtIpaInsert) != 1) { errMsg = "新增盤點清冊(ipa_tb)失敗!"; BoMaster.TRAN.Rollback(); WfShowErrorMsg(errMsg); return(false); } BoInv.OfCreateDao("ipb_tb", "*", ""); sbInsert = new StringBuilder(); sbInsert.AppendLine("SELECT * FROM ipb_tb"); sbInsert.AppendLine("WHERE 1<>1"); dtIpbInsert = BoInv.OfGetDataTable(sbInsert.ToString()); var i = 0; foreach (DataRow drIcc in dtMain.Rows) { i++; drIpb = dtIpbInsert.NewRow(); var iccModel = drIcc.ToItem <icc_tb>(); drIpb["ipb01"] = ipa01New; drIpb["ipb02"] = i; drIpb["ipb03"] = iccModel.icc01; drIpb["ipb04"] = iccModel.icc02; drIpb["ipb05"] = iccModel.icc03; drIpb["ipb06"] = iccModel.icc05; drIpb["ipb07"] = iccModel.icc04; drIpb["ipb30"] = 0; drIpb["ipb31"] = DBNull.Value; drIpb["ipb32"] = DBNull.Value; drIpb["ipb40"] = 0; drIpb["ipb41"] = DBNull.Value; drIpb["ipb42"] = DBNull.Value; drIpb["ipb50"] = 0; drIpb["ipb51"] = DBNull.Value; drIpb["ipb52"] = DBNull.Value; drIpb["ipbcomp"] = LoginInfo.CompNo; drIpb["ipbcreu"] = LoginInfo.UserNo; drIpb["ipbcreg"] = LoginInfo.DeptNo; drIpb["ipbcred"] = Now; drIpb["ipbmodu"] = DBNull.Value; drIpb["ipbmodg"] = DBNull.Value; drIpb["ipbmodd"] = DBNull.Value; dtIpbInsert.Rows.Add(drIpb); } if (BoInv.OfUpdate(dtIpbInsert) <= 0) { errMsg = "新增盤點清冊(ipb_tb)失敗!"; BoMaster.TRAN.Rollback(); WfShowErrorMsg(errMsg); return(false); } #endregion BoMaster.TRAN.Commit(); #region 檢視產生資料 if (WfShowConfirmMsg("盤點清冊展開完成,是否要檢視盤點資料?") == DialogResult.Yes) { sbSql = new StringBuilder(); sbSql.AppendLine(string.Format(" AND ipa01='{0}'", ipa01New)); WfShowForm("invb501", false, new object[] { "admi600", this.LoginInfo, sbSql.ToString() }); } #endregion return(true); } catch (Exception ex) { BoMaster.TRAN.Rollback(); throw ex; } }
/********************** 新增/查詢/拷貝/存檔/刪除 相關 Function **********************/ #region WfIniMaster() 設定表單主要的資料來源 protected virtual Boolean WfIniMaster() { try { // 以 FormID 由 Pu_pgm 中取得表單設定 #region 初始化 PU_BUSOBJ if (GlobalVar.PU_BUSOBJ != null) { this.BoSecurity = (YR.ERP.BLL.MSSQL.AdmBLL)GlobalVar.PU_BUSOBJ; } else { if (GlobalVar.Adm_DAO != null) { this.BoSecurity = new AdmBLL((YR.ERP.DAL.ERP_MSSQLDAL)GlobalVar.Adm_DAO); } else { //this.BoSecurity = new AdmBLL(); } } #endregion if (BoSecurity == null) { return(false); } this.AdoModel = BoSecurity.OfGetAdoModel(StrFormID); if (AdoModel == null) { return(false); } this.TabMaster.TargetTable = AdoModel.ado05; this.TabMaster.TargetColumn = "*"; this.TabMaster.ViewTable = AdoModel.ado06; if (TabMaster.ViewTable == "") { TabMaster.ViewTable = TabMaster.TargetTable; } if (BoSecurity == null) { throw new Exception("物件BoSecurity,尚未初始化!"); //return false; } this.TabMaster.AzaTbList = BoSecurity.OfGetAzaModels(TabMaster.ViewTable); this.TabMaster.AddTbModel = BoSecurity.OfGetAddModel(LoginInfo.UserRole, StrFormID); // 建立 Form Master 的 Business Object : boBasic this.WfCreateBoBasic(); //取得baa_tb共用參數代碼 if (BaaModel == null) { using (var boBas = new BasBLL(BoMaster.OfGetConntion())) { if (BoMaster.TRAN != null) { boBas.TRAN = BoMaster.TRAN; } BaaModel = boBas.OfGetBaaModel(); } } #region 取得日期格式 var baa01KvpList = new BasBLL().OfGetBaa01KVPList();//取得日期格式 this.DateFormat = baa01KvpList.Where(x => x.Key == BaaModel.baa01) .Select(x => x.Value) .FirstOrDefault() ; if (GlobalFn.varIsNull(DateFormat)) { DateFormat = "yyyy/MM/dd"; } else //取得格式會含有 . ex:1.yyyy/MM/dd 要剔除 { if (DateFormat.IndexOf('.') >= 0) { var dotPosition = DateFormat.IndexOf('.'); DateFormat = DateFormat.Substring(dotPosition + 1, DateFormat.Length - dotPosition - 1); } } #endregion // 先取得空的資料表 if (this.TabMaster.ViewTable != "") { this.TabMaster.DtSource = this.TabMaster.BoBasic.OfSelect(" WHERE 1=2 "); TabMaster.DtSource.Rows.Add(TabMaster.DtSource.NewRow()); this.WfSetMasterDatasource(this.TabMaster.DtSource); this.BindingMaster.MoveFirst(); DrMaster = TabMaster.DtSource.Rows[0]; WfSetMasterRowDefault(DrMaster); } } catch (Exception ex) { throw ex; } return(true); }