//回傳值 true.通過驗證 false.未通過驗證,會把值還原 protected override bool WfItemCheck(object sender, ItemCheckInfo e) { int iChkCnts = 0; vw_zinvt001 masterModel = null; vw_zinvt001s detailModel = null; List <vw_zinvt001s> detailList = null; bab_tb l_bab = null; UltraGrid uGrid = null; try { masterModel = DrMaster.ToItem <vw_zinvt001>(); #region 單身-pick vw_zinvt001s if (e.Row.Table.Prefix.ToLower() == "vw_zinvt001s") { uGrid = sender as UltraGrid; detailModel = e.Row.ToItem <vw_zinvt001s>(); detailList = e.Row.Table.ToList <vw_zinvt001s>(); l_bab = BoBas.OfGetBabModel(masterModel.iga01); switch (e.Column.ToLower()) { case "igb07": //異動成本 if (GlobalFn.varIsNull(e.Value)) { return(true); } if (detailModel.igb07 < 0) { WfShowErrorMsg("單價不可小於0!"); return(false); } //依幣別檔設定單價小數 e.Row[e.Column] = GlobalFn.Round(detailModel.igb07, BekModel.bek03); WfSetDetailAmt(e.Row); break; } } #endregion return(true); } 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; } }
public Result OfGetSga23(sga_tb sgaModel, out decimal sga23) { sga23 = 0; Result rtnResult = null; rtnResult = new Result(); rtnResult.Success = false; try { if (sgaModel == null) { return(rtnResult); } rtnResult.Key1 = sgaModel.sga01; if (OfChkEbusinessPlateForm(sgaModel.sga03) == false) { rtnResult.Message = "非出貨成本計算客戶!"; return(rtnResult); } switch (sgaModel.sga03) { case "C000002": //蝦皮 sga23 = sgaModel.sga13t * 0.05m; if (sgaModel.sga13t > 4490) { sga23 += 60; } break; case "C000003": //露天-正中 sga23 = sgaModel.sga13t * 0.03m; break; case "C000004": //奇摩 sga23 = sgaModel.sga13t * 0.015m; if (sgaModel.sga13t > 4990) { sga23 += 60; } break; case "C000005": //松果 sga23 = sgaModel.sga13t * 0.04m; //預設刷卡 //sga23 += 60; break; case "C000006": //蝦皮2 sga23 = sgaModel.sga13t * 0.05m; break; case "C000007": //露天-艾達 sga23 = sgaModel.sga13t * 0.03m; break; } sga23 = GlobalFn.Round(sga23, 0); rtnResult.Success = true; return(rtnResult); } catch (Exception ex) { throw ex; } }
/********** 其他常用function ********/ #region OfGetPrice /// <summary> /// /// </summary> /// <param name="pSbc01">價格條件</param> /// <param name="pCust">客戶編號</param> /// <param name="pItem">料號</param> /// <param name="pUnit">單位</param> /// <param name="pDate">日期</param> /// <param name="pCurrency">幣別</param> /// <param name="pType">1.報價 2.訂單 3.出貨單</param> /// <param name="pQty">數量</param> /// <param name="pTaxYN">含稅否</param> /// <param name="pTaxRate">稅率</param> /// <param name="pExRate">匯率</param> /// <param name="pPrice">回傳價格</param> /// <returns></returns> public Result OfGetPrice(string pSbc01, string pCust, string pItem, string pUnit, DateTime?pDate, string pCurrency, string pType, decimal pQty, string pTaxYN, decimal pTaxRate, decimal pExRate, out decimal pPrice ) { Result rtnResult = null; string sqlSelect = ""; List <SqlParameter> sqlParmList = null; List <sbc_tb> sbcList = null; BasBLL boBas = null; bek_tb bekModel = null; decimal tempPrice = 0; bool flag = false; pPrice = 0; try { rtnResult = new Result(); rtnResult.Key1 = pItem; boBas = new BasBLL(OfGetConntion()); boBas.TRAN = this.TRAN; sbcList = OfgetSbcList(pSbc01); if (sbcList == null || sbcList.Count == 0) { rtnResult.Message = "未設定取價原則!"; return(rtnResult); } bekModel = boBas.OfGetBekModel(pCurrency); if (bekModel == null) { rtnResult.Message = "查無此幣別資料!"; return(rtnResult); } foreach (sbc_tb sbcModel in sbcList.OrderBy(p => p.sbc04)) { switch (sbcModel.sbc03.ToUpper()) { case "A1": //依料號主檔 考量含稅否及匯率 sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@ica01", pItem)); if (pTaxYN == "Y") { sqlSelect = @"SELECT ica11 FROM ica_tb WHERE ica01=@ica01"; } else { sqlSelect = @"SELECT ica10 FROM ica_tb WHERE ica01=@ica01"; } tempPrice = GlobalFn.isNullRet(OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0m); break; case "A2": //依料號客戶價格 雖然key值只有料號+客戶編號+幣別,但還是得加含稅否來做處理 sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("@sdd01", pItem)); sqlParmList.Add(new SqlParameter("@sdd02", pCust)); sqlParmList.Add(new SqlParameter("@sdd03", pCurrency)); sqlParmList.Add(new SqlParameter("@sdd08", pTaxYN)); sqlSelect = @"SELECT sdd09 FROM sdd_tb WHERE sdd01=@sdd01 AND sdd02=@sdd02 AND sdd03=@sdd03 AND sdd08=@sdd08 "; tempPrice = GlobalFn.isNullRet(OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0m); break; case "A3": //依產品主檔 break; } if (sbcModel.sbc03.ToUpper() == "A1" && tempPrice > 0) { pPrice = tempPrice / pExRate; pPrice = GlobalFn.Round(pPrice, bekModel.bek03); break; } if (sbcModel.sbc03.ToUpper() == "A2" && tempPrice > 0) { pPrice = tempPrice; pPrice = GlobalFn.Round(pPrice, bekModel.bek03); break; } } rtnResult.Success = true; return(rtnResult); } catch (Exception ex) { throw ex; } }
/********** 其他常用function ********/ #region OfGetPrice /// <summary> /// /// </summary> /// <param name="pPbc01">價格條件</param> /// <param name="pVendor">客戶編號</param> /// <param name="pItem">料號</param> /// <param name="pUnit">單位</param> /// <param name="pDate">日期</param> /// <param name="pCurrency">幣別</param> /// <param name="pType">2.採購 3.收貨</param> /// <param name="pQty">數量</param> /// <param name="pTaxYN">含稅否</param> /// <param name="pTaxRate">稅率</param> /// <param name="pExRate">匯率</param> /// <param name="pUtaxPrice">回傳未稅價格</param> /// <param name="pTaxPrice">回傳含稅價格</param> /// <returns></returns> public Result OfGetPrice(string pPbc01, string pVendor, string pItem, string pUnit, DateTime?pDate, string pCurrency, string pType, decimal pQty, string pTaxYN, decimal pTaxRate, decimal pExRate, out decimal pUtaxPrice, out decimal pTaxPrice ) { Result rtnResult = null; string sqlSelect = ""; List <SqlParameter> sqlParmList = null; List <pbc_tb> pbcList = null; ica_tb icaModel = null; bek_tb bekModel = null; InvBLL boInv = null; BasBLL boBas = null; decimal tempUtaxPrice = 0, tempTaxPrice = 0, unitRate = 0; bool flag = false; pUtaxPrice = 0; pTaxPrice = 0; try { rtnResult = new Result(); rtnResult.Key1 = pItem; boInv = new InvBLL(OfGetConntion()); boInv.TRAN = this.TRAN; boBas = new BasBLL(OfGetConntion()); boBas.TRAN = this.TRAN; pbcList = OfgetPbcList(pPbc01); if (pbcList == null || pbcList.Count == 0) { rtnResult.Message = "未設定取價原則!"; return(rtnResult); } icaModel = boInv.OfGetIcaModel(pItem); if (icaModel == null) { rtnResult.Message = "查無此料號資料!"; return(rtnResult); } bekModel = boBas.OfGetBekModel(pCurrency); if (bekModel == null) { rtnResult.Message = "查無此幣別資料!"; return(rtnResult); } foreach (pbc_tb pbcModel in pbcList.OrderBy(p => p.pbc04)) { switch (pbcModel.pbc03.ToUpper()) { case "A1": //依料號最近市價 考量含稅否及匯率 tempUtaxPrice = icaModel.ica19; if (pTaxYN == "Y") { tempTaxPrice = tempUtaxPrice * (1 + pTaxRate / 100); } //取得單位換算率 傳入單位與採購單位的換算率--這個適用A1跟A2 flag = boInv.OfGetUnitCovert(pItem, icaModel.ica08, pUnit, out unitRate); if (flag == false) { rtnResult.Message = "取得料號換算率失敗!"; return(rtnResult); } tempUtaxPrice = tempUtaxPrice * unitRate; tempTaxPrice = tempTaxPrice * unitRate; break; case "A2": //依料號最近採購價 考量含稅否及匯率 tempUtaxPrice = icaModel.ica18; if (pTaxYN == "Y") { tempTaxPrice = tempUtaxPrice * (1 + pTaxRate / 100); } //取得單位換算率 傳入單位與採購單位的換算率--這個適用A1跟A2 flag = boInv.OfGetUnitCovert(pItem, icaModel.ica08, pUnit, out unitRate); if (flag == false) { rtnResult.Message = "取得料號換算率失敗!"; return(rtnResult); } tempUtaxPrice = tempUtaxPrice * unitRate; tempTaxPrice = tempTaxPrice * unitRate; break; case "A3": //依料號供應商單價 var pddModel = OfGetPddModel(pItem, pVendor, pCurrency); if (pddModel == null) { continue; } tempUtaxPrice = pddModel.pdd09; tempTaxPrice = pddModel.pdd10; //取得匯率 //取得單位換算率 傳入單位與採購單位的換算率--這個適用A1跟A2 flag = boInv.OfGetUnitCovert(pItem, pddModel.pdd12, pUnit, out unitRate); if (flag == false) { rtnResult.Message = "取得料號換算率失敗!"; return(rtnResult); } tempUtaxPrice = tempUtaxPrice * unitRate; tempTaxPrice = tempTaxPrice * unitRate; break; } if (pTaxYN == "Y" && tempTaxPrice == 0) { continue; } if (pTaxYN != "Y" && tempUtaxPrice == 0) { continue; } if (pbcModel.pbc03.ToUpper() == "A1" || pbcModel.pbc03.ToUpper() == "A2") { pUtaxPrice = tempUtaxPrice / pExRate; pTaxPrice = tempTaxPrice / pExRate; pUtaxPrice = GlobalFn.Round(pUtaxPrice, bekModel.bek03); pTaxPrice = GlobalFn.Round(pTaxPrice, bekModel.bek03); break; } if (pbcModel.pbc03.ToUpper() == "A3") //查詢已包含幣別,所以不用考量匯率 { pUtaxPrice = GlobalFn.Round(tempUtaxPrice, bekModel.bek03); pTaxPrice = GlobalFn.Round(tempTaxPrice, bekModel.bek03); break; } } rtnResult.Success = true; return(rtnResult); } catch (Exception ex) { throw ex; } }