protected override bool WfFormCheck() { vw_glab311 masterModel = null; string msg = ""; try { masterModel = DrMaster.ToItem <vw_glab311>(); if (GlobalFn.varIsNull(masterModel.gfa02_s)) { msg = "傳票起日不可為空白!"; WfShowErrorMsg(msg); errorProvider.SetError(udt_gfa02_s, msg); return(false); } if (GlobalFn.varIsNull(masterModel.gfa02_s)) { msg = "傳票迄日不可為空白!"; WfShowErrorMsg(msg); errorProvider.SetError(udt_gfa02_e, msg); return(false); } return(true); } catch (Exception ex) { throw ex; } }
protected override bool WfExecute() { vw_glab311 masterModel = null; int chkCnts = 0; StringBuilder sbResult = null; try { //取得交易物件 BoMaster.TRAN = BoMaster.OfGetConntion().BeginTransaction(); BoGlab311.TRAN = BoMaster.TRAN; masterModel = DrMaster.ToItem <vw_glab311>(); var securityString = WfGetSecurityString(); var resultList = BoGlab311.OfGlab311Post(masterModel, "N", securityString, "", LoginInfo); if (resultList == null || resultList.Count == 0) { BoGlab311.TRAN.Rollback(); WfShowBottomStatusMsg("無可過帳資料!"); 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; } }
/// <summary> /// 刪除此會計期間內的相關內容 /// 1.會計期間餘額檔 gbh_tb /// 2.每日餘額檔 gbi_tb /// 3.部門餘額檔 gbj_tb /// </summary> /// <param name="glab311Model"></param> /// <returns></returns> private bool WfUpdatePostRelation(vw_glab311 glab311Model, vw_glab312 glab312Model) { string updateSql = ""; List <SqlParameter> sqlParmList = null; try { //更新會計期間餘額檔 updateSql = @"UPDATE gbh_tb SET gbh04=0,gbh05=0,gbh06=0,gbh07=0 WHERE gbh02=@gbh02 AND gbh03=@gbh03 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbh02", glab312Model.gfa08)); sqlParmList.Add(new SqlParameter("@gbh03", glab312Model.gfa09)); BoGlab311.OfExecuteNonquery(updateSql, sqlParmList.ToArray()); //更新每日餘額檔 updateSql = @"UPDATE gbi_tb SET gbi03=0,gbi04=0,gbi05=0,gbi06=0 WHERE gbi02 between @gbi02_s AND @gbi02_e "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbi02_s", glab311Model.gfa02_s)); sqlParmList.Add(new SqlParameter("@gbi02_e", glab311Model.gfa02_e)); BoGlab311.OfExecuteNonquery(updateSql, sqlParmList.ToArray()); //更新部門餘額檔 updateSql = @"UPDATE gbj_tb SET gbj05=0,gbj06=0,gbj07=0,gbj08=0 WHERE gbj03=@gbj03 AND gbj04=@gbj04 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbj03", glab312Model.gfa08)); sqlParmList.Add(new SqlParameter("@gbj04", glab312Model.gfa09)); BoGlab311.OfExecuteNonquery(updateSql, sqlParmList.ToArray()); return(true); } catch (Exception ex) { 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; } }
/// <summary> /// 過帳及重過帳共用程式 /// </summary> /// <param name="pModel"></param> /// <param name="pPost"></param> /// <returns></returns> public List <Result> OfGlab311Post(vw_glab311 pModel, string pPost, string pSecurityString, string pSrcFormId, UserInfo pLoginInfo) { List <Result> rtnResultList = null; string selectSql = ""; string strQueryRange = "", strQuerySingle = ""; List <SqlParameter> sqlParmList = null; DataTable dtGfa = null; List <QueryInfo> queryInfoList; QueryInfo queryModel; gfa_tb gfaModel; try { _loginInfo = pLoginInfo; selectSql = @" SELECT * FROM gfa_tb WHERE gfaconf='Y' "; selectSql += string.Format(" AND gfapost='{0}'", pPost); sqlParmList = new List <SqlParameter>(); queryInfoList = new List <QueryInfo>(); #region range 處理 if (!GlobalFn.varIsNull(pModel.gfa01)) { queryModel = new QueryInfo(); queryModel.TableName = "gfa_tb"; queryModel.ColumnName = "gfa01"; queryModel.ColumnType = "string"; queryModel.Value = pModel.gfa01; queryInfoList.Add(queryModel); } sqlParmList = new List <SqlParameter>(); strQueryRange = WfGetQueryString(queryInfoList, out sqlParmList); #endregion #region single處理 if (!GlobalFn.varIsNull(pModel.gfa02_s)) { sqlParmList.Add(new SqlParameter("@gfa02_s", pModel.gfa02_s)); strQuerySingle += string.Format(" AND gfa02>=@gfa02_s"); } if (!GlobalFn.varIsNull(pModel.gfa02_e)) { sqlParmList.Add(new SqlParameter("@gfa02_e", pModel.gfa02_e)); strQuerySingle += string.Format(" AND gfa02<=@gfa02_e"); } #endregion selectSql = string.Concat(selectSql, strQueryRange, strQuerySingle, pSecurityString); //加入權限處理 dtGfa = OfGetDataTable(selectSql, sqlParmList.ToArray()); if (dtGfa == null || dtGfa.Rows.Count == 0) { return(null); } rtnResultList = new List <Result>(); foreach (DataRow drGfa in dtGfa.Rows) { gfaModel = drGfa.ToItem <gfa_tb>(); var result = new Result(); rtnResultList.Add(result); if (gfaModel.gfa03 != gfaModel.gfa04) { result.Key1 = gfaModel.gfa01; result.Message = "借貸不平衡!"; continue; } if (pPost == "N") //重過帳不修改傳票單頭 { if (OfPostGfa(gfaModel) == false) { result.Key1 = gfaModel.gfa01; result.Message = "更新gfa_tb失敗!"; continue; } } if (OfPostGfb(gfaModel, result) == false) { continue; } result.Success = true; } return(rtnResultList); } catch (Exception ex) { throw ex; } }