protected void ddl_Brand_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (tr_OrganizeCity.SelectValue != "0")
        {
            DataTable dt = TreeTableBLL.GetFullPath("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "SuperID", int.Parse(tr_OrganizeCity.SelectValue));

            string citys = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                citys += dt.Rows[i]["ID"].ToString();

                if (i < dt.Rows.Count - 1)
                {
                    citys += ",";
                }
            }
            string condition = "ToOrganizeCity IN (" + citys + ") AND GETDATE() BETWEEN BeginTime AND DateAdd(day,1,EndTime) AND State=2 AND Type=" + rbl_Type.SelectedValue + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',1)=" + ddl_Brand.SelectedValue;
            IList <ORD_ApplyPublish> list = ORD_ApplyPublishBLL.GetModelList(condition);
            ddl_Publish.DataTextField  = "Topic";
            ddl_Publish.DataValueField = "ID";
            ddl_Publish.DataSource     = list;
            ddl_Publish.DataBind();
            if (list.Count == 0)
            {
                ddl_Publish.Items.Insert(0, new ListItem("当前无可以申请的产品目录", "0"));
                bt_Confirm.Enabled = false;
            }
            else
            {
                bt_Confirm.Enabled = true;
            }
        }
    }
예제 #2
0
    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);
    }