示例#1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                Convert.ToInt32(this.TextBox4.Text);
            }
            catch {
                Response.Redirect("<script>alert('价格只能为正数')</script>");
            }
            CarDetailinfo c = new CarDetailinfo();

            c.cname    = this.TextBox2.Text;
            c.Content  = this.TextBox3.Text;
            c.Price    = Convert.ToInt32(this.TextBox4.Text);
            c.ImageUrl = this.FileUpload1.FileName;
            c.BrandId  = Convert.ToInt32(this.DropDownList1.SelectedValue.ToString());
            bool flag = new CarInfoBLL().AddCarBLL(c);

            if (flag)
            {
                Response.Redirect("WebForm1.aspx");
            }
            else
            {
                Response.Redirect("<script>alert('添加失败')</script>");
            }
        }
示例#2
0
        public bool AddCarDAL(CarDetailinfo c)
        {
            string sql = string.Format(@"insert into CarDetail 
                                values('{0}','{1}','{2}','{3}',default,'{4}')"
                                       , c.cname, c.Content, c.Price, c.ImageUrl, c.BrandId);

            return(new DBhelper().Excute(sql));
        }
示例#3
0
        public DataTable GetGridDAL(CarDetailinfo c)
        {
            string sql = "select * from CarDetail a,CarBrand b where a.BrandId=b.BrandId ";

            if (c != null)
            {
                if (c.cname != "")
                {
                    sql += string.Format("and cname like '%{0}%'", c.cname);
                }
                if (c.Price != 0 && c.Price2 != 0)
                {
                    sql += string.Format("and Price > '{0}' and Price < '{1}'", c.Price, c.Price2);
                }
            }
            return(new DBhelper().Get(sql));
        }
示例#4
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            CarDetailinfo c = new CarDetailinfo();

            c.cid     = (int)GridView1.DataKeys[e.RowIndex].Value;
            c.Content = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("CarInfo")).Text;
            c.Price   = Convert.ToInt32(((TextBox)GridView1.Rows[e.RowIndex].FindControl("CarPrice")).Text);
            bool flag = new CarInfoBLL().UpdateGridBLL(c);

            if (flag)
            {
                GridView1.EditIndex = -1;
                GetGrid();
                Response.Write("<script>alert('修改成功')</script>");
            }
            else
            {
                GridView1.EditIndex = -1;
                Response.Write("<script>alert('修改失败')</script>");
            }
        }
示例#5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string price  = this.TextBox2.Text;
            string price2 = this.TextBox3.Text;

            if (price != "" && price2 != "")
            {
                try
                {
                    Convert.ToInt32(price);
                    Convert.ToInt32(price2);
                }
                catch
                {
                    Response.Write("<script>alert('请输入整数')</script>");
                    return;
                }
            }
            CarDetailinfo c = new CarDetailinfo();

            c.cname = this.TextBox1.Text;
            if (price != "" && price2 != "")
            {
                if (Convert.ToInt32(price) < Convert.ToInt32(price2))
                {
                    c.Price  = Convert.ToInt32(price);
                    c.Price2 = Convert.ToInt32(price2);
                }
                else
                {
                    Response.Write("<script>alert('请在方框左边输入范围起点')</script>");
                }
            }
            DataTable dt = new CarInfoBLL().GetGridBLL(c);

            this.GridView1.DataSource = dt;
            this.GridView1.DataBind();
        }
示例#6
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            CarDetailinfo c = new CarDetailinfo();

            if (e.CommandName == "del")
            {
                c.cid = Convert.ToInt32(e.CommandArgument.ToString());
                bool flag = new CarInfoBLL().DelGridBLL(c);
                if (flag)
                {
                    Response.Write("<script>alert('删除成功')</script>");
                    GetGrid();
                }
                else
                {
                    Response.Write("<script>alert('删除失败')</script>");
                }
            }
            //if (e.CommandName == "bj")
            //{
            //    c.cid = Convert.ToInt32(e.CommandArgument.ToString());

            //}
        }
示例#7
0
        public bool UpdateGridDAL(CarDetailinfo c)
        {
            string sql = string.Format("update CarDetail set Content='{0}',Price='{1}' where cid='{2}'", c.Content, c.Price, c.cid);

            return(new DBhelper().Excute(sql));
        }
示例#8
0
        public bool DelGridDAL(CarDetailinfo c)
        {
            string sql = string.Format("delete CarDetail where cid='{0}'", c.cid);

            return(new DBhelper().Excute(sql));
        }
示例#9
0
 public bool UpdateGridBLL(CarDetailinfo c)
 {
     return(new CarInfoDAL().UpdateGridDAL(c));
 }
示例#10
0
 public bool AddCarBLL(CarDetailinfo c)
 {
     return(new CarInfoDAL().AddCarDAL(c));
 }
示例#11
0
 public bool DelGridBLL(CarDetailinfo c)
 {
     return(new CarInfoDAL().DelGridDAL(c));
 }
示例#12
0
 public DataTable GetGridBLL(CarDetailinfo c)
 {
     return(new CarInfoDAL().GetGridDAL(c));
 }