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

📄 selectstocklist.aspx.cs

📁 c#三层架构项目开发的全过程
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 金利来分销管理系统.Stock
{
    public partial class SelectStockList : System.Web.UI.Page
    {
        //实例化BLL
        BLL.Store.StoreBll storebllshow;
        BLL.Stock.StockFormBll stockformbllshow;
        BLL.Stock.Stock_SetailsBll stocksetailbllshow;
        BLL.Employee.EmployeeBll employeebllshow;

        public SelectStockList()
        {
            storebllshow = new BLL.Store.StoreBll();
            stockformbllshow = new BLL.Stock.StockFormBll();
            stocksetailbllshow = new BLL.Stock.Stock_SetailsBll();
            employeebllshow = new BLL.Employee.EmployeeBll();
        }
     
        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(), "47") == true)
                    {
                        //显示所有采购单据
                        this.gvShow.DataSource = stockformbllshow.StockFormSelectByWhere();
                        this.gvShow.DataBind();
                    }
                    else
                    {
                        Response.Write("<script>alert('你无权查看此功能,请与管理员联系');location.href='../Aboutus.aspx'</script>");
                    }
                }
            }
        }
        //查询采购单据信息按钮事件
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            ShowMethod();
        }

        private void ShowMethod()
        {
            //实例化采购单据泛型集合
            List<Model.Stock.StockFormModel> mo = stockformbllshow.StockFormSelectByWhere();
            //按采购单据编号查找
            if (ddlStockFormID.SelectedValue != "请选择采购单据号")
            {
                mo = mo.FindAll(o => o.stockform_id == this.ddlStockFormID.Text.Trim());
            }
            //按审核状态
            if (ddlOKType.SelectedIndex != 0)
            {
                mo = mo.FindAll(o => o.stockform_oktext == this.ddlOKType.Text.Trim());
            }
            this.gvShow.DataSource = mo;
            this.gvShow.DataBind();
        }
        
        //删除采购单据以及明细
        protected void gvShow_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //要删除行的ID
            string id = this.gvShow.Rows[e.RowIndex].Cells[0].Text;
            //要删除行的审核状态
            string status = this.gvShow.Rows[e.RowIndex].Cells[6].Text.Trim ();
            if (status == "未通过")
            {
                stocksetailbllshow.StockSetailDelete(id);
                stockformbllshow.StockFormDelete(id, "未通过");
                Response.Write("<script>alert('删除成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('该单据已被审核,不能进行删除')</script>");
            }
        }
        //按时间查找采购单据按钮事件
        protected void btnSele_Click(object sender, EventArgs e)
        {                //清空采购单据编号
            this.ddlStockFormID.Items.Clear();

            if (this.txtTime.Text == "")
            {
                this.lblTime.Visible = true;
            }
            else
            {
                this.lblTime.Visible = false ;
                //实例化采购明细(通过时间)
                List<Model.Stock.Stock_SetailsModel> stockid = storebllshow.SelectStockFormIDByTime(DateTime.Parse(this.txtTime.Text));
                //查询所有采购单据编号
                foreach (var item in stockid)
                {
                    this.ddlStockFormID.Items.Add(item.stockform_id);
                }
                if (ddlStockFormID.Text == "")
                {
                    this.gvShow.DataSource = null;
                    this.gvShow.DataBind();
                }
            }
        }
        //分页
        protected void gvShow_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.gvShow.PageIndex = e.NewPageIndex;
            ShowMethod();
        }
       
    }
}

⌨️ 快捷键说明

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