public cac_tb OfGetCacModel(string pCac01, int pCac01Length) { DataRow drBab = null; cac_tb rtnModel = null; try { drBab = OfGetCacDr(pCac01, pCac01Length); if (drBab == null) { return(null); } rtnModel = drBab.ToItem <cac_tb>(); return(rtnModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// 傳入單別,自動會以baa06的單別碼數截取資料 /// </summary> /// <param name="pCac01"></param> /// <returns></returns> public cac_tb OfGetCacModel(string pCac01) { DataRow drCac = null; cac_tb rtnModel = null; try { drCac = OfGetCacDr(pCac01); if (drCac == null) { return(null); } rtnModel = drCac.ToItem <cac_tb>(); return(rtnModel); } catch (Exception ex) { throw ex; } }
private bool OfGenGea(vw_carb110 pCarb110Model, sga_tb pSgaModel, Result pResult) { string selectSql = "", updateSql = ""; List <SqlParameter> sqlParmList = null; StpBLL boStp = null; CarBLL boCar = null; BasBLL boBas = null; DataTable dtCea = null, dtCeb = null; DataRow drCea = null, drCeb = null; string cea01 = "", cea01New = ""; DateTime? cea02; string errMsg = ""; List <sgb_tb> sgbList = null; cac_tb cacModel = null; //收款單別 bab_tb babModel = null; //出貨單別 int chkCnts = 0; try { boCar = new CarBLL(OfGetConntion()); boCar.TRAN = this.TRAN; boStp = new StpBLL(OfGetConntion()); boStp.TRAN = this.TRAN; boBas = new BasBLL(OfGetConntion()); boBas.TRAN = this.TRAN; boCar.OfCreateDao("cea_tb", "*", ""); selectSql = @"SELECT * FROM cea_tb WHERE 1<>1"; dtCea = boCar.OfGetDataTable(selectSql); drCea = dtCea.NewRow(); //已輸入的為主 if (!GlobalFn.varIsNull(pCarb110Model.cea01)) { cea01 = pCarb110Model.cea01; } else { //以出貨單別設定的來拋轉 babModel = boBas.OfGetBabModel(pSgaModel.sga01); if (babModel == null) { pResult.Key1 = pSgaModel.sga01; pResult.Message = "取得出貨單別失敗!"; return(false); } if (GlobalFn.varIsNull(babModel.bab09)) { pResult.Key1 = pSgaModel.sga01; pResult.Message = "未設定出貨單拋轉應收帳款單別,請先至單別資料設定!"; return(false); } cea01 = babModel.bab09; } if (!GlobalFn.varIsNull(pCarb110Model.cea02)) { cea02 = pCarb110Model.cea02; } else { cea02 = pSgaModel.sga02; } errMsg = ""; if (boBas.OfGetAutoNo(cea01, ModuleType.car, (DateTime)cea02, out cea01New, out errMsg) == false) { pResult.Key1 = pSgaModel.sga01; pResult.Message = errMsg; return(false); } drCea["cea00"] = "11"; //帳款類別 drCea["cea01"] = cea01New; drCea["cea02"] = cea02; drCea["cea03"] = pSgaModel.sga03; drCea["cea04"] = pSgaModel.sga04; drCea["cea05"] = pSgaModel.sga05; //業務部門 drCea["cea06"] = pSgaModel.sga06; //課稅別 drCea["cea07"] = pSgaModel.sga07; //稅率 drCea["cea08"] = pSgaModel.sga08; //含稅否 drCea["cea09"] = pSgaModel.sga09; //發票聯數 drCea["cea10"] = pSgaModel.sga10; //幣別 drCea["cea11"] = pSgaModel.sga11; //收款條件 drCea["cea12"] = pSgaModel.sga21; //匯率 drCea["cea13"] = pSgaModel.sga13; //原幣未稅金額 drCea["cea13t"] = pSgaModel.sga13t; //原幣含稅金額 drCea["cea13g"] = pSgaModel.sga13g; //原幣稅額 drCea["cea14"] = 0; //原幣沖帳金額 drCea["cea15"] = 0; //本幣未稅金額 drCea["cea15t"] = 0; //本幣含稅金額 drCea["cea15g"] = 0; //本幣稅額 drCea["cea16"] = 0; //本幣沖帳金額 drCea["cea17"] = ""; //參考單號 drCea["cea18"] = ""; //備註 drCea["cea19"] = DBNull.Value; //應收款日 drCea["cea20"] = ""; //保留 drCea["cea21"] = ""; //科目類別 drCea["cea22"] = ""; //會科編號 drCea["cea23"] = ""; //發票別 drCea["cea24"] = ""; //發票日期 drCea["cea25"] = ""; //發票號碼 drCea["cea26"] = ""; //發票客戶 drCea["cea27"] = ""; //申報統編 drCea["cea28"] = ""; //來源別 drCea["cea29"] = ""; //傳票編號 drCea["ceaconf"] = "N"; drCea["ceacomp"] = _loginInfo.CompNo; drCea["ceacreu"] = _loginInfo.UserNo; drCea["ceacreg"] = _loginInfo.DeptNo; drCea["ceacred"] = OfGetNow(); drCea["ceamodu"] = DBNull.Value; drCea["ceamodg"] = DBNull.Value; drCea["ceamodd"] = DBNull.Value; drCea["ceasecu"] = _loginInfo.UserNo; drCea["ceasecg"] = _loginInfo.GroupNo; dtCea.Rows.Add(drCea); if (boCar.OfUpdate(dtCea) == -1) { pResult.Key1 = cea01New; pResult.Message = "新增應收單頭失敗!"; return(false); } boCar.OfCreateDao("cfb_tb", "*", ""); selectSql = @"SELECT * FROM ceb_tb WHERE 1<>1"; dtCeb = boCar.OfGetDataTable(selectSql); foreach (sgb_tb sgbModel in sgbList.OrderBy(p => p.sgb02)) { drCeb = dtCeb.NewRow(); drCeb["ceb00"] = "11"; //帳款類別 drCeb["ceb01"] = cea01New; //傳票編號 drCeb["ceb02"] = sgbModel.sgb02; //項次 drCeb["ceb03"] = sgbModel.sgb03; //料號 drCeb["ceb04"] = sgbModel.sgb04; //品名 drCeb["ceb05"] = sgbModel.sgb05; //數量 drCeb["ceb06"] = sgbModel.sgb09; //原幣單價 drCeb["ceb07"] = sgbModel.sgb10; //原幣未稅金額 drCeb["ceb07t"] = sgbModel.sgb10t; //原幣含稅金額 drCeb["ceb08"] = 0; //本幣單價 drCeb["ceb09"] = 0; //本未稅金額 drCeb["ceb09t"] = 0; //本幣含稅金額 drCeb["ceb10"] = ""; //會計科目 drCeb["ceb11"] = pSgaModel.sga01; //出貨單號 drCeb["ceb12"] = sgbModel.sgb02; //出貨項次 drCeb["ceb13"] = 0; //原幣已沖金額 drCeb["ceb14"] = 0; //本幣已沖金額 drCeb["ceb15"] = 0; //本幣未沖金額 drCeb["ceb16"] = sgbModel.sgb06; //單位 drCeb["cebcomp"] = _loginInfo.CompNo; drCeb["cebcreu"] = _loginInfo.UserNo; drCeb["cebcreg"] = _loginInfo.DeptNo; drCeb["cebcred"] = OfGetNow(); drCeb["cebmodu"] = DBNull.Value; drCeb["cebmodg"] = DBNull.Value; drCeb["cebmodd"] = DBNull.Value; dtCeb.Rows.Add(drCeb); } if (boCar.OfUpdate(dtCeb) == -1) { pResult.Key1 = cea01New; pResult.Message = "新增應收單身失敗!"; return(false); } updateSql = @"UPDATE sga_tb SET sga22=@sga22 WHERE sga01=@sga01 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@sga22", cea01New)); sqlParmList.Add(new SqlParameter("@sga01", pSgaModel.sga01)); chkCnts = OfExecuteNonquery(updateSql, sqlParmList.ToArray()); if (chkCnts != 1) { pResult.Key1 = pSgaModel.sga01; pResult.Message = "更新出貨單失敗!"; return(false); } // updateSql = @"UPDATE gea_tb // SET gea06=@gea06, // gea07=@gea07 // WHERE gea01=@gea01 // AND gea02=@gea02 // AND gea03=@gea03 // AND gea04=@gea04 // "; // sqlParmList = new List<SqlParameter>(); // sqlParmList.Add(new SqlParameter("@gea06", cea01New)); // sqlParmList.Add(new SqlParameter("@gea07", cea02)); // sqlParmList.Add(new SqlParameter("@gea01", pGeaModel.gea01)); // sqlParmList.Add(new SqlParameter("@gea02", pGeaModel.gea02)); // sqlParmList.Add(new SqlParameter("@gea03", pGeaModel.gea03)); // sqlParmList.Add(new SqlParameter("@gea04", pGeaModel.gea04)); // chkCnts = OfExecuteNonquery(updateSql, sqlParmList.ToArray()); // if (chkCnts != 1) // { // pResult.Key1 = pGeaModel.gea01; // pResult.Message = "更新分稿底稿失敗!"; // return false; // } return(true); } catch (Exception ex) { pResult.Key1 = pSgaModel.sga01; pResult.Message = ex.Message; pResult.Exception = ex; throw; } }
/// <summary> /// 產生分錄底稿 來源為收款沖帳單 /// </summary> /// <param name="pCarb350Model"></param> /// <param name="pCfaModel"></param> /// <param name="pGeaModel"></param> /// <param name="pResult"></param> /// <returns></returns> private bool OfGenGfa(vw_carb350 pCarb350Model, cfa_tb pCfaModel, gea_tb pGeaModel, Result pResult) { string selectSql = "", updateSql = ""; List <SqlParameter> sqlParmList = null; GlaBLL boGla = null; BasBLL boBas = null; DataTable dtGfa = null, dtGfb = null; DataRow drGfa = null, drGfb = null; string gfa01 = "", gfa01New = ""; DateTime? gfa02; string errMsg = ""; int year = 0, period = 0; List <geb_tb> gebList = null; cac_tb cacModel = null; //收款單別 int chkCnts = 0; try { boGla = new GlaBLL(OfGetConntion()); boGla.TRAN = this.TRAN; boBas = new BasBLL(OfGetConntion()); boBas.TRAN = this.TRAN; boGla.OfCreateDao("gfa_tb", "*", ""); selectSql = @"SELECT * FROM gfa_tb WHERE 1<>1"; dtGfa = boGla.OfGetDataTable(selectSql); drGfa = dtGfa.NewRow(); if (!GlobalFn.varIsNull(pCarb350Model.gfa01)) { gfa01 = pCarb350Model.gfa01; } else { //以應收單別設定的來拋轉 cacModel = OfGetCacModel(pCfaModel.cfa01); if (cacModel == null) { pResult.Key1 = pCfaModel.cfa01; pResult.Message = "取得應收單別失敗!"; return(false); } if (GlobalFn.varIsNull(cacModel.cac10)) { pResult.Key1 = pCfaModel.cfa01; pResult.Message = "未設定應收拋轉總帳單別,請先至單別資料設定!"; return(false); } gfa01 = cacModel.cac10; } if (!GlobalFn.varIsNull(pCarb350Model.gfa02)) { gfa02 = pCarb350Model.gfa02; } else { gfa02 = pGeaModel.gea05; } errMsg = ""; if (boBas.OfGetAutoNo(gfa01, ModuleType.gla, (DateTime)gfa02, out gfa01New, out errMsg) == false) { pResult.Key1 = pCfaModel.cfa01; pResult.Message = errMsg; return(false); } drGfa["gfa01"] = gfa01New; drGfa["gfa02"] = gfa02; drGfa["gfa03"] = pGeaModel.gea08; drGfa["gfa04"] = pGeaModel.gea09; drGfa["gfa05"] = ""; //備註 drGfa["gfa06"] = pGeaModel.gea02; //來源碼-系統別 drGfa["gfa07"] = pGeaModel.gea01; //來源單號 if (boGla.OfGetGlaYearPeriod(Convert.ToDateTime(gfa02), out year, out period) == false) { pResult.Message = "取得會計年度失敗!"; return(false); } drGfa["gfa08"] = year; drGfa["gfa09"] = period; drGfa["gfa10"] = DBNull.Value; //保留 drGfa["gfa10"] = DBNull.Value; //保留 drGfa["gfa11"] = DBNull.Value; //保留 drGfa["gfa12"] = DBNull.Value; //保留 drGfa["gfa13"] = DBNull.Value; //保留 drGfa["gfa14"] = DBNull.Value; //保留 drGfa["gfa15"] = DBNull.Value; //保留 drGfa["gfa16"] = DBNull.Value; //保留 drGfa["gfa17"] = DBNull.Value; //保留 drGfa["gfa18"] = DBNull.Value; //保留 drGfa["gfa19"] = DBNull.Value; //保留 drGfa["gfa20"] = DBNull.Value; //保留 drGfa["gfaprno"] = 0; drGfa["gfaconf"] = "N"; drGfa["gfaconu"] = DBNull.Value; drGfa["gfapost"] = "N"; drGfa["gfaposd"] = DBNull.Value; drGfa["gfaposu"] = DBNull.Value; drGfa["gfacomp"] = _loginInfo.CompNo; drGfa["gfacreu"] = _loginInfo.UserNo; drGfa["gfacreg"] = _loginInfo.DeptNo; drGfa["gfacred"] = OfGetNow(); drGfa["gfamodu"] = DBNull.Value; drGfa["gfamodg"] = DBNull.Value; drGfa["gfamodd"] = DBNull.Value; drGfa["gfasecu"] = _loginInfo.UserNo; drGfa["gfasecg"] = _loginInfo.GroupNo; dtGfa.Rows.Add(drGfa); if (boGla.OfUpdate(dtGfa) == -1) { pResult.Key1 = pGeaModel.gea01; pResult.Message = "新增傳票單頭失敗!"; return(false); } gebList = boGla.OfGetGebList(pGeaModel.gea01, pGeaModel.gea02, pGeaModel.gea03, pGeaModel.gea04); if (gebList == null || gebList.Count == 0) { pResult.Key1 = pGeaModel.gea01; pResult.Message = "查無分錄底稿單身資料!"; return(false); } boGla.OfCreateDao("gfb_tb", "*", ""); selectSql = @"SELECT * FROM gfb_tb WHERE 1<>1"; dtGfb = boGla.OfGetDataTable(selectSql); foreach (geb_tb gebModel in gebList.OrderBy(p => p.geb05)) { drGfb = dtGfb.NewRow(); drGfb["gfb01"] = gfa01New; //傳票編號 drGfb["gfb02"] = gebModel.geb05; //項次 drGfb["gfb03"] = gebModel.geb06; //科目編號 drGfb["gfb04"] = gebModel.geb07; //摘要 drGfb["gfb05"] = gebModel.geb08; //部門 drGfb["gfb06"] = gebModel.geb09; //借貸別 drGfb["gfb07"] = gebModel.geb10; //本幣金額 drGfb["gfb08"] = gebModel.geb11; //原幣幣別 drGfb["gfb09"] = gebModel.geb12; //匯率 drGfb["gfb10"] = gebModel.geb13; //原幣金額 drGfb["gfb11"] = DBNull.Value; //保留 drGfb["gfb12"] = DBNull.Value; //保留 drGfb["gfb13"] = DBNull.Value; //保留 drGfb["gfb14"] = DBNull.Value; //保留 drGfb["gfb15"] = DBNull.Value; //保留 drGfb["gfb16"] = DBNull.Value; //保留 drGfb["gfb17"] = DBNull.Value; //保留 drGfb["gfb18"] = DBNull.Value; //保留 drGfb["gfb19"] = DBNull.Value; //保留 drGfb["gfb20"] = DBNull.Value; //保留 drGfb["gfbcomp"] = _loginInfo.CompNo; drGfb["gfbcreu"] = _loginInfo.UserNo; drGfb["gfbcreg"] = _loginInfo.DeptNo; drGfb["gfbcred"] = OfGetNow(); drGfb["gfbmodu"] = DBNull.Value; drGfb["gfbmodg"] = DBNull.Value; drGfb["gfbmodd"] = DBNull.Value; dtGfb.Rows.Add(drGfb); } if (boGla.OfUpdate(dtGfb) == -1) { pResult.Key1 = pGeaModel.gea01; pResult.Message = "新增傳票單身失敗!"; return(false); } updateSql = @"UPDATE cfa_tb SET cfa12=@cfa12 WHERE cfa01=@cfa01 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@cfa12", gfa01New)); sqlParmList.Add(new SqlParameter("@cfa01", pCfaModel.cfa01)); chkCnts = OfExecuteNonquery(updateSql, sqlParmList.ToArray()); if (chkCnts != 1) { pResult.Key1 = pGeaModel.gea01; pResult.Message = "更新收款單失敗!"; return(false); } updateSql = @"UPDATE gea_tb SET gea06=@gea06, gea07=@gea07 WHERE gea01=@gea01 AND gea02=@gea02 AND gea03=@gea03 AND gea04=@gea04 "; sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@gea06", gfa01New)); sqlParmList.Add(new SqlParameter("@gea07", gfa02)); sqlParmList.Add(new SqlParameter("@gea01", pGeaModel.gea01)); sqlParmList.Add(new SqlParameter("@gea02", pGeaModel.gea02)); sqlParmList.Add(new SqlParameter("@gea03", pGeaModel.gea03)); sqlParmList.Add(new SqlParameter("@gea04", pGeaModel.gea04)); chkCnts = OfExecuteNonquery(updateSql, sqlParmList.ToArray()); if (chkCnts != 1) { pResult.Key1 = pGeaModel.gea01; pResult.Message = "更新分稿底稿失敗!"; return(false); } return(true); } catch (Exception ex) { pResult.Key1 = pCfaModel.cfa01; pResult.Message = ex.Message; pResult.Exception = ex; throw; } }