protected void bt_In_Click(object sender, EventArgs e) { Save(); foreach (GridViewRow row in gv_NotInList.Rows) { CheckBox cb_check = (CheckBox)row.FindControl("cb_Check"); if (cb_check.Checked) { ORD_ApplyPublishBLL _bll; if ((int)ViewState["ID"] != 0) { _bll = new ORD_ApplyPublishBLL((int)ViewState["ID"]); } else { return; } ORD_ApplyPublishDetail pd = new ORD_ApplyPublishDetail(); pd.ID = (int)ViewState["ID"]; pd.Product = int.Parse(gv_NotInList.DataKeys[row.RowIndex]["ID"].ToString()); pd.Price = new PDT_ProductBLL(pd.Product).Model.FactoryPrice; _bll.AddDetail(pd); } } Response.Redirect("PublishDetail.aspx?ID=" + ViewState["ID"].ToString()); }
protected string GetPublishDetailRemark(int product) { ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL((int)ViewState["Publish"]); ORD_ApplyPublishDetail detail = publish.Items.FirstOrDefault(p => p.Product == product); if (detail != null) { return(detail["Remark"]); } else { return(""); } }
/// <summary> /// 根据请购买申请单重新初始化购物车 /// </summary> /// <param name="ApplyID"></param> /// <returns></returns> public static ORD_OrderCartBLL InitByOrderApply(int ApplyID) { ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL(ApplyID); if (apply.Model == null) { return(null); } ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(apply.Model.PublishID); if (publish.Model == null) { return(null); } int addressid = 0; int.TryParse(apply.Model["AddressID"], out addressid); ORD_OrderCartBLL cart = new ORD_OrderCartBLL(apply.Model.PublishID, apply.Model.OrganizeCity, apply.Model.Client, apply.Model.AccountMonth, addressid); foreach (ORD_OrderApplyDetail item in apply.Items) { ORD_ApplyPublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product); if (_m == null) { continue; } ORD_OrderCart cartitem = new ORD_OrderCart(); cartitem.ID = _m.ID; cartitem.Product = _m.Product; cartitem.MinQuantity = _m.MinQuantity; cartitem.MaxQuantity = _m.MaxQuantity; cartitem.Price = item.Price; cartitem.AvailableQuantity = _m.AvailableQuantity; cartitem.SubmitQuantity = ORD_OrderApplyBLL.GetSubmitQuantity(cart.Publish, cartitem.Product); cartitem.BookQuantity = item.BookQuantity; cart.Items.Add(cartitem); } return(cart); }
protected void bt_Submit_Click(object sender, EventArgs e) { if (!Save()) { return; } if ((int)ViewState["ID"] != 0) { ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]); Session["SubmitOrderApplyID"] = (int)ViewState["ID"]; if (bll.Model.State > 1) { Response.Redirect("OrderApplyList.aspx"); } if (bll.Items.Count == 0) { MessageBox.ShowAndRedirect(this, "对不起,定单申请明细不能为空!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } if (bll.Model.AccountMonth < AC_AccountMonthBLL.GetCurrentMonth()) { MessageBox.Show(this, "对不起,该订单申请月份已不是当前月份,已不可提交,请删除该单后重新申请赠品!"); return; } decimal totalcost = bll.Items.Sum(m => m.BookQuantity * m.Price); if (bll.Model.Type == 2) { //促销品申请 #region 判断预算额度余额是否够申请 ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(bll.Model.PublishID).Model; int productbrand = 0, giftclassify = 0; int.TryParse(publish["ProductBrand"], out productbrand); int.TryParse(publish["GiftClassify"], out giftclassify); decimal _budgetbalance = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, publish.FeeType); decimal _productbalance = ORD_GiftApplyAmountBLL.GetBalanceAmount(bll.Model.AccountMonth, bll.Model.Client, productbrand, giftclassify); decimal _balance = _productbalance; //2012-3-27 暂时限定赠品额度,不限定预算 //decimal _balance = (_budgetbalance > _productbalance ? _productbalance : _budgetbalance); string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' }); if (_balance < totalcost && !nolimitbrand.Contains(publish["ProductBrand"])) { if (bll.Model["GiftClassify"] == "2" && _balance > 0 && ORD_OrderApplyBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + bll.Model["ProductBrand"] + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)=" + bll.Model["GiftClassify"]).Count == 0) { //判断是否可以申请最低金额赠品1件 decimal MinApplyAmount = 0, MaxApplyAmount = 0; ORD_ApplyPublishBLL _publishbll = new ORD_ApplyPublishBLL(bll.Model.PublishID); _publishbll.GetMinApplyAmount(out MinApplyAmount, out MaxApplyAmount); if (_balance > 0 && _balance < MinApplyAmount) { if (bll.Items.Count > 1) { MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品"); return; } else { int applyproduct = bll.Items[0].Product; ORD_ApplyPublishDetail applydetail = _publishbll.Items.FirstOrDefault(p => p.Product == applyproduct); if (applydetail != null && applydetail.MinQuantity < bll.Items[0].BookQuantity) { MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品"); return; } } } else { MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } } else { MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } } #endregion #region 发起工作流 NameValueCollection dataobjects = new NameValueCollection(); dataobjects.Add("ID", ViewState["ID"].ToString()); dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString()); dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString()); dataobjects.Add("FeeType", publish.FeeType.ToString()); dataobjects.Add("ProductBrand", publish["ProductBrand"]); dataobjects.Add("GiftClassify", publish["GiftClassify"]); dataobjects.Add("TotalFee", totalcost.ToString()); int TaskID = EWF_TaskBLL.NewTask("CuXiaoPin_Apply", (int)Session["UserID"], "促销品申请申请流程", "~/SubModule/Logistics/Order/OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString() + "&Type=2", dataobjects); new EWF_TaskBLL(TaskID).Start(); #endregion bll.Submit((int)Session["UserID"], TaskID); Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString()); } else { //产品申请申请 bll.Submit((int)Session["UserID"], 0); Response.Redirect("OrderApplyList.aspx"); } } }
private bool Save() { ORD_ApplyPublishBLL _bll; if ((int)ViewState["ID"] != 0) { _bll = new ORD_ApplyPublishBLL((int)ViewState["ID"]); } else { _bll = new ORD_ApplyPublishBLL(); } pl_ApplyPublish.GetData(_bll.Model); #region 判断有效性 if (_bll.Model.Type == 2) { if (_bll.Model["ProductBrand"] == "0") { MessageBox.Show(this, "请选择【品牌】!"); return(false); } if (_bll.Model["GiftClassify"] == "0") { MessageBox.Show(this, "请选择【赠品费用类别】!"); return(false); } } #endregion #region 组织主题 if (_bll.Model.Topic == "") { DropDownList ddl_Type = (DropDownList)pl_ApplyPublish.FindControl("ORD_ApplyPublish_Type"); if (ddl_Type != null) { _bll.Model.Topic += ddl_Type.SelectedItem.Text + " "; } DropDownList ddl_AccountMonth = (DropDownList)pl_ApplyPublish.FindControl("ORD_ApplyPublish_AccountMonth"); if (ddl_AccountMonth != null) { _bll.Model.Topic += ddl_AccountMonth.SelectedItem.Text.Replace('-', '年') + "月 "; } DropDownList ddl_ProductBrand = (DropDownList)pl_ApplyPublish.FindControl("ORD_ApplyPublish_ProductBrand"); if (ddl_ProductBrand != null) { _bll.Model.Topic += ddl_ProductBrand.SelectedItem.Text + " "; } DropDownList ddl_GiftClassify = (DropDownList)pl_ApplyPublish.FindControl("ORD_ApplyPublish_GiftClassify"); if (ddl_GiftClassify != null) { _bll.Model.Topic += ddl_GiftClassify.SelectedItem.Text + " "; } } #endregion if ((int)ViewState["ID"] != 0) { if (_bll.Model.Type == 2 && _bll.Model.FeeType == 0) { //赠品所属费用类型 _bll.Model.FeeType = ConfigHelper.GetConfigInt("GiftFeeType"); } _bll.Model.UpdateStaff = int.Parse(Session["UserID"].ToString()); _bll.Update(); } else { #region 判断相同品牌的申请当月是否已存在 string condition = string.Format(@"AccountMonth={0} AND Type={1} AND ToOrganizeCity={2} AND MCS_SYS.dbo.UF_Spilt2('MCS_Logistics.dbo.ORD_ApplyPublish',ExtPropertys,'ProductBrand')='{3}' AND MCS_SYS.dbo.UF_Spilt2('MCS_Logistics.dbo.ORD_ApplyPublish',ExtPropertys,'GiftClassify')='{4}' ", _bll.Model.AccountMonth, _bll.Model.Type, _bll.Model.ToOrganizeCity, _bll.Model["ProductBrand"], _bll.Model["GiftClassify"]); if (ORD_ApplyPublishBLL.GetModelList(condition).Count > 0) { MessageBox.Show(this, "对不起,相同品牌相同类别的申请目录已发布了,请勿重复发布!"); return(false); } #endregion _bll.Model.State = 1; _bll.Model.ApproveFlag = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Add(); ViewState["ID"] = _bll.Model.ID; } #region 修改明细 foreach (GridViewRow row in gv_List.Rows) { ORD_ApplyPublishDetail item = new ORD_ApplyPublishDetail(); item.PublishID = _bll.Model.ID; item.ID = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()); item.Product = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString()); PDT_Product p = new PDT_ProductBLL(item.Product).Model; item.Price = p.FactoryPrice; if (row.FindControl("tbx_AvailableQuantity_T") != null) { item.AvailableQuantity = int.Parse(((TextBox)row.FindControl("tbx_AvailableQuantity_T")).Text) * p.ConvertFactor; } if (row.FindControl("tbx_MinQuantity_T") != null) { item.MinQuantity = int.Parse(((TextBox)row.FindControl("tbx_MinQuantity_T")).Text) * p.ConvertFactor; } if (row.FindControl("tbx_MaxQuantity_T") != null) { item.MaxQuantity = int.Parse(((TextBox)row.FindControl("tbx_MaxQuantity_T")).Text) * p.ConvertFactor; } if (row.FindControl("tbx_Remark") != null) { item.Remark = ((TextBox)row.FindControl("tbx_Remark")).Text; } if (row.FindControl("tbx_GiveLevel") != null) { item["GiveLevel"] = ((TextBox)row.FindControl("tbx_GiveLevel")).Text; } if (item.MaxQuantity > 0 && item.MinQuantity > item.MaxQuantity) { MessageBox.Show(this, "产品:" + p.FullName + "的【单次最小请购数量】不能大于【单次最大请购数量】!"); return(false); } if (item.MaxQuantity > 0 && item.AvailableQuantity > 0 && item.MaxQuantity > item.AvailableQuantity) { MessageBox.Show(this, "产品:" + p.FullName + "的【单次最大请购数量】不能大于【可供请购数量】!"); return(false); } _bll.UpdateDetail(item); } #endregion return(true); }