⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 removeadd.aspx.cs

📁 c#三层架构项目开发的全过程
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Model;
namespace 金利来分销管理系统.Remove
{
    public partial class RemoveAdd : System.Web.UI.Page
    {
        bool x = true;
        DataTable dt;
        //实例化的BLL层
        BLL.Remove.RemoveBll bllshow;
        BLL.Goods.ProductBll productbllshow;
        BLL.Store.StoreBll storeIDshow;
        List<Model.Remove.RemoveModel> show = new List<Model.Remove.RemoveModel>();
        public RemoveAdd()
        {
            bllshow = new BLL.Remove.RemoveBll();
            productbllshow = new BLL.Goods.ProductBll();
            storeIDshow = new BLL.Store.StoreBll();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //将所有商品编号添加到DropDownList
                List<Model.Goods.ProductModel> productid = productbllshow.SelectProductID();
                foreach (var item in productid)
                {
                    this.ddlProductID.Items.Add(item.product_id);
                }
                //获取当天时间
                this.lblRemoveID.Text = "DB" + DateTime.Now.ToString("yyyyMMddhhmmssfff");
                //将所有分店编号添加到DropDownList
                List<Model.Store.StoreModel> storeid = storeIDshow.SelectStoreID();
                foreach (var item in storeid)
                {
                    this.ddlstorego.Items.Add(item.store_id.ToString());
                    this.ddlstoreto.Items.Add(item.store_id.ToString());
                }
            }
        }
        private void createDT()
        {
            
            dt = new DataTable();
            dt.Columns.Add("商品ID");
            dt.Columns.Add("商品颜色");
            dt.Columns.Add("31");
            dt.Columns.Add("32");
            dt.Columns.Add("33");
            dt.Columns.Add("34");
            dt.Columns.Add("35");
            dt.Columns.Add("36");
            dt.Columns.Add("37");
            dt.Columns.Add("数量");
            dt.Columns.Add("始");
            dt.Columns.Add("至");
        }
        //通过商品ID查询该商品信息
        protected void ddlProductID_SelectedIndexChanged(object sender, EventArgs e)
        {
            //当未选择商品编号时
            if (this.ddlProductID.Text == "请选择商品编号")
            {
                //提示“请选择商品编号”
                this.lblproductidcheck.Visible = true;
            }
            else
            {
                //提示框“请选择商品编号”
                this.lblproductidcheck.Visible = false;
            }
            //颜色框的值清空
            ddlColor.Items.Clear();
            txtProductName.Text = "";
            //获取商品信息
            List<Model.Goods.ProductModel> p = productbllshow.SelectProductByID(this.ddlProductID.Text);
            foreach (Model.Goods.ProductModel item in p)
            {
                ddlColor.Items.Add(item.producttype_color);
                this.txtProductName.Text = item.product_name;
                this.lblsize1.Text = item.producttype_s1.ToString();
                this.lblsize2.Text = item.producttype_s2.ToString();
                this.lblsize3.Text = item.producttype_s3.ToString();
                this.lblsize4.Text = item.producttype_s4.ToString();
                this.lblsize5.Text = item.producttype_s5.ToString();
                this.lblsize6.Text = item.producttype_s6.ToString();
                this.lblsize7.Text = item.producttype_s7.ToString();
            }
            this.txtSize1.Text = "0";
            this.txtSize2.Text = "0";
            this.txtSize3.Text = "0";
            this.txtSize4.Text = "0";
            this.txtSize5.Text = "0";
            this.txtSize6.Text = "0";
            this.txtSize7.Text = "0";
        }
        //提交申请单到ViewState["dt"]
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            this.lblSum.Visible = false;
            this.lblShow.Visible = false;
            
            //当商品编号选择为‘请选择商品编号’
            if (this.ddlProductID.SelectedValue != "请选择商品编号")
            {
                //发货仓库和接受仓库都有选择时
                if (this.ddlstorego.Text != "请选择门店编号" && this.ddlstoreto.Text != "请选择门店编号")
                {
                    if (ViewState["dt"] == null)
                    {
                        createDT();
                    }
                    else
                    {
                        dt = (DataTable)ViewState["dt"];
                    }
                    
                    DataRow dr = dt.NewRow();
                    dr[0] = this.ddlProductID.Text.Trim();
                    dr[1] = this.ddlColor.Text;
                    dr[2] = this.txtSize1.Text;
                    dr[3] = this.txtSize2.Text;
                    dr[4] = this.txtSize3.Text;
                    dr[5] = this.txtSize4.Text;
                    dr[6] = this.txtSize5.Text;
                    dr[7] = this.txtSize6.Text;
                    dr[8] = this.txtSize7.Text;
                    dr[9] = Convert.ToInt32(this.txtSize1.Text) + Convert.ToInt32(this.txtSize2.Text) + Convert.ToInt32(this.txtSize3.Text) + Convert.ToInt32(this.txtSize4.Text) + Convert.ToInt32(this.txtSize5.Text) + Convert.ToInt32(this.txtSize6.Text) + Convert.ToInt32(this.txtSize7.Text);
                    dr[10] = this.ddlstorego.Text;
                    dr[11] = this.ddlstoreto.Text;
                    int s1 = int.Parse(this.txtSize1.Text);
                    int s2 = int.Parse(this.txtSize2.Text);
                    int s3 = int.Parse(this.txtSize3.Text);
                    int s4 = int.Parse(this.txtSize4.Text);
                    int s5 = int.Parse(this.txtSize5.Text);
                    int s6 = int.Parse(this.txtSize6.Text);
                    int s7 = int.Parse(this.txtSize7.Text);
                    //如果数量都是为“零”
                    if (int.Parse(dr[9].ToString()) == 0)
                    {
                        this.lblSum.Visible = true;
                    }
                    //大于零的时候
                    else
                    {
                        //通过商品在库存中
                        Model.Store.StoreModel storemodel = storeIDshow.SelectStoreByProduct(int.Parse(this.ddlstorego.Text), this.ddlProductID.Text, this.ddlColor.Text);
                        //在dt表里的每一行循环
                        foreach (DataRow item in dt.Rows)
                        {
                            //提交的信息,与dt表里存在的信息做对比
                            if (int.Parse(this.ddlstorego.Text) == Convert.ToInt32(item[10]) && this.ddlProductID.Text.Trim() == item[0].ToString() && this.ddlColor.Text.Trim() == item[1].ToString())
                            {
                                //开始记录该仓库,该商品,该颜色,在dt表里已存在的尺码数量
                                s1 += Convert.ToInt32(item[2]);
                                s2 += Convert.ToInt32(item[3]);
                                s3 += Convert.ToInt32(item[4]);
                                s4 += Convert.ToInt32(item[5]);
                                s5 += Convert.ToInt32(item[6]);
                                s6 += Convert.ToInt32(item[7]);
                                s7 += Convert.ToInt32(item[8]);
                                //该仓库,该商品,该颜色的信息,是否小于(提交的信息加dt表里所对应的信息)
                                if (storemodel.store_size1 < s1 || storemodel.store_size2 < s2 || storemodel.store_size3 < s3 || storemodel.store_size4 < s4 || storemodel.store_size5 < s5 || storemodel.store_size6 < s6 || storemodel.store_size7 < s7)
                                {
                                    this.lblShow.Visible = true;
                                    //如果小于添加的数额,跳出
                                    return;
                                }
                            }
                        }
                        //判断每次提交的数量,是否是小于仓库的数量
                        if (storemodel.store_size1 < int.Parse(this.txtSize1.Text) || storemodel.store_size2 < int.Parse(this.txtSize2.Text) || storemodel.store_size3 < int.Parse(this.txtSize3.Text) || storemodel.store_size4 < int.Parse(this.txtSize4.Text) || storemodel.store_size5 < int.Parse(this.txtSize5.Text) || storemodel.store_size6 < int.Parse(this.txtSize6.Text) || storemodel.store_size7 < int.Parse(this.txtSize7.Text))
                        {
                            this.lblShow.Visible = true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -