private bool OfDeleteRelation(vw_glab321 pModel, Result pResult) { string deleteSql = ""; List <SqlParameter> sqlParmList = null; int nextYear = 0; //DateTime startDate, endDate; try { nextYear = (new DateTime(Convert.ToInt16(pModel.gfa08), 1, 1)).AddYears(1).Year; //刪除會科各期餘額檔 下期期初資料 deleteSql = "DELETE FROM gbh_tb WHERE gbh02=@gbh02 AND gbh03=0"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbh02", nextYear)); OfExecuteNonquery(deleteSql, sqlParmList.ToArray()); //刪除部門各期餘額檔 deleteSql = "DELETE FROM gbj_tb WHERE gbj03=@gbj03 AND gbj04=0"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbj03", nextYear)); OfExecuteNonquery(deleteSql, sqlParmList.ToArray()); return(true); } catch (Exception ex) { pResult.Message = "刪除年結相關資料失敗!"; pResult.Exception = ex; return(false); } }
public Result OfGlab321Post(vw_glab321 pModel, UserInfo pLoginInfo) { Result rtnResult = null; try { _loginInfo = pLoginInfo; rtnResult = new Result(); if (OfDeleteRelation(pModel, rtnResult) == false) { return(rtnResult); } if (OfPostGbh(pModel, rtnResult) == false) { return(rtnResult); } if (OfPostGbj(pModel, rtnResult) == false) { return(rtnResult); } return(rtnResult); } catch (Exception ex) { throw ex; } }
protected override bool WfFormCheck() { vw_glab321 masterModel = null; string msg = ""; try { masterModel = DrMaster.ToItem <vw_glab321>(); if (GlobalFn.varIsNull(masterModel.gfa08)) { msg = "會計年度不可為空白!"; WfShowErrorMsg(msg); errorProvider.SetError(ute_gfa08, msg); return(false); } return(true); } catch (Exception ex) { 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; } }
private bool OfPostGbj(vw_glab321 pModel, Result pResult) { DataTable dtGbjSum = null; string selectSql = ""; List <SqlParameter> sqlParmList = null; int nextYear = 0, chkCnts = 0; GlaBLL boGbh = null; DataTable dtGbjNext = null; try { nextYear = (new DateTime(Convert.ToInt16(pModel.gfa08), 1, 1)).AddYears(1).Year; //過帳會科部門各期餘額檔 下期期初資料 selectSql = @"SELECT gbj01,gbj02, SUM(gbj05) AS gbj05, SUM(gbj06) AS gbj06 FROM gbj_tb WHERE gbj03=@gbj03 AND gbj04<>4 GROUP BY gbj01,gbj02 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbj03", pModel.gfa08)); dtGbjSum = OfGetDataTable(selectSql, sqlParmList.ToArray()); if (dtGbjSum == null || dtGbjSum.Rows.Count == 0) { pResult.Message = "取得部門各期餘額加總失敗!"; return(false); } boGbh = new GlaBLL(OfGetConntion()); boGbh.TRAN = this.TRAN; boGbh.OfCreateDao("gbj_tb", "*", ""); selectSql = @"SELECT * FROM gbj_tb WHERE gbj01=@gbj01 AND gbj02=@gbj02 AND gbj03=@gbj03 AND gbj04=@gbj04"; foreach (DataRow drGbjSum in dtGbjSum.Rows) { var gbjSumModel = drGbjSum.ToItem <gbj_tb>(true); sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbj01", gbjSumModel.gbj01)); sqlParmList.Add(new SqlParameter("@gbj02", gbjSumModel.gbj02)); sqlParmList.Add(new SqlParameter("@gbj03", nextYear)); sqlParmList.Add(new SqlParameter("@gbj04", 0)); dtGbjNext = boGbh.OfGetDataTable(selectSql, sqlParmList.ToArray()); if (dtGbjNext.Rows.Count == 0) { var drGbhNext = dtGbjNext.NewRow(); drGbhNext["gbj01"] = gbjSumModel.gbj01; drGbhNext["gbj02"] = gbjSumModel.gbj02; drGbhNext["gbj03"] = nextYear; drGbhNext["gbj04"] = 0; drGbhNext["gbj05"] = gbjSumModel.gbj05; drGbhNext["gbj06"] = gbjSumModel.gbj06; drGbhNext["gbj07"] = 0; drGbhNext["gbj08"] = 0; drGbhNext["gbjcomp"] = _loginInfo.CompNo; dtGbjNext.Rows.Add(drGbhNext); } else { var drGbhNext = dtGbjNext.Rows[0]; drGbhNext["gbj05"] = gbjSumModel.gbj05; drGbhNext["gbj06"] = gbjSumModel.gbj06; drGbhNext["gbj07"] = 0; drGbhNext["gbj08"] = 0; } chkCnts = boGbh.OfUpdate(dtGbjNext); if (chkCnts != 1) { pResult.Message = "更新年結相關資料(部門餘額)失敗!"; return(false); } } pResult.Success = true; return(true); } catch (Exception ex) { pResult.Message = "更新年結相關資料(部門餘額)失敗!"; pResult.Exception = ex; return(false); } }