예제 #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
        private void GetGrid()
        {
            DataTable dt = new CarInfoBLL().GetGridBLL(null);

            this.GridView1.DataSource = dt;
            this.GridView1.DataBind();
        }
예제 #3
0
        private void ShowDpd()
        {
            DataTable dt = new CarInfoBLL().ShowDpdBLL();

            this.DropDownList1.DataSource     = dt;
            this.DropDownList1.DataTextField  = "BrandName";
            this.DropDownList1.DataValueField = "BrandId";
            this.DropDownList1.DataBind();
        }
예제 #4
0
        protected void btnSaveCar_OnClick(object sender, EventArgs e)
        {
            //准备参数
            string     carNum = this.txbcarNum.Text.Trim();
            CarInfoBLL bll    = new CarInfoBLL();

            //调用方法保存车辆
            if (bll.AddCar((Session["UserInfo"] as UserInfo).UserName, carNum))
            {
                Helper.jsPrint("保存成功!");
                this.paddCar.Visible  = false;
                this.pManager.Visible = true;
            }
            else
            {
                Helper.jsPrint("保存失败!");
            }
        }
예제 #5
0
        protected void btnAddCar_OnClick(object sender, EventArgs e)
        {
            string     carNum = this.txbNewCar.Text.Trim();
            CarInfoBLL bll    = new CarInfoBLL();

            if (bll.AddCar((Session["UserInfo"] as UserInfo).UserName, carNum))
            {
                Helper.jsPrint("添加成功!");
                this.rblCarNum.Visible   = true;
                this.lbmsgNoCar.Visible  = false;
                this.btnAddCar.Visible   = false;
                this.txbNewCar.Visible   = false;
                this.btnGotoport.Visible = true;
                LoadUserCar(list);
                return;
            }
            Helper.jsPrint("添加失败!");
        }
예제 #6
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>");
            }
        }
예제 #7
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();
        }
예제 #8
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());

            //}
        }