protected override void WfCreateBoBasic() { BoMaster = new AdmBLL(LoginInfo.CompNo, TabMaster.TargetTable, TabMaster.TargetColumn, TabMaster.ViewTable); BoBas = new BasBLL(BoMaster.OfGetConntion()); BoInv = new InvBLL(BoMaster.OfGetConntion()); return; }
private void RefreshBTN_Click(object sender, EventArgs e) { Inv inv = InvBLL.Buscar(1); double Total = inv.Total; TotalInvWrite.Text = Total.ToString(); }
protected override bool WfAppendUpdate() { vw_admi611 admi611Model = null; int chkCnts = 0; StringBuilder sbSql = null; List <SqlParameter> sqlParmsList; CommonBLL boAppend; DataTable dtady = null; try { boAppend = new InvBLL(BoMaster.OfGetConntion()); boAppend.TRAN = BoMaster.TRAN; boAppend.OfCreateDao("ady_tb", "*", ""); admi611Model = DrMaster.ToItem <vw_admi611>(); //處理明細--均先刪後新增 if (FormEditMode != YREditType.新增) { sbSql = new StringBuilder(); sqlParmsList = new List <SqlParameter>(); sbSql.AppendLine("DELETE FROM ady_tb WHERE ady01=@ady01"); sqlParmsList.Add(new SqlParameter("@ady01", admi611Model.adx01)); chkCnts = boAppend.OfExecuteNonquery(sbSql.ToString(), sqlParmsList.ToArray()); sbSql = new StringBuilder(); sqlParmsList = new List <SqlParameter>(); sbSql.AppendLine("SELECT * FROM ady_tb"); sbSql.AppendLine("WHERE 1<>1"); dtady = boAppend.OfGetDataTable(sbSql.ToString()); foreach (vw_admi611s detailModel in Admi611sList) { var drady = dtady.NewRow(); drady["ady01"] = detailModel.ady01; drady["ady02"] = detailModel.ady02; drady["ady03"] = detailModel.ady03; drady["ady04"] = detailModel.ady04; drady["ady05"] = detailModel.ady05; drady["ady06"] = detailModel.ady06; drady["ady07"] = detailModel.ady07; drady["adycreu"] = detailModel.adycreu; drady["adycreg"] = detailModel.adycreg; if (detailModel.adycred == null) { drady["adycred"] = DBNull.Value; } else { drady["adycred"] = detailModel.adycred; } drady["adymodu"] = detailModel.adymodu; drady["adymodg"] = detailModel.adymodg; if (detailModel.adymodd == null) { drady["adymodd"] = DBNull.Value; } else { drady["adymodd"] = detailModel.adymodd; } dtady.Rows.Add(drady); } boAppend.OfUpdate(dtady); } return(true); } 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; } }