private decimal GetGiftAmountBalance() { int id = (int)ViewState["ID"]; FNA_FeeApply apply = new FNA_FeeApplyBLL(id).Model; if (apply == null) { return(0); } decimal giftamountbalance = 0; IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", apply.AccountMonth, apply.Client, apply.ProductBrand, (int)ViewState["GiftFeeClassify"])); if (giftamounts.Count > 0) { decimal budget = decimal.Parse(lb_BudgetBalance.Text); decimal balance = giftamounts[0].BalanceAmount; giftamountbalance = budget > balance ? balance : budget; } lb_GiftAmountBalance.Visible = true; lb_GiftAmountBalance.Text = string.Format("赠品费用可申请额度:{0:0.##}元", giftamountbalance); if (pn_FeeApply.FindControl("FNA_FeeApply_Client") != null) { ((MCSSelectControl)pn_FeeApply.FindControl("FNA_FeeApply_Client")).Enabled = false; } return(giftamountbalance); }
private void BindBudgetInfo(int city, int month, int client, int feetype, int productbrand, int giftclassify, int receiver) { lb_OrganizeCityName.Text = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", city); lb_ClientName.Text = client == 0 ? "" : new CM_ClientBLL(client).Model.FullName; lb_Receiver.Text = (receiver == 0 || receiver == null) ? "" : new CM_ClientBLL(receiver).Model.FullName; decimal totalbudget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); lb_TotalBudget.Text = totalbudget.ToString("0.##"); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); if (giftamounts.Count > 0) { decimal available = giftamounts[0].AvailableAmount + giftamounts[0].PreBalance - giftamounts[0].DeductibleAmount; decimal balance = giftamounts[0].BalanceAmount; ViewState["SalesVolume"] = giftamounts[0].SalesVolume; lb_AvailableAmount.Text = available.ToString("0.##"); lb_BalanceAmount.Text = balance.ToString("0.##"); //2012-3-27 暂时只取赠品额度,不取预算 //lb_BalanceAmount.Text = (totalbudget > balance ? balance : totalbudget).ToString("0.##"); } else { lb_AvailableAmount.Text = "0"; lb_BalanceAmount.Text = "0"; } hl_ViewBudget.NavigateUrl = "~/SubModule/FNA/Budget/BudgetBalance.aspx?OrganizeCity=" + city.ToString(); }
private decimal GetGiftAmountBalance() { decimal giftamountbalance = 0; int month = 0, city = 0, feetype = 0, client = 0, productbrand = 0, giftclassify = 0; feetype = (int)ViewState["GiftFeeType"]; int.TryParse(ddl_ApplyMonth.SelectedValue, out month); int.TryParse(tr_OrganizeCity.SelectValue, out city); int.TryParse(select_Client.SelectValue, out client); int.TryParse(ddl_Brand.SelectedValue, out productbrand); int.TryParse(rbl_GiftClassify.SelectedValue, out giftclassify); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); if (giftamounts.Count > 0) { decimal budget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); decimal balance = giftamounts[0].BalanceAmount; giftamountbalance = budget > balance ? balance : budget; } lb_GiftAmountBalance.Text = giftamountbalance.ToString("0.0#"); return(giftamountbalance); }
private void BindBudgetInfo(int city, int month, int client, int feetype, int productbrand, int giftclassify) { decimal totalbudget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); lb_TotalBudget.Text = totalbudget.ToString("0.##"); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); ViewState["SalesVolume"] = 0m; if (giftamounts.Count > 0) { decimal available = giftamounts[0].AvailableAmount + giftamounts[0].PreBalance - giftamounts[0].DeductibleAmount;; decimal balance = giftamounts[0].BalanceAmount; ViewState["SalesVolume"] = giftamounts[0].SalesVolume; lb_AvailableAmount.Text = available.ToString("0.##"); lb_BalanceAmount.Text = balance.ToString("0.##"); //2012-3-27 暂时只取赠品额度,不取预算 //lb_BalanceAmount.Text = (totalbudget > balance ? balance : totalbudget).ToString("0.##"); } else { lb_AvailableAmount.Text = "0"; lb_BalanceAmount.Text = "0"; } hl_ViewBudget.NavigateUrl = "~/SubModule/FNA/Budget/BudgetBalance.aspx?OrganizeCity=" + city.ToString(); }
private void LoadGiftApplyAmount() { int month = 0; int client = 0; int.TryParse(ddl_AccountMonth.SelectedValue, out month); int.TryParse(select_Client.SelectValue, out client); if (month > 0 && client > 0) { IList <ORD_GiftApplyAmount> lists = ORD_GiftApplyAmountBLL.GetModelList(string.Format("AccountMonth={0} AND Client={1}", month, client)); if (lists.Count == 0) { ORD_GiftApplyAmountBLL.ComputAvailableAmount(month, client); } int pulishid = 0; int brand = 0; int giftclassify = 0; int.TryParse(ddl_Publish.SelectedValue, out pulishid); if (pulishid > 0) { ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(pulishid); int.TryParse(publish.Model["ProductBrand"], out brand); int.TryParse(publish.Model["GiftClassify"], out giftclassify); lists = ORD_GiftApplyAmountBLL.GetModelList(string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, brand, giftclassify)); if (lists.Count > 0) { lb_GiftApplyAmount.Text = string.Format("销量:{0:0.#元},赠品费率:{1:0.###%},赠品总额度:{2:0.#元}, 赠品额度余额:{3:0.#元}", lists[0].SalesVolume, lists[0].FeeRate, lists[0].AvailableAmount + lists[0].PreBalance - lists[0].DeductibleAmount, lists[0].BalanceAmount); } else { string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' }); lb_GiftApplyAmount.Text = nolimitbrand.Contains(publish.Model["ProductBrand"])?"本品类不限制申请额度":"上月无销量!"; } } } }
private void threadStartImport(BackgroundWorker worker, DoWorkEventArgs e) { bool bFind = false; StringBuilder _xhs_success = new StringBuilder("");//成功导入的记录序号(用于定期批量更新导入标志) string XH = ""; int ClientID = 0, AccountMonth = 0, Brand = 0, Classify = 0, DIClassify = 0; decimal PreBalance, DeductibleAmount; try { lb_Count.Text = dt_Amount.Rows.Count.ToString(); for (int i = 0; i < dt_Amount.Rows.Count; i++) { worker.ReportProgress((i + 1) * 100 / this.dt_Amount.Rows.Count, i); if (worker.CancellationPending) { e.Cancel = true; break; } XH = dt_Amount.Rows[i]["序号"].ToString(); IList <CM_Client> _cmlist = CM_ClientBLL.GetModelList("Code='" + dt_Amount.Rows[i]["经销商代码"].ToString() + "' AND ActiveFlag=1 AND ApproveFlag=1"); if (_cmlist.Count == 1) { DIClassify = int.Parse(_cmlist[0]["DIClassify"]); ClientID = DIClassify == 3?_cmlist[0].Supplier: _cmlist[0].ID;//经销商为子户头时,取主户头 } else { UpdateImportFlag(i, "导入失败,经销商代码不正确"); continue; } if (dt_Amount.Rows[i]["品牌"].ToString() != "") { IList <PDT_Brand> _listbrand = PDT_BrandBLL.GetModelList("Name='" + dt_Amount.Rows[i]["品牌"].ToString() + "'"); if (_listbrand.Count == 0) { UpdateImportFlag(i, "导入失败,该品牌不存在"); continue; } else { Brand = _listbrand[0].ID; } } if (dt_Amount.Rows[i]["会计月"].ToString() != "") { IList <AC_AccountMonth> _monthlist = AC_AccountMonthBLL.GetModelList("Name='" + dt_Amount.Rows[i]["会计月"].ToString() + "'"); if (_monthlist.Count == 0) { UpdateImportFlag(i, "导入失败,会计月填写错误"); continue; } else { AccountMonth = _monthlist[0].ID; } } foreach (Dictionary_Data item in DictionaryBLL.Dictionary_Data_GetAlllList("Type IN (SELECT ID FROM MCS_SYS.dbo.Dictionary_Type WHERE TableName='ORD_GiftClassify')")) { if (item.Name == dt_Amount.Rows[i]["有导无导标志"].ToString().Trim()) { Classify = int.Parse(item.Code); bFind = true; break; } } if (!bFind) { UpdateImportFlag(i, "导入失败,有导无导标志错误!"); continue; } IList <ORD_GiftApplyAmount> _listamount = ORD_GiftApplyAmountBLL.GetModelList("AccountMonth=" + AccountMonth.ToString() + " AND Client=" + ClientID.ToString() + " AND Brand=" + Brand.ToString() + " AND Classify=" + Classify.ToString()); if (_listamount.Count == 0) { UpdateImportFlag(i, "导入失败,没有找到符合该条件的赠品余额记录。"); continue; } if (ORD_GiftApplyAmountBLL.GetModelList("AccountMonth=" + (AccountMonth + 1).ToString() + " AND Client=" + ClientID.ToString() + " AND Brand=" + Brand.ToString() + " AND Classify=" + Classify.ToString()).Count > 0) { UpdateImportFlag(i, "导入失败,不能更新历史记录。"); continue; } ORD_GiftApplyAmountBLL _bll = new ORD_GiftApplyAmountBLL(_listamount[0].ID); #region 记录需更新费用 decimal.TryParse(dt_Amount.Rows[i]["赠品抵扣额"].ToString().Trim(), out DeductibleAmount); if (decimal.TryParse(dt_Amount.Rows[i]["上月余额"].ToString().Trim(), out PreBalance)) { if (DIClassify == 1) { _bll.Model.PreBalance = PreBalance; } else { _bll.Model.PreBalance += PreBalance; } } _bll.Model.DeductibleAmount += DeductibleAmount; _bll.Model.BalanceAmount = _bll.Model.AvailableAmount + _bll.Model.PreBalance - _bll.Model.AppliedAmount - _bll.Model.DeductibleAmount; _bll.Update(); dt_Amount.Rows[i]["导入标志"] = "导入成功"; _xhs_success.Append(XH + ","); #endregion } UpdateSuccess(_xhs_success.ToString()); } catch (System.Exception err) { UpdateSuccess(_xhs_success.ToString()); MessageBox.Show(err.Source + "~r~n" + err.StackTrace, err.Message); } return; }