Example #1
0
        /// <summary>
        /// 添加一个库位类型.库位类型ID是主键.
        /// </summary>
        /// <param name="posity">库位类型对象.</param>
        /// <returns>通过布尔类型判断操作是否成功.</returns>
        public bool addPositionType(Model.PositionType posity)
        {
            string sqltext               = "insert positiontype(num,positionTypeId,positionTypeName,length,width,height,remark) values(@num,@positionTypeId,@positionTypeName,@length,@width,@height,@remark)";
            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara  = new SqlParameter("@num", posity.Num);
            SqlParameter        sqlpara1 = new SqlParameter("@positionTypeId", posity.PositionTypeId);
            SqlParameter        sqlpara2 = new SqlParameter("@positionTypeName", posity.PositionTypeName);
            SqlParameter        sqlpara3 = new SqlParameter("@length", posity.Length);
            SqlParameter        sqlpara4 = new SqlParameter("@width", posity.Width);
            SqlParameter        sqlpara5 = new SqlParameter("@height", posity.Height);
            SqlParameter        sqlpara6 = new SqlParameter("@remark", posity.Remark);

            para.Add(sqlpara);
            para.Add(sqlpara1);
            para.Add(sqlpara2);
            para.Add(sqlpara3);
            para.Add(sqlpara4);
            para.Add(sqlpara5);
            para.Add(sqlpara6);
            int i = DBTools.exenonquerySQL(sqltext, para);

            if (i == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 更新某个库位.库位ID不可更改.
        /// </summary>
        /// <param name="posity">库位类型对象.</param>
        public bool updatePositionType(Model.PositionType posity)
        {
            string sqltext               = "update positiontype set positionTypeName=@positionTypeName,length=@length,width=@width,height=@height,remark=@remark where positionTypeId=@positionTypeId";
            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara1 = new SqlParameter("@positionTypeId", posity.PositionTypeId);
            SqlParameter        sqlpara2 = new SqlParameter("@positionTypeName", posity.PositionTypeName);
            SqlParameter        sqlpara3 = new SqlParameter("@length", posity.Length);
            SqlParameter        sqlpara4 = new SqlParameter("@width", posity.Width);
            SqlParameter        sqlpara5 = new SqlParameter("@height", posity.Height);
            SqlParameter        sqlpara6 = new SqlParameter("@remark", posity.Remark);

            para.Add(sqlpara2);
            para.Add(sqlpara3);
            para.Add(sqlpara4);
            para.Add(sqlpara5);
            para.Add(sqlpara6);
            para.Add(sqlpara1);
            int i = DBTools.exenonquerySQL(sqltext, para);

            if (i == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "editt")
     {
         Image1.Visible = true;
         Image2.Visible = true;
         Image3.Visible = true;
         Image4.Visible = true;
         Image5.Visible = true;
         Image6.Visible = true;
         int xy = Convert.ToInt32(e.CommandArgument);
         Div1.Visible      = true;
         Button9.Text      = "确定";
         GridView1.Visible = false;
         if (GridView1.Visible == true)
         {
             Button1.Visible  = true;
             Button4.Visible  = true;
             Button5.Visible  = true;
             ListBox1.Visible = true;
             TextBox1.Visible = true;
         }
         else if (GridView1.Visible == false)
         {
             Button1.Visible  = false;
             Button4.Visible  = false;
             Button5.Visible  = false;
             ListBox1.Visible = false;
             TextBox1.Visible = false;
         }
         TextBox10.Text = GridView1.Rows[xy].Cells[1].Text;
         Model.PositionType pos = new DAL.PositionTypeDAO().getPositionTypeByid(GridView1.Rows[xy].Cells[1].Text);
         TextBox11.Text     = pos.PositionTypeName;
         TextBox12.Text     = pos.Length;
         TextBox13.Text     = pos.Width;
         TextBox14.Text     = pos.Height;
         TextBox15.Text     = pos.Remark;
         TextBox10.ReadOnly = true;
     }
     if (e.CommandName == "deletee")
     {
         Model.PositionType delete = new Model.PositionType();
         int x = Convert.ToInt32(e.CommandArgument);
         delete.PositionTypeId = GridView1.Rows[x].Cells[1].Text;
         bool yy = new DAL.ChestDAO().deleteChestByNum(delete.PositionTypeId);
         if (yy)
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
             rg.Refresh("select * from Positiontype order by num", "PositionTypeId", GridView1);
         }
         else
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
         }
     }
 }
Example #4
0
        /// <summary>
        /// 获取所有的库位类型.
        /// </summary>
        /// <returns>库位类型对象泛型集合.</returns>
        public List <Model.PositionType> getAllPositionsType()
        {
            List <Model.PositionType> posity = new List <Model.PositionType>();
            string        sqltext            = "select * from positiontype";
            SqlDataReader sdr = DBTools.exereaderSQL(sqltext, new List <SqlParameter>());

            while (sdr.Read())
            {
                Model.PositionType p = new Model.PositionType();
                p.PositionTypeId   = sdr["positionTypeId"].ToString();
                p.PositionTypeName = sdr["positionTypeName"].ToString();
                p.Length           = sdr["length"].ToString();
                p.Width            = sdr["width"].ToString();
                p.Height           = sdr["height"].ToString();
                p.Remark           = sdr["remark"].ToString();

                posity.Add(p);
            }
            sdr.Close();
            DBTools.DBClose();
            return(posity);
        }
Example #5
0
        /// <summary>
        /// 通过ID找到库位类型.
        /// </summary>
        /// <param name="iid">库位类型ID.</param>
        public Model.PositionType getPositionTypeByid(string iid)
        {
            Model.PositionType  p        = null;
            string              sqltext  = "select * from positiontype where positionTypeId=@positionTypeId";
            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara1 = new SqlParameter("@positionTypeId", iid);

            para.Add(sqlpara1);
            SqlDataReader sdr = DBTools.exereaderSQL(sqltext, para);

            while (sdr.Read())
            {
                p = new Model.PositionType();
                p.PositionTypeId   = sdr["positionTypeId"].ToString();
                p.PositionTypeName = sdr["positionTypeName"].ToString();
                p.Length           = sdr["length"].ToString();
                p.Width            = sdr["width"].ToString();
                p.Height           = sdr["height"].ToString();
                p.Remark           = sdr["remark"].ToString();
            }
            sdr.Close();
            DBTools.DBClose();
            return(p);
        }
        protected void Button9_Click(object sender, EventArgs e)
        {
            switch (Button9.Text)
            {
            case "增加":
            {
                if (Image1.ImageUrl == "~/Image/对号.png" && Image2.ImageUrl == "~/Image/对号.png" && Image3.ImageUrl == "~/Image/对号.png" && Image4.ImageUrl == "~/Image/对号.png" && Image5.ImageUrl == "~/Image/对号.png" && Image6.ImageUrl == "~/Image/对号.png")
                {
                    try
                    {
                        Model.PositionType add = new Model.PositionType();
                        DAL.Query          nn  = new DAL.Query();
                        int n = nn.query("Positiontype");
                        add.Num              = (n + 1).ToString();
                        add.PositionTypeId   = TextBox10.Text;
                        add.PositionTypeName = TextBox11.Text;
                        add.Length           = TextBox12.Text;
                        add.Width            = TextBox13.Text;
                        add.Height           = TextBox14.Text;
                        add.Remark           = TextBox15.Text;
                        bool xx = new DAL.PositionTypeDAO().addPositionType(add);
                        if (xx == true)
                        {
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true);
                            Div1.Visible      = false;
                            GridView1.Visible = true;
                            rg.Refresh("select * from Positiontype order by num", "PositionTypeId", GridView1);
                            if (GridView1.Visible == true)
                            {
                                Button1.Visible  = true;
                                Button4.Visible  = true;
                                Button5.Visible  = true;
                                ListBox1.Visible = true;
                                TextBox1.Visible = true;
                            }
                            else if (GridView1.Visible == false)
                            {
                                Button1.Visible  = false;
                                Button4.Visible  = false;
                                Button5.Visible  = false;
                                ListBox1.Visible = false;
                                TextBox1.Visible = false;
                                Div1.Visible     = true;
                            }
                        }
                        else
                        {
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true);
                        }
                        //Response.Redirect(Request.Url.ToString());
                    }
                    catch
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true);
                    }
                }
            }
            break;

            case "确定":
            {
                Button             btn    = sender as Button;
                Model.PositionType update = new Model.PositionType();
                update.PositionTypeId   = TextBox10.Text;
                update.PositionTypeName = TextBox11.Text;
                update.Length           = TextBox12.Text;
                update.Width            = TextBox13.Text;
                update.Height           = TextBox14.Text;
                update.Remark           = TextBox15.Text;
                bool xx = new DAL.PositionTypeDAO().updatePositionType(update);
                if (xx)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true);
                    Div1.Visible      = false;
                    GridView1.Visible = true;
                    rg.Refresh("select * from Positiontype order by num", "PositionTypeId", GridView1);
                    if (GridView1.Visible == true)
                    {
                        Button1.Visible  = true;
                        Button4.Visible  = true;
                        Button5.Visible  = true;
                        ListBox1.Visible = true;
                        TextBox1.Visible = true;
                    }
                    else if (GridView1.Visible == false)
                    {
                        Button1.Visible  = false;
                        Button4.Visible  = false;
                        Button5.Visible  = false;
                        ListBox1.Visible = false;
                        TextBox1.Visible = false;
                        Div1.Visible     = true;
                    }
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true);
                }
            }
            break;
            }
        }