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

📄 branchstoresreturn.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 Model;
using BLL;
using System.Data;

namespace WebApplication1
{
    public partial class BranchStoresReturn : System.Web.UI.Page
    {
        DataTable dt;
        bool x = true;
        //实例化BLL层
        List<Model.Branch.Vendition_infoModel> show = new List<Model.Branch.Vendition_infoModel>();
        BLL.Goods.ProductBll productbllshow;
        BLL.Employee.EmployeeBll employeebllshow;
        BLL.Branch.VenditionBll venditionbllshow;
        BLL.Branch.Vendition_infoBll vendition_infobllshow;
        BLL.Store.StoreBll storebllshow;
        public BranchStoresReturn()
        {
            storebllshow=new BLL.Store.StoreBll ();
            productbllshow = new BLL.Goods.ProductBll();
            employeebllshow = new BLL.Employee.EmployeeBll();
            venditionbllshow = new BLL.Branch.VenditionBll();
            vendition_infobllshow = new BLL.Branch.Vendition_infoBll();
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //用户权限
                if (Session["employee_id"] == null)
                {
                    Response.Write("<script>alert('请您登陆系统');location.href='../Enter.aspx'</script>");
                }
                else 
                {
                    if (employeebllshow.UserRole(Session["role_id"].ToString(), "56") == true)
                    {
                        //将所有商品编号添加到DropDownList
                        List<Model.Goods.ProductModel> productid = productbllshow.SelectProductID();
                        foreach (var item in productid)
                        {
                            this.ddlProductID.Items.Add(item.product_id);
                        }
                        //分店编号在页面显示
                        List<Model.Employee.EmployeeModel> em = employeebllshow.ShopidSelect(Session["employee_id"].ToString());
                        foreach (Model.Employee.EmployeeModel item in em)
                        {
                            this.lblShop.Text = item.Shop_id.ToString();
                        }
                        //获取当天时间
                        this.lblInvoiceID.Text = "TH" + DateTime.Now.ToString("yyyyMMddhhmmssfff");
                        this.lblName.Text = Session["employee_id"].ToString();
                    }
                    else
                    {
                        Response.Write("<script>alert('你无权查看此功能,请与管理员联系');location.href='../Aboutus.aspx'</script>");
                    }
                }
            }
        }
        private void createDT()
        {
            dt = new DataTable();
            dt.Columns.Add("商品ID");
            dt.Columns.Add("商品名称");
            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("店铺");
        }
        //按照商品编号查找商品信息
        protected void ddlProductID_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.txtProductName.Text = "";
            this.txtSize1.Text = "";
            this.txtSize2.Text = "";
            this.txtSize3.Text = "";
            this.txtSize4.Text = "";
            this.txtSize5.Text = "";
            this.txtSize6.Text = "";
            this.txtSize7.Text = "";
            ddlColor.Items.Clear();
            this.lblShow.Visible = false;
            this.lblSum1.Visible = false;
            //获取商品信息
            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";
            }
        }
        //通过员工编号查询该店铺编号
        List< Model.Employee.EmployeeModel> employee;
        //提交
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            employee = employeebllshow.ShopidSelect(this.lblName.Text.Trim());

            if (ViewState["dt"] == null)
            {
                createDT();
            }
            else
            {
                dt = (DataTable)ViewState["dt"];
            }
            if (this.ddlProductID.SelectedValue == "请选择商品编号")
            {
                this.lblShowPID.Visible = true;
            }
            else
            {
                //通过登陆人查询店铺编号
                List<Model.Employee.EmployeeModel> em= employeebllshow.ShopidSelect(Session["employee_id"].ToString());
                foreach (Model.Employee.EmployeeModel item in em)
                {                      
                    //通过商品在库存中的编号,颜色以及库存编号查找尺码是否大于所填写的数据
                    Model.Store.StoreModel storemodel = storebllshow.SelectStoreByProduct(item.Shop_id,this.ddlProductID.Text,this.ddlColor.Text);    
                    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;
                    }
                    else
                    {
                        if (ViewState["dt"] == null)
                        {
                            createDT();
                        }
                        else
                        {
                            dt = (DataTable)ViewState["dt"];
                        }
                        DataRow dr = dt.NewRow();
                        dr[0] = this.ddlProductID.Text.Trim();
                        dr[1] = this.txtProductName.Text;
                        dr[2] = this.ddlColor.Text;
                        dr[3] = this.txtSize1.Text;
                        dr[4] = this.txtSize2.Text;
                        dr[5] = this.txtSize3.Text;
                        dr[6] = this.txtSize4.Text;
                        dr[7] = this.txtSize5.Text;
                        dr[8] = this.txtSize6.Text;
                        dr[9] = this.txtSize7.Text;
                        dr[10] = 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);
                        int ss1 = int.Parse(this.txtSize1.Text);
                        int ss2 = int.Parse(this.txtSize2.Text);
                        int ss3 = int.Parse(this.txtSize3.Text);
                        int ss4 = int.Parse(this.txtSize4.Text);
                        int ss5 = int.Parse(this.txtSize5.Text);
                        int ss6 = int.Parse(this.txtSize6.Text);
                        int ss7 = int.Parse(this.txtSize7.Text);
                        //foreach (Model.Employee.EmployeeModel it in employee)
                        //{

⌨️ 快捷键说明

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