コード例 #1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "editt")
        {
            int         xy  = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = GridView1.Rows[xy];

            search.Visible = false;
            add.Visible    = true;
            Button3.Text   = "确定修改";
            TextBox2.Text  = row.Cells[2].Text;
            TextBox6.Text  = row.Cells[3].Text;
            TextBox3.Text  = row.Cells[4].Text;
            TextBox4.Text  = row.Cells[5].Text;
            TextBox5.Text  = row.Cells[6].Text;
            num            = row.Cells[1].Text;
            providerName   = row.Cells[2].Text;
        }
        if (e.CommandName == "deletee")
        {
            int    x       = Convert.ToInt32(e.CommandArgument);
            string dataid  = GridView1.Rows[x].Cells[2].Text;
            bool   success = new DAL.ProviderDAO().deleteProviderByName(dataid);
            if (success)
            {
                new Warehouse.Tools.AddSysLog().addlog("1", "供应商管理", "删除");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
            }
            refresh();
        }
    }
コード例 #2
0
    public void refresh()               //刷新函数,查找并显示全部的供应商的信息
    {
        if (name == null || name == "") //判断name里面存的有没有值,有的话说明刚才查询过,现在gridview显示的查询名字后的,刷新的时候就不能查询全部
        {
            GridView1.DataSource = pros;
            GridView1.DataBind();
            countPageIndex = pros.Count / 11 + 1;
            Label8.Text    = "总记录数:" + pros.Count;
            Label9.Text    = "总页数:" + countPageIndex;
            Label10.Text   = "当前页:" + PageIndex;
        }
        else
        {
            List <Provider> pross = new List <Provider>();           //若获取的单个对象,需要添加到集合中,因为gridview的数据源不支持单个对象
            Provider        pro   = new DAL.ProviderDAO().getProviderByName(name);
            if (pro == null)
            {
            }
            else
            {
                pross.Add(pro);
            }
            GridView1.DataSource = pross;
            GridView1.DataBind();
            countPageIndex = 1;
            PageIndex      = 1;
            Label8.Text    = "总记录数:" + pross.Count;
            Label9.Text    = "总页数:1";
            Label10.Text   = "当前页:" + PageIndex;
        }

        if (GridView1.Rows.Count == 0)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ProviderNum");
            dt.Columns.Add("ProviderName");
            dt.Columns.Add("Leader");
            dt.Columns.Add("Contact");
            dt.Columns.Add("ContactNumber");
            dt.Columns.Add("ProviderAddress");
            dt.Columns.Add("CreateTime");
            dt.Columns.Add("UpdateTime");
            dt.Rows.Add(dt.NewRow());
            this.GridView1.DataSource = dt;
            this.GridView1.DataBind();
            GridView1.Rows[0].Cells.Clear();
            GridView1.Rows[0].Cells.Add(new TableCell());
            GridView1.Rows[0].Cells[0].ColumnSpan = dt.Columns.Count + 3;
            GridView1.Rows[0].Cells[0].Text       = "您查询的信息为空";
            GridView1.Rows[0].Cells[0].Style.Add("text-align", "center");
            Label8.Text  = "总记录数:0";
            Label9.Text  = "总页数:0";
            Label10.Text = "";
        }
    }
コード例 #3
0
    protected void Button4_Click(object sender, EventArgs e)        //入库确定添加按钮点击事件
    {
        cleaTitle();
        Button b = sender as Button;

        if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "" || TextBox3.Text.Trim() == "" || TextBox4.Text.Trim() == "" || TextBox5.Text.Trim() == "" || TextBox6.Text.Trim() == "")
        {
            Response.Write("<script>alert('所有信息不能为空!')</script>");
        }
        else
        {
            bool     condition = true;   //记录输入的东西是否符合条件,全都正确为true
            Position p         = new DAL.PositionDAO().getPositionByNum(TextBox1.Text.Trim());
            if (p == null)
            {
                condition   = false;
                Label2.Text = "没有查询到此库位";
            }

            Goods g = new DAL.GoodsDAO().getGoodsByNum(TextBox2.Text.Trim());
            if (g == null)
            {
                condition   = false;
                Label4.Text = "没有查询到此物品";
            }

            int inamount;
            try
            {
                inamount = int.Parse(TextBox3.Text.Trim());
                if (inamount <= 0)
                {
                    int.Parse("测试");
                }
            }
            catch
            {
                condition   = false;
                inamount    = 0;
                Label6.Text = "输入格式错误,请输入大于0的整数";
            }

            Provider pr = new DAL.ProviderDAO().getProviderByNum(TextBox4.Text.Trim());
            if (pr == null)
            {
                condition   = false;
                Label8.Text = "没有查询到此供应商";
            }

            if (TextBox5.Text.Length >= 100)
            {
                condition    = false;
                Label10.Text = "输入长度大于100";
            }

            DateTime dt;
            try
            {
                dt = DateTime.Parse(TextBox6.Text.Trim());
                if (b.Text != "确认修改")
                {
                    if (dt < DateTime.Now)
                    {
                        condition    = false;
                        Label12.Text = "输入日期必须大于等于今天的日期";
                    }
                }
            }
            catch
            {
                condition    = false;
                dt           = DateTime.Parse("2018-8-8");
                Label12.Text = "输入日期的格式不正确";
            }

            if (condition)
            {
                if (b.Text != "确认修改")
                {
                    Batch bt = new Batch();
                    bt.BatchNum    = new Warehouse.Tools.batchNum().protect_batchNumByWPB("供货");
                    bt.ProorrecNum = TextBox4.Text.Trim();
                    bt.Condition   = "准备";
                    bt.OutorinType = "入库";
                    bool batchsucc = new DAL.BatchDao().addBatch(bt);
                    new Warehouse.Tools.AddSysLog().addlog("1", "批次", "添加");
                    Inin ii = new Inin();
                    ii.PositionNum = TextBox1.Text.Trim();
                    ii.GoodsNum    = TextBox2.Text.Trim();
                    ii.InAmount    = inamount;
                    ii.Remark      = TextBox5.Text.Trim();
                    ii.Date        = dt;
                    bool ininsucc = new DAL.IninDAO().addIn(ii);
                    if (batchsucc && ininsucc)
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true);
                        new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "添加");
                        addIn.Visible = false;

                        refreAllIn();

                        clea();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true);
                    }
                }
                else
                {
                    Inin ii = new Inin();
                    ii.PositionNum = TextBox1.Text.Trim();
                    ii.GoodsNum    = TextBox2.Text.Trim();
                    ii.InAmount    = inamount;
                    ii.Remark      = TextBox5.Text.Trim();
                    ii.Date        = dt;
                    ii.InID        = inID;
                    ii.BatchNum    = inBatch;
                    ii.UserId      = "1";
                    bool ininsucc = new DAL.IninDAO().updateIn(ii);
                    if (ininsucc)
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true);
                        new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "修改");
                        addIn.Visible     = false;
                        GridView2.Visible = true;
                        refreAllIn();
                        inID    = null;
                        inBatch = null;
                        clea();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true);
                    }
                }
            }
            else
            {
            }
        }
    }
コード例 #4
0
    /// <summary>
    /// 绑定下拉框的数据
    /// </summary>
    public void refredatabind()
    {
        ListItem lt1 = new ListItem();

        lt1.Value = "";
        /*        绑定供应商        */
        List <Provider> ps = new DAL.ProviderDAO().getAllProviders();

        ListBox6.DataSource     = ps;
        ListBox6.DataTextField  = "providerName";
        ListBox6.DataValueField = "providerNum";
        ListBox6.DataBind();

        ListBox6.Items.Add(lt1);
        ListBox6.SelectedValue = "";

        /*             绑定库柜        */
        List <Chest> cs = new DAL.ChestDAO().getAllChests();

        ListBox4.DataSource     = cs;
        ListBox4.DataTextField  = "chestName";
        ListBox4.DataValueField = "chestNum";
        ListBox4.DataBind();

        ListBox4.Items.Add(lt1);
        ListBox4.SelectedValue = "";

        /*                绑定经办人           */
        List <SysUser> sys = new DAL.SysUserDAO().getAllUsers();

        ListBox5.DataSource     = sys;
        ListBox5.DataTextField  = "userId";
        ListBox5.DataValueField = "staffnum";
        ListBox5.DataBind();

        ListBox5.Items.Add(lt1);
        ListBox5.SelectedValue = "";


        /*             绑定物品类别第一项        */
        List <GoodsType> gts = new DAL.GoodsTypeDAO().getParentGoodsTypes();

        ListBox1.DataSource     = gts;
        ListBox1.DataTextField  = "goodsTypeName";
        ListBox1.DataValueField = "goodsTypeNum";
        ListBox1.DataBind();

        ListBox1.Items.Add(lt1);
        ListBox1.SelectedValue = "";


        /*            绑定gridview数据源            */
        BoundField bf1 = new BoundField(); bf1.HeaderText = "序号";
        BoundField bf2 = new BoundField(); bf2.DataField = "inID"; bf2.HeaderText = "编号";
        BoundField bf3 = new BoundField(); bf3.DataField = "goods.goodsName"; bf3.HeaderText = "物品名称";
        BoundField bf4 = new BoundField(); bf4.DataField = "goods.goodsType.goodsTypeName"; bf4.HeaderText = "物品类别";
        BoundField bf5 = new BoundField(); bf5.DataField = "position.positionNum"; bf5.HeaderText = "库位编号";
        BoundField bf6 = new BoundField(); bf6.DataField = "date"; bf6.HeaderText = "入库时间";
        BoundField bf7 = new BoundField(); bf7.DataField = "inAmount"; bf7.HeaderText = "入库量";
        BoundField bf8 = new BoundField(); bf8.DataField = "batch.provider.providername"; bf8.HeaderText = "供应商";
        BoundField bf9 = new BoundField(); bf9.DataField = "sysuser.staff.staffname"; bf9.HeaderText = "经办人";

        GridView1.Columns.Add(bf1);
        GridView1.Columns.Add(bf2);
        GridView1.Columns.Add(bf3);
        GridView1.Columns.Add(bf4);
        GridView1.Columns.Add(bf5);
        GridView1.Columns.Add(bf6);
        GridView1.Columns.Add(bf7);
        GridView1.Columns.Add(bf8);
        GridView1.Columns.Add(bf9);

        BoundField bf11 = new BoundField(); bf11.HeaderText = "序号";
        BoundField bf12 = new BoundField(); bf12.DataField = "ouID"; bf12.HeaderText = "编号";
        BoundField bf13 = new BoundField(); bf13.DataField = "goods.goodsName"; bf13.HeaderText = "物品名称";
        BoundField bf14 = new BoundField(); bf14.DataField = "goods.goodsType.goodsTypeName"; bf14.HeaderText = "物品类别";
        BoundField bf15 = new BoundField(); bf15.DataField = "position.positionNum"; bf15.HeaderText = "库位编号";
        BoundField bf16 = new BoundField(); bf16.DataField = "date"; bf16.HeaderText = "出库时间";
        BoundField bf17 = new BoundField(); bf17.DataField = "outAmount"; bf17.HeaderText = "出库量";
        BoundField bf18 = new BoundField(); bf18.DataField = "batch.receiver.receivername"; bf18.HeaderText = "收货商";
        BoundField bf19 = new BoundField(); bf19.DataField = "sysuser.staff.staffname"; bf19.HeaderText = "经办人";

        GridView2.Columns.Add(bf11);
        GridView2.Columns.Add(bf12);
        GridView2.Columns.Add(bf13);
        GridView2.Columns.Add(bf14);
        GridView2.Columns.Add(bf15);
        GridView2.Columns.Add(bf16);
        GridView2.Columns.Add(bf17);
        GridView2.Columns.Add(bf18);
        GridView2.Columns.Add(bf19);
    }
コード例 #5
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        if (TextBox2.Text.Trim() == "" || TextBox3.Text.Trim() == "" || TextBox4.Text.Trim() == "" || TextBox5.Text.Trim() == "" || TextBox6.Text.Trim() == "")
        {
            Response.Write("<script>alert('信息都不能为空!')</script>");
        }
        else
        {
            if (num != null)            //判断num是否为空,不为空则说明是要修改信息,而不是添加
            {
                Provider p = new Provider();
                p.ProviderNum  = num;
                p.ProviderName = TextBox2.Text.Trim();
                if (providerName != TextBox2.Text.Trim())           //判断名字修改了没有(即和修改前记录的是否一样),如果名字改了需要判断是否重复
                {
                    bool exit = new DAL.ProviderDAO().hasProviderOfName(p.ProviderName);
                    if (exit)              //如果重复就提示
                    {
                        Response.Write("<script>alert('供货商名字重复,请重新输入!')</script>");
                    }
                    else
                    {
                        p.Leader          = TextBox6.Text.Trim();
                        p.Contact         = TextBox3.Text.Trim();
                        p.ContactNumber   = TextBox4.Text.Trim();
                        p.ProviderAddress = TextBox5.Text.Trim();
                        p.UpdateTime      = DateTime.Now;
                        bool success = new DAL.ProviderDAO().updateProvider(p);
                        if (success)
                        {
                            new Warehouse.Tools.AddSysLog().addlog("1", "供应商管理", "修改");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true);
                        }
                        else
                        {
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true);
                        }
                        num = null;
                    }
                }
                else
                {
                    p.Leader          = TextBox6.Text.Trim();
                    p.Contact         = TextBox3.Text.Trim();
                    p.ContactNumber   = TextBox4.Text.Trim();
                    p.ProviderAddress = TextBox5.Text.Trim();
                    p.UpdateTime      = DateTime.Now;
                    bool success = new DAL.ProviderDAO().updateProvider(p);
                    if (success)
                    {
                        new Warehouse.Tools.AddSysLog().addlog("1", "供应商管理", "修改");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true);
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true);
                    }
                    num = null;
                }
            }
            else
            {
                Provider p = new Provider();

                p.ProviderNum  = Warehouse.Controllor.ProviderControl.GetNum();
                p.ProviderName = TextBox2.Text.Trim();
                bool exit = new DAL.ProviderDAO().hasProviderOfName(p.ProviderName);
                if (exit)
                {
                    Response.Write("<script>alert('供货商名字重复,请重新输入!')</script>");
                }
                else
                {
                    p.Contact         = TextBox3.Text.Trim();
                    p.ContactNumber   = TextBox4.Text.Trim();
                    p.ProviderAddress = TextBox5.Text.Trim();
                    p.UpdateTime      = DateTime.Now;
                    p.Leader          = TextBox6.Text.Trim();
                    p.CreateTime      = DateTime.Now;
                    bool success = new DAL.ProviderDAO().addProvider(p);               //调用DAL层的添加方法

                    if (success)
                    {
                        new Warehouse.Tools.AddSysLog().addlog("1", "供应商管理", "添加");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true);
                        TextBox2.Text  = "";
                        TextBox6.Text  = "";
                        TextBox3.Text  = "";
                        TextBox4.Text  = "";
                        TextBox5.Text  = "";
                        search.Visible = true;
                        add.Visible    = false;
                        refresh();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true);
                    }
                }
            }
        }
    }