private bool OfPostGfb(gfa_tb pGfaModel, Result pResult) { DataTable dtGfb = null; gfb_tb gfbModel = null; gba_tb gbaModel = null; string selectSql = ""; List <SqlParameter> sqlParmList = null; try { selectSql = @"SELECT * FROM gfb_tb WHERE gfb01=@gfb01"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gfb01", pGfaModel.gfa01)); dtGfb = OfGetDataTable(selectSql, sqlParmList.ToArray()); if (dtGfb == null && dtGfb.Rows.Count == 0) { return(true); } foreach (DataRow drGfb in dtGfb.Rows) { gfbModel = drGfb.ToItem <gfb_tb>(); gbaModel = OfGetGbaModel(gfbModel.gfb03); if (gfbModel == null) { pResult.Key1 = string.Concat(gfbModel.gfb01, "/", gfbModel.gfb02); pResult.Message = "查無此項次,會科資料!"; return(false); } //更新會計科目每期餘額檔 if (OfPostGbh(pGfaModel, gfbModel, gbaModel, pResult) == false) { return(false); } //更新會計科目每日餘額檔 if (OfPostGbi(pGfaModel, gfbModel, gbaModel, pResult) == false) { return(false); } //更新部門各期餘額檔 if (OfPostGbj(pGfaModel, gfbModel, gbaModel, pResult) == false) { return(false); } } return(true); } catch (Exception ex) { throw ex; } }
public gba_tb OfGetGbaModel(string pGba01) { DataRow drGba = null; gba_tb rtnModel = null; try { drGba = OfGetGbaDr(pGba01); if (drGba == null) { return(null); } rtnModel = drGba.ToItem <gba_tb>(); return(rtnModel); } catch (Exception ex) { throw ex; } }
//回傳值 true.通過驗證 false.未通過驗證,會把值還原 protected override bool WfItemCheck(object sender, ItemCheckInfo e) { int chkCnts = 0; vw_glai110 masterModel = null; vw_glai110s detailModel = null; List <vw_glai110s> detailList = null; gba_tb gbaModel = null; UltraGrid uGrid = null; UltraGridRow uGridRow = null; string sqlSelect = ""; List <SqlParameter> sqlParmList = null; try { masterModel = DrMaster.ToItem <vw_glai110>(); if (e.Column.ToLower() != "gbd01" && GlobalFn.isNullRet(DrMaster["gbd01"], "") == "") { WfShowErrorMsg("請先輸入上層部門!"); return(false); } #region 單頭-vw_glai110 if (e.Row.Table.Prefix.ToLower() == "vw_glai110") { switch (e.Column.ToLower()) { case "gbd01": if (GlobalFn.isNullRet(e.Value, "") == "") { e.Row["gbd01_c"] = ""; return(true); } var babModel = BoBas.OfGetBebModel(e.Value.ToString()); if (babModel == null) { WfShowErrorMsg("無此上層部門,請檢核!"); return(false); } if (babModel.bebvali != "Y") { WfShowErrorMsg("此上層部門已失效,請檢核!"); return(false); } if (WfChkGbd01Exists(e.Value.ToString()) == true) { WfShowErrorMsg("此上層部門已存在,請檢核!"); return(false); } e.Row["gbd01_c"] = babModel.beb03; break; } } #endregion #region 單身-vw_glai110s if (e.Row.Table.Prefix.ToLower() == "vw_glai110s") { uGrid = sender as UltraGrid; uGridRow = uGrid.ActiveRow; detailModel = e.Row.ToItem <vw_glai110s>(); detailList = e.Row.Table.ToList <vw_glai110s>(); switch (e.Column.ToLower()) { case "gbd02": if (GlobalFn.isNullRet(e.Value, "") == "") { e.Row["gbd02_c"] = ""; return(true); } var babModel = BoBas.OfGetBebModel(e.Value.ToString()); if (babModel == null) { WfShowErrorMsg("無此下層部門,請檢核!"); return(false); } if (babModel.bebvali != "Y") { WfShowErrorMsg("此下層部門已失效,請檢核!"); return(false); } if (masterModel.gbd01.ToUpper() == e.Value.ToString().ToUpper()) { WfShowErrorMsg("不可與上層部門相同,請檢核!"); return(false); } chkCnts = detailList.Where(p => p.gbd02.ToUpper() == e.Value.ToString().ToUpper()).Count(); if (chkCnts > 1) { WfShowErrorMsg("下層部門不可重覆,請檢核!"); return(false); } sqlSelect = "SELECT COUNT(1) FROM gbd_tb WHERE gbd02=@gbd02 AND gbd01<>@gbd01"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbd01", masterModel.gbd01)); sqlParmList.Add(new SqlParameter("@gbd02", e.Value.ToString())); chkCnts = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0); if (chkCnts > 0) { WfShowErrorMsg("此下層部門已隸屬於其他上層部門,請檢核!"); return(false); } e.Row["gbd02_c"] = babModel.beb03; break; } } #endregion return(true); } catch (Exception ex) { throw ex; } }
private bool OfPostGbj(gfa_tb pGfaModel, gfb_tb pGfbModel, gba_tb pGbaModel, Result pResult) { string selectSql = ""; List <SqlParameter> sqlParmList = null; decimal dAmt = 0, cAmt = 0, dRec = 0, cRec = 0; GlaBLL boGbj = null; DataTable dtGbj = null; DataRow drGbj = null; try { if (pGbaModel.gba09 != "Y") { return(true); } boGbj = new GlaBLL(OfGetConntion()); boGbj.TRAN = this.TRAN; boGbj.OfCreateDao("gbj_tb", "*", ""); selectSql = @"SELECT * FROM gbj_tb WHERE gbj01=@gbj01 AND gbj02=@gbj02 AND gbj03=@gbj03 AND gbj04=@gbj04"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbj01", pGfbModel.gfb03)); sqlParmList.Add(new SqlParameter("@gbj02", pGfbModel.gfb05)); sqlParmList.Add(new SqlParameter("@gbj03", pGfaModel.gfa08)); sqlParmList.Add(new SqlParameter("@gbj04", pGfaModel.gfa09)); dtGbj = boGbj.OfGetDataTable(selectSql, sqlParmList.ToArray()); if (pGfbModel.gfb06 == "1") { dAmt = pGfbModel.gfb07; dRec = 1; } else { cAmt = pGfbModel.gfb07; cRec = 1; } if (dtGbj.Rows.Count == 0) { drGbj = dtGbj.NewRow(); drGbj["gbj01"] = pGfbModel.gfb03; drGbj["gbj02"] = pGfbModel.gfb05; drGbj["gbj03"] = pGfaModel.gfa08; drGbj["gbj04"] = pGfaModel.gfa09; drGbj["gbj05"] = dAmt; drGbj["gbj06"] = cAmt; drGbj["gbj07"] = dRec; drGbj["gbj08"] = cRec; drGbj["gbjcomp"] = _loginInfo.CompNo; dtGbj.Rows.Add(drGbj); } else { drGbj = dtGbj.Rows[0]; drGbj["gbj05"] = Convert.ToDecimal(drGbj["gbj05"]) + dAmt; drGbj["gbj06"] = Convert.ToDecimal(drGbj["gbj06"]) + cAmt; drGbj["gbj07"] = Convert.ToDecimal(drGbj["gbj07"]) + dRec; drGbj["gbj08"] = Convert.ToDecimal(drGbj["gbj08"]) + cRec; } if (boGbj.OfUpdate(dtGbj) != 1) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新部門各期餘額檔(gbj_tb)失敗!"; return(false); } //需遞迴處理上層部門 selectSql = "SELECT * FROM gbd_tb WHERE gbd02=@gbd02"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbd02", pGfbModel.gfb05)); var dtGbd = OfGetDataTable(selectSql, sqlParmList.ToArray()); if (dtGbd == null || dtGbd.Rows.Count == 0) { return(true); } if (dtGbd.Rows.Count > 1) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新部門餘額檔,有多個上層部門異常!"; return(false); } var gbdModel = dtGbd.Rows[0].ToItem <gbd_tb>(); if (OfPostGbjRecursive(gbdModel.gbd01, pGfaModel, pGfbModel, dAmt, cAmt, dRec, cRec, pResult) == false) { return(false); } return(true); } catch (Exception ex) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新部門各期餘額檔(gbj_tb)失敗!"; pResult.Exception = ex; return(false); } }
private bool OfPostGbi(gfa_tb pGfaModel, gfb_tb pGfbModel, gba_tb pGbaModel, Result pResult) { string selectSql = "", updateSql = "", insertSql = ""; List <SqlParameter> sqlParmList = null; decimal dAmt = 0, cAmt = 0, dRec = 0, cRec = 0; GlaBLL boGbi = null; DataTable dtGbi = null; DataRow drGbi = null; try { boGbi = new GlaBLL(OfGetConntion()); boGbi.TRAN = this.TRAN; boGbi.OfCreateDao("gbi_tb", "*", ""); selectSql = @"SELECT * FROM gbi_tb WHERE gbi01=@gbi01 AND gbi02=@gbi02"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbi01", pGfbModel.gfb03)); sqlParmList.Add(new SqlParameter("@gbi02", pGfaModel.gfa02)); dtGbi = boGbi.OfGetDataTable(selectSql, sqlParmList.ToArray()); if (pGfbModel.gfb06 == "1") { dAmt = pGfbModel.gfb07; dRec = 1; } else { cAmt = pGfbModel.gfb07; cRec = 1; } if (dtGbi.Rows.Count == 0) { drGbi = dtGbi.NewRow(); drGbi["gbi01"] = pGfbModel.gfb03; drGbi["gbi02"] = pGfaModel.gfa02; drGbi["gbi03"] = dAmt; drGbi["gbi04"] = cAmt; drGbi["gbi05"] = dRec; drGbi["gbi06"] = cRec; drGbi["gbicomp"] = _loginInfo.CompNo; dtGbi.Rows.Add(drGbi); } else { drGbi = dtGbi.Rows[0]; drGbi["gbi03"] = Convert.ToDecimal(drGbi["gbi03"]) + dAmt; drGbi["gbi04"] = Convert.ToDecimal(drGbi["gbi04"]) + cAmt; drGbi["gbi05"] = Convert.ToDecimal(drGbi["gbi05"]) + dRec; drGbi["gbi06"] = Convert.ToDecimal(drGbi["gbi06"]) + cRec; } if (boGbi.OfUpdate(dtGbi) != 1) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新會科各期餘額檔(gbi_tb)失敗!"; return(false); } //明細科目,需遞迴處理統制科目 if (pGbaModel.gba06 == "2") { if (OfPostGbiRecursive(pGbaModel.gba07, pGfaModel, pGfbModel, dAmt, cAmt, dRec, cRec, pResult) == false) { return(false); } } return(true); } catch (Exception ex) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新會科每日餘額檔(gbi_tb)失敗!"; pResult.Exception = ex; return(false); } }
private bool OfPostGbh(gfa_tb pGfaModel, gfb_tb pGfbModel, gba_tb pGbaModel, Result pResult) { string selectSql = ""; List <SqlParameter> sqlParmList = null; decimal dAmt = 0, cAmt = 0, dRec = 0, cRec = 0; GlaBLL boGbh = null; DataTable dtGbh = null; DataRow drGbh = null; try { boGbh = new GlaBLL(OfGetConntion()); boGbh.TRAN = this.TRAN; boGbh.OfCreateDao("gbh_tb", "*", ""); selectSql = @"SELECT * FROM gbh_tb WHERE gbh01=@gbh01 AND gbh02=@gbh02 AND gbh03=@gbh03"; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gbh01", pGfbModel.gfb03)); sqlParmList.Add(new SqlParameter("@gbh02", pGfaModel.gfa08)); sqlParmList.Add(new SqlParameter("@gbh03", pGfaModel.gfa09)); dtGbh = boGbh.OfGetDataTable(selectSql, sqlParmList.ToArray()); if (pGfbModel.gfb06 == "1") { dAmt = pGfbModel.gfb07; dRec = 1; } else { cAmt = pGfbModel.gfb07; cRec = 1; } if (dtGbh.Rows.Count == 0) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新會科各期餘額檔(gbh_tb)失敗!查無該期會科餘額檔!"; return(false); } else { drGbh = dtGbh.Rows[0]; drGbh["gbh04"] = Convert.ToDecimal(drGbh["gbh04"]) - dAmt; drGbh["gbh05"] = Convert.ToDecimal(drGbh["gbh05"]) - cAmt; drGbh["gbh06"] = Convert.ToDecimal(drGbh["gbh06"]) - dRec; drGbh["gbh07"] = Convert.ToDecimal(drGbh["gbh07"]) - cRec; } if (boGbh.OfUpdate(dtGbh) != 1) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新會科各期餘額檔(gbh_tb)失敗!"; return(false); } //明細科目,需遞迴處理統制科目 if (pGbaModel.gba06 == "2") { if (OfPostGbhRecursive(pGbaModel.gba07, pGfaModel, pGfbModel, dAmt, cAmt, dRec, cRec, pResult) == false) { return(false); } } return(true); } catch (Exception ex) { pResult.Key1 = string.Concat(pGfbModel.gfb01, "/", pGfbModel.gfb02); pResult.Message = "更新會科各期餘額檔(gbh_tb)失敗!"; pResult.Exception = ex; return(false); } }
public List <Result> OfGenGeaByCea(string pCea01, UserInfo pLoginInfo) { List <Result> rtnResultList = null; Result result = null; cea_tb ceaModel = null; List <ceb_tb> cebList = null; string sqlSelect = ""; List <SqlParameter> sqlParmList = null; CarBLL boCar = null; StpBLL boStp = null; BasBLL boBas = null; DataTable dtGea = null, dtGeb = null; DataRow drGea = null, drGeb = null; decimal gea08 = 0, gea09 = 0; int i; baa_tb baaModel = null; gba_tb gbaModel = null; cba_tb cbaModel = null; try { rtnResultList = new List <Result>(); boBas = new BasBLL(this.OfGetConntion()); boBas.TRAN = this.TRAN; boCar = new CarBLL(this.OfGetConntion()); boCar.TRAN = this.TRAN; boStp = new StpBLL(this.OfGetConntion()); boStp.TRAN = this.TRAN; baaModel = boBas.OfGetBaaModel(); if (baaModel == null || GlobalFn.varIsNull(baaModel.baa04)) { result = new Result(); result.Key1 = pCea01; result.Message = "查無本國幣別!"; rtnResultList.Add(result); return(rtnResultList); } ceaModel = boCar.OfGetCeaModel(pCea01); if (ceaModel == null) { result = new Result(); result.Key1 = pCea01; result.Message = "查無此應收單號!"; rtnResultList.Add(result); return(rtnResultList); } if (ceaModel.ceaconf != "N") { result = new Result(); result.Key1 = pCea01; result.Message = "應收帳款非未確認狀態!"; rtnResultList.Add(result); return(rtnResultList); } cbaModel = boCar.OfGetCbaModel(ceaModel.cea21); if (cbaModel == null) { result = new Result(); result.Key1 = pCea01; result.Message = "查無應收科目類別資料!"; rtnResultList.Add(result); return(rtnResultList); } if (GlobalFn.varIsNull(cbaModel.cba05)) { result = new Result(); result.Key1 = pCea01; result.Message = "查無銷項稅額科目!"; rtnResultList.Add(result); return(rtnResultList); } cebList = boCar.OfGetCebList(pCea01); if (cebList == null || cebList.Count == 0) { result = new Result(); result.Key1 = pCea01; result.Message = "應收帳款無單身資料!"; rtnResultList.Add(result); return(rtnResultList); } //新增底稿單頭 this.OfCreateDao("gea_tb", "*", ""); sqlSelect = "SELECT * FROM gea_tb WHERE 1<>1 "; dtGea = this.OfGetDataTable(sqlSelect); drGea = dtGea.NewRow(); drGea["gea01"] = ceaModel.cea01; //底稿單號 drGea["gea02"] = "AR"; //系統別 drGea["gea03"] = 1; //1.應收 2.收款 drGea["gea04"] = 1; //AR 固定為1 drGea["gea05"] = ceaModel.cea02; //同帳款日期 drGea["gea06"] = DBNull.Value; //傳票號碼 drGea["gea07"] = DBNull.Value; //傳票日期 drGea["gea08"] = ceaModel.cea15t; //借方金額 var ceb09t_tot = cebList.Sum(p => p.ceb09t); drGea["gea09"] = ceb09t_tot; //貸方金額 drGea["gea10"] = DBNull.Value; //保留 drGea["gea11"] = DBNull.Value; //保留 drGea["gea12"] = DBNull.Value; //保留 drGea["geaprno"] = 0; drGea["geacomp"] = pLoginInfo.CompNo; drGea["geacreu"] = pLoginInfo.UserNo; drGea["geacreg"] = pLoginInfo.DeptNo; drGea["geacred"] = OfGetNow(); drGea["geamodu"] = DBNull.Value; drGea["geamodg"] = DBNull.Value; drGea["geamodd"] = DBNull.Value; drGea["geasecu"] = pLoginInfo.UserNo; drGea["geasecg"] = pLoginInfo.GroupNo; dtGea.Rows.Add(drGea); if (this.OfUpdate(dtGea) == -1) { result = new Result(); result.Key1 = pCea01; result.Message = "新增分錄底稿單頭失敗!"; rtnResultList.Add(result); return(rtnResultList); } //新增底稿單身 this.OfCreateDao("geb_tb", "*", ""); sqlSelect = "SELECT * FROM geb_tb WHERE 1<>1 "; dtGeb = this.OfGetDataTable(sqlSelect); //借方帶單頭應收帳款 //用本幣匯總成一筆來加總 drGeb = dtGeb.NewRow(); i = 1; drGeb = dtGeb.NewRow(); drGeb["geb01"] = ceaModel.cea01; //底稿單頭 drGeb["geb02"] = "AR"; drGeb["geb03"] = 1; //1.應收 2.收款 drGeb["geb04"] = 1; //AR 固定為1 drGeb["geb05"] = i; //項次 drGeb["geb06"] = ceaModel.cea22; //會計科目-待補入 drGeb["geb07"] = ""; //摘要 drGeb["geb08"] = DBNull.Value; //部門 if (!GlobalFn.varIsNull(ceaModel.cea22)) { gbaModel = OfGetGbaModel(ceaModel.cea22); if (gbaModel != null && gbaModel.gba09 == "Y") { drGeb["geb08"] = ceaModel.cea05; } } drGeb["geb09"] = 1; //借貸 1.借 2.貸 drGeb["geb10"] = ceaModel.cea15t; //本幣金額(稅) //幣別均以本幣處理 drGeb["geb11"] = baaModel.baa04; //原幣幣別(帶入本幣幣別) drGeb["geb12"] = ceaModel.cea12; //匯率 drGeb["geb13"] = ceaModel.cea15t; //原幣金額(稅) drGeb["geb14"] = ceaModel.cea03; //客戶編號 drGeb["geb15"] = boStp.OfGetSca03(ceaModel.cea03); //客戶簡稱 drGeb["geb16"] = DBNull.Value; //保留 drGeb["geb17"] = DBNull.Value; //保留 drGeb["geb18"] = DBNull.Value; //保留 drGeb["geb19"] = DBNull.Value; //保留 drGeb["geb20"] = DBNull.Value; //保留 drGeb["geb21"] = DBNull.Value; //保留 drGeb["gebcomp"] = pLoginInfo.CompNo; drGeb["gebcreu"] = pLoginInfo.UserNo; drGeb["gebcreg"] = pLoginInfo.DeptNo; drGeb["gebcred"] = OfGetNow(); drGeb["gebmodu"] = DBNull.Value; drGeb["gebmodg"] = DBNull.Value; drGeb["gebmodd"] = DBNull.Value; dtGeb.Rows.Add(drGeb); //處理貸方未稅明細資料 foreach (ceb_tb cebModel in cebList) { i++; drGeb = dtGeb.NewRow(); drGeb["geb01"] = cebModel.ceb01; //底稿單頭 drGeb["geb02"] = "AR"; drGeb["geb03"] = 1; //1.應收 2.收款 drGeb["geb04"] = 1; //AR 固定為1 drGeb["geb05"] = i; //項次 drGeb["geb06"] = cebModel.ceb10; //會計科目 drGeb["geb07"] = ""; //摘要 drGeb["geb08"] = DBNull.Value; //部門 if (!GlobalFn.varIsNull(cebModel.ceb10)) { gbaModel = OfGetGbaModel(cebModel.ceb10); if (gbaModel != null && gbaModel.gba09 == "Y") { drGeb["geb08"] = ceaModel.cea05; } } drGeb["geb09"] = 2; //借貸 1.借 2.貸 drGeb["geb10"] = cebModel.ceb09; //本幣金額(未稅) drGeb["geb11"] = ceaModel.cea10; //原幣幣別 drGeb["geb12"] = ceaModel.cea12; //匯率 drGeb["geb13"] = cebModel.ceb07; //原幣金額 drGeb["geb14"] = ceaModel.cea03; //客戶編號 drGeb["geb15"] = boStp.OfGetSca03(ceaModel.cea03); //客戶簡稱 drGeb["geb16"] = DBNull.Value; //保留 drGeb["geb17"] = DBNull.Value; //保留 drGeb["geb18"] = DBNull.Value; //保留 drGeb["geb19"] = DBNull.Value; //保留 drGeb["geb20"] = DBNull.Value; //保留 drGeb["geb21"] = DBNull.Value; //保留 drGeb["gebcomp"] = pLoginInfo.CompNo; drGeb["gebcreu"] = pLoginInfo.UserNo; drGeb["gebcreg"] = pLoginInfo.DeptNo; drGeb["gebcred"] = OfGetNow(); drGeb["gebmodu"] = DBNull.Value; drGeb["gebmodg"] = DBNull.Value; drGeb["gebmodd"] = DBNull.Value; dtGeb.Rows.Add(drGeb); } //貸方再補一筆稅額 //用本幣匯總成一筆來加總 drGeb = dtGeb.NewRow(); i++; drGeb = dtGeb.NewRow(); drGeb["geb01"] = ceaModel.cea01; //底稿單頭 drGeb["geb02"] = "AR"; drGeb["geb03"] = 1; //1.應收 2.收款 drGeb["geb04"] = 1; //AR 固定為1 drGeb["geb05"] = i; //項次 drGeb["geb06"] = cbaModel.cba05; //會計科目 drGeb["geb07"] = ""; //摘要 drGeb["geb08"] = DBNull.Value; //部門 if (!GlobalFn.varIsNull(cbaModel.cba05)) { gbaModel = OfGetGbaModel(cbaModel.cba05); if (gbaModel != null && gbaModel.gba09 == "Y") { drGeb["geb08"] = ceaModel.cea05; } } drGeb["geb09"] = 2; //借貸 1.借 2.貸 var taxTotal = cebList.Sum(x => x.ceb09t - x.ceb09); drGeb["geb10"] = taxTotal; //本幣金額(稅) //幣別均以本幣處理 drGeb["geb11"] = baaModel.baa04; //原幣幣別(帶入本幣幣別) drGeb["geb12"] = ceaModel.cea12; //匯率 drGeb["geb13"] = taxTotal; //原幣金額(稅) drGeb["geb14"] = ceaModel.cea03; //客戶編號 drGeb["geb15"] = boStp.OfGetSca03(ceaModel.cea03); //客戶簡稱 drGeb["geb16"] = DBNull.Value; //保留 drGeb["geb17"] = DBNull.Value; //保留 drGeb["geb18"] = DBNull.Value; //保留 drGeb["geb19"] = DBNull.Value; //保留 drGeb["geb20"] = DBNull.Value; //保留 drGeb["geb21"] = DBNull.Value; //保留 drGeb["gebcomp"] = pLoginInfo.CompNo; drGeb["gebcreu"] = pLoginInfo.UserNo; drGeb["gebcreg"] = pLoginInfo.DeptNo; drGeb["gebcred"] = OfGetNow(); drGeb["gebmodu"] = DBNull.Value; drGeb["gebmodg"] = DBNull.Value; drGeb["gebmodd"] = DBNull.Value; dtGeb.Rows.Add(drGeb); if (this.OfUpdate(dtGeb) == -1) { result = new Result(); result.Key1 = pCea01; result.Message = "新增分錄底稿單身失敗!"; rtnResultList.Add(result); return(rtnResultList); } return(rtnResultList); } catch (Exception ex) { throw ex; } }
//回傳值 true.通過驗證 false.未通過驗證,會把值還原 protected override bool WfItemCheck(object sender, ItemCheckInfo e) { int iChkCnts = 0; vw_glat300_1 masterModel = null; vw_glat300_1s detailModel = null; List <vw_glat300_1s> detailList = null; gba_tb gbaModel = null; UltraGrid uGrid = null; UltraGridRow uGridRow = null; int ChkCnts = 0; string sql = ""; List <SqlParameter> sqlParmList = null; try { masterModel = DrMaster.ToItem <vw_glat300_1>(); #region 單身-vw_glat300_1s if (e.Row.Table.Prefix.ToLower() == "vw_glat300_1s") { uGrid = sender as UltraGrid; uGridRow = uGrid.ActiveRow; detailModel = e.Row.ToItem <vw_glat300_1s>(); detailList = e.Row.Table.ToList <vw_glat300_1s>(); var bb = TabDetailList[0].DtSource.ToList <vw_glat300_1s>(); switch (e.Column.ToLower()) { case "is_pick": //項次 e.Row["gfh09"] = 0; if (e.Value.ToString() == "Y") { WfSetControlReadonly(uGridRow.Cells["gfh09"], false); } else { WfSetControlReadonly(uGridRow.Cells["gfh09"], true); WfSetSumGfb09(); } break; case "gfh09": //沖帳金額 if (GlobalFn.varIsNull(e.Value)) { WfShowErrorMsg("請輸入數字!"); return(false); } if (GlobalFn.isNullRet(e.Value, 0) < 0) { WfShowErrorMsg("金額不可小於0!"); return(false); } var sumGfh09 = detailList.Where(p => p.is_pick == "Y" && p.gfh09 >= 0) .Sum(p => p.gfh09); if (masterModel.gfb07 < sumGfh09) { var bekModel = BoBas.OfGetBekModel(BaaModel.baa04); WfShowErrorMsg(string.Format("輸入金額加總已超過{0},請檢核!", GlobalFn.Round(masterModel.gfb07, bekModel.bek03).ToString()) ); return(false); } //檢查 已沖+暫沖(DB)+輸入金額 是否有超過立帳金額 var availableMaxAmt = 0m; //可輸入最高金額 var glat300aList = _dtGlat300a.ToList <vw_glat300a>(); //可輸入金額=資料庫(立帳金額-暫沖) availableMaxAmt = detailModel.gfg07 - detailModel.gfg08; //可輸人金額 再減掉此傳票但不屬於該項次的金額加總 availableMaxAmt -= glat300aList.Where(p => p.gfh01 == detailModel.gfg01 && p.gfh02 == detailModel.gfg02 && p.gfh04 != masterModel.gfb02) .Sum(p => p.gfh09) ; //可輸入金額 再減掉資料庫中不屬於該傳票未過帳的金額加總 if (!GlobalFn.varIsNull(masterModel.gfb01)) { sql = @"SELECT SUM(gfh09) FROM gfh_tb WHERE gfhconf='N' AND gfh03<>@gfh03 AND gfh01=@gfh01 AND gfh02=@gfh02 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gfh01", detailModel.gfg01)); sqlParmList.Add(new SqlParameter("@gfh02", detailModel.gfg02)); sqlParmList.Add(new SqlParameter("@gfh03", masterModel.gfb01)); var sumTempGfh09 = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sql, sqlParmList.ToArray()), 0m); availableMaxAmt -= sumTempGfh09; } if (Convert.ToDecimal(e.Value) > availableMaxAmt) { var bekModel = BoBas.OfGetBekModel(BaaModel.baa04); WfShowErrorMsg(string.Format("可輸入最大沖帳金額為{0} !", GlobalFn.Round(availableMaxAmt, bekModel.bek03).ToString()) ); return(false); } DrMaster["sum_gfh09"] = sumGfh09; break; } } #endregion return(true); } catch (Exception ex) { throw ex; } }
//回傳值 true.通過驗證 false.未通過驗證,會把值還原 protected override bool WfItemCheck(object sender, ItemCheckInfo e) { int iChkCnts = 0; vw_cari030 masterModel = null; gba_tb gbaModel = null; try { masterModel = DrMaster.ToItem <vw_cari030>(); #region 單頭 vw_cart100 if (e.Row.Table.Prefix.ToLower() == "vw_cari030") { switch (e.Column.ToLower()) { case "cba01": if (GlobalFn.isNullRet(e.Value, "") == "") { return(true); } if (FormEditMode == YREditType.新增) { if (BoCar.OfChkCbaPKExists(masterModel.cba01) == true) { WfShowErrorMsg("此科目分類碼已存在,請檢查!"); return(false); } } break; case "cba03": //應收帳款 if (GlobalFn.isNullRet(e.Value, "") == "") { return(true); } gbaModel = BoGla.OfGetGbaModel(e.Value.ToString()); if (gbaModel == null) { WfShowErrorMsg("無此會計科目,請檢核!"); return(false); } if (gbaModel.gbavali != "Y") { WfShowErrorMsg("此會計科目已失效,請檢核!"); return(false); } if (gbaModel.gba06 != "2" && gbaModel.gba06 != "3") { WfShowErrorMsg("會計科目非明細或獨立科目,請檢核!"); return(false); } break; case "cba04": //銷貨收入 if (GlobalFn.isNullRet(e.Value, "") == "") { return(true); } gbaModel = BoGla.OfGetGbaModel(e.Value.ToString()); if (gbaModel == null) { WfShowErrorMsg("無此會計科目,請檢核!"); return(false); } if (gbaModel.gbavali != "Y") { WfShowErrorMsg("此會計科目已失效,請檢核!"); return(false); } if (gbaModel.gba06 != "2" && gbaModel.gba06 != "3") { WfShowErrorMsg("會計科目非明細或獨立科目,請檢核!"); return(false); } break; case "cba05": //銷項稅額 if (GlobalFn.isNullRet(e.Value, "") == "") { return(true); } gbaModel = BoGla.OfGetGbaModel(e.Value.ToString()); if (gbaModel == null) { WfShowErrorMsg("無此會計科目,請檢核!"); return(false); } if (gbaModel.gbavali != "Y") { WfShowErrorMsg("此會計科目已失效,請檢核!"); return(false); } if (gbaModel.gba06 != "2" && gbaModel.gba06 != "3") { WfShowErrorMsg("會計科目非明細或獨立科目,請檢核!"); return(false); } break; } } #endregion return(true); } catch (Exception ex) { throw ex; } }