Exemplo n.º 1
0
 /// <summary>
 /// 刷新全部信息
 /// </summary>
 public void refreshAll()
 {
     if (amo != null)
     {
         GridView1.DataSource = amo;
     }
     else
     {
         List <Amount> dcs = new DAL.AmountDAO().getAllAmounts();
         GridView1.DataSource = dcs;
     }
     GridView1.DataBind();
     refreEmpty();
 }
Exemplo n.º 2
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        List <string> wheresql = new List <string>();
        List <Amount> ins      = null;

        if (ListBox1.Text != "")            //判断物品类别是否选择
        {
            if (ListBox2.Text != "")
            {
                if (ListBox3.Text != "")
                {
                    wheresql.Add(" and goods.goodsTypeNum='" + ListBox3.SelectedValue.ToString() + "'");
                }
                else
                {
                    wheresql.Add(" and goods.goodsTypeNum='" + ListBox2.SelectedValue.ToString() + "'");
                }
            }
            else
            {
                wheresql.Add(" and goods.goodsTypeNum='" + ListBox1.SelectedValue.ToString() + "'");
            }
        }

        if (DropDownList1.Text != "")         //判断库柜是否选择
        {
            wheresql.Add(" and goods.goodsnum='" + DropDownList1.SelectedValue.ToString() + "'");
        }

        ins = new DAL.AmountDAO().getAmountsByWhere(wheresql);
        amo = ins;
        GridView1.DataSource = ins;
        GridView1.DataBind();
        new Warehouse.Tools.AddSysLog().addlog("1", "在库汇总", "查询");
        refreEmpty();
    }
    protected void Button6_Click(object sender, EventArgs e)            //添加出库按钮点击事件
    {
        cleaTitle();
        Button b = sender as Button;

        if (TextBox7.Text.Trim() == "" || TextBox8.Text.Trim() == "" || TextBox9.Text.Trim() == "" || TextBox10.Text.Trim() == "" || TextBox11.Text.Trim() == "" || TextBox12.Text.Trim() == "")
        {
            Response.Write("<script>alert('所有信息不能为空!')</script>");
        }
        else
        {
            bool condition = true;       //记录输入的东西是否符合条件,全都正确为true
            Inin i         = new DAL.IninDAO().getInsById(TextBox7.Text.Trim());
            if (i == null)
            {
                condition    = false;
                Label14.Text = "没有查询到此入库";
            }

            Goods  g  = new DAL.GoodsDAO().getGoodsByNum(TextBox8.Text.Trim());
            Amount am = null;
            if (g == null)
            {
                condition    = false;
                Label16.Text = "没有查询到此物品";
            }
            else
            {
                List <string> sql = new List <string>();
                sql.Add(" and positionNum ='" + i.PositionNum + "'");
                sql.Add(" and GoodsNum='" + g.GoodsNum + "'");
                am = new DAL.AmountDAO().getAmountsByWherePoAndGo(sql);
                if (am == null)
                {
                    condition    = false;
                    Label16.Text = "此物品在此库位无存货";
                }
                else if (am.Amounts <= 0)
                {
                    condition    = false;
                    Label16.Text = "此物品在此库位无存货";
                }
            }

            int outamount;
            try
            {
                outamount = int.Parse(TextBox9.Text.Trim());
                if (outamount <= 0)
                {
                    condition    = false;
                    outamount    = 0;
                    Label18.Text = "输入格式错误,请输入大于0的整数";
                }
                else if (am != null)
                {
                    if (am.Amounts < outamount)
                    {
                        condition    = false;
                        outamount    = 0;
                        Label18.Text = "库存数量小于出货数量";
                    }
                }
            }
            catch
            {
                condition    = false;
                outamount    = 0;
                Label18.Text = "输入格式错误,请输入整数";
            }

            Receiver re = new DAL.ReceiverDAO().getReceiverByNum(TextBox10.Text.Trim());
            if (re == null)
            {
                condition    = false;
                Label20.Text = "没有查询到此收货商";
            }

            if (TextBox11.Text.Length >= 100)
            {
                condition    = false;
                Label22.Text = "输入长度必须小于100";
            }

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

            if (condition)
            {
                if (b.Text != "确认修改")
                {
                    Batch bt = new Batch();
                    bt.BatchNum    = new Warehouse.Tools.batchNum().protect_batchNumByWPB("收货");
                    bt.ProorrecNum = TextBox10.Text.Trim();
                    bt.Condition   = "准备";
                    bt.OutorinType = "出库";
                    bool batchsucc = new DAL.BatchDao().addBatch(bt);
                    new Warehouse.Tools.AddSysLog().addlog("1", "批次", "添加");
                    Outout oo = new Outout();
                    oo.PositionNum = i.PositionNum;
                    oo.GoodsNum    = TextBox8.Text.Trim();
                    oo.OutAmount   = outamount;
                    oo.Remark      = TextBox11.Text.Trim();
                    oo.Date        = dt;
                    bool outoutsucc = new DAL.OutoutDAO().addOut(oo);
                    if (batchsucc && outoutsucc)
                    {
                        new Warehouse.Tools.AddSysLog().addlog("1", "未完成出库", "添加");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true);
                        addOut.Visible = true;
                        refreAllOut();
                        clea();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true);
                    }
                }
                else
                {
                    Outout oo = new Outout();
                    oo.PositionNum = TextBox1.Text.Trim();
                    oo.GoodsNum    = TextBox2.Text.Trim();
                    oo.OutAmount   = outamount;
                    oo.Remark      = TextBox5.Text.Trim();
                    oo.Date        = dt;
                    oo.OuID        = outID;
                    oo.BatchNum    = outBatch;
                    oo.UserId      = "1";
                    bool ininsucc = new DAL.OutoutDAO().updateOut(oo);
                    if (ininsucc)
                    {
                        new Warehouse.Tools.AddSysLog().addlog("1", "未完成出库", "修改");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true);

                        addIn.Visible     = false;
                        GridView2.Visible = true;
                        refreAllIn();
                        outID    = null;
                        outBatch = null;
                        clea();
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true);
                    }
                }
            }
            else
            {
            }
        }
    }