コード例 #1
0
 public void BindCarName()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         List <ZLzuche.Model.Car> carlist = new List <Model.Car>();
         int cartypeid = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
         if (cartypeid > 0)
         {
             carlist = entity.Car.Where(x => x.CarTypeId == cartypeid).ToList();
         }
         //else
         //{
         //    carlist = entity.Car.ToList();
         //}
         carlist.Insert(0, new Model.Car()
         {
             CarName = "--请选择--", ID = 0
         });
         this.CarName.DataSource     = carlist;
         this.CarName.DataTextField  = "CarName";
         this.CarName.DataValueField = "ID";
         this.CarName.DataBind();
         this.CarName.SelectedIndex = 0;
     }
 }
コード例 #2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string enterpriseName = this.EnterpriseName.Text.Trim();
            string linkman        = this.Linkman.Text.Trim();
            string linktel        = this.LinkTel.Text.Trim();
            string email          = this.Email.Text.Trim();
            string needinfo       = this.NeedInfo.Text.Trim();

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.rzzlApply model = new Model.rzzlApply();
                    model.EnterpriseName = enterpriseName;
                    model.Linkman        = linkman;
                    model.LinkTel        = linktel;
                    model.Email          = email;
                    model.NeedInfo       = needinfo;
                    model.ApplyTime      = DateTime.Now;
                    entity.AddTorzzlApply(model);
                    entity.SaveChanges();

                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('申请成功');window.close();</script>");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #3
0
        protected void CarModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            string carid = CarModel.SelectedItem.Value;
            if (Convert.ToInt32(carid) > 0)
            {
                int id = Convert.ToInt32(carid);
                string carmodel = CarModel.SelectedItem.Text;
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    var model = entity.Car.Where(x => x.ID == id && x.CarModel == carmodel).FirstOrDefault();
                    if (model != null)
                    {
                        this.clzdj.Text = model.clzdj;
                        this.clgzs.Text = model.clgzs;
                        this.ycspf.Text = model.ycspf;
                        this.gcfy.InnerHtml = (Convert.ToInt32(model.clzdj) + Convert.ToInt32(model.clgzs) + Convert.ToInt32(model.ycspf)).ToString() + "元";

                        this.threeyear.Checked = true;
                        this.rzzlfy.InnerHtml = model.C3Yearzlfy + "元";
                        this.sfzj.Text = (Convert.ToInt32(model.C3Yearzlfy) * 0.3).ToString();
                        this.yzj.Text = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 36).ToString();
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string newtype    = this.NewType.SelectedItem.Text;;
            string subject    = this.Subject.Text.Trim();
            string hidcontent = this.hidcontent.Value;
            string content    = HttpUtility.UrlDecode(hidcontent);

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.News news = new Model.News();
                    news.NewType    = newtype;
                    news.Subject    = subject;
                    news.Content    = content;
                    news.CreateBy   = Convert.ToInt32(Session["ID"] == null ? "0" : Session["ID"].ToString());
                    news.CreateTime = DateTime.Now;
                    entity.AddToNews(news);
                    entity.SaveChanges();
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #5
0
        protected void CarTypeGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string id       = CarTypeGrid.DataKeys[e.RowIndex].Value.ToString();
            string name     = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtName"))).Text.ToString();     //通过 DataKeyNames 属性来设置
            string describe = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtDescribe"))).Text.ToString(); //获取当前行当前列的值,重点
            string remark   = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtRemark"))).Text.ToString();   //获取当前行当前列的值,重点

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    int intid = Convert.ToInt32(id);
                    var model = entity.CarType.FirstOrDefault(x => x.ID == intid);
                    if (model != null)
                    {
                        model.CarTypeName = name;
                        model.Describe    = describe;
                        model.Remark      = remark;
                        entity.SaveChanges();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑失败,没找到该汽车品牌');</script>");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑发生异常');</script>");
                return;
            }
            CarTypeGrid.EditIndex = -1;//设置当前编辑行为空
            BindGrid();
        }
コード例 #6
0
        protected void CarModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            string carid = CarModel.SelectedItem.Value;

            if (Convert.ToInt32(carid) > 0)
            {
                int    id       = Convert.ToInt32(carid);
                string carmodel = CarModel.SelectedItem.Text;
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    var model = entity.Car.Where(x => x.ID == id && x.CarModel == carmodel).FirstOrDefault();
                    if (model != null)
                    {
                        this.clzdj.Text     = model.clzdj;
                        this.clgzs.Text     = model.clgzs;
                        this.ycspf.Text     = model.ycspf;
                        this.gcfy.InnerHtml = (Convert.ToInt32(model.clzdj) + Convert.ToInt32(model.clgzs) + Convert.ToInt32(model.ycspf)).ToString() + "元";

                        this.threeyear.Checked = true;
                        this.rzzlfy.InnerHtml  = model.C3Yearzlfy + "元";
                        this.sfzj.Text         = (Convert.ToInt32(model.C3Yearzlfy) * 0.3).ToString();
                        this.yzj.Text          = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 36).ToString();
                    }
                }
            }
        }
コード例 #7
0
        protected void rdo_CheckedChanged(object sender, EventArgs e)
        {
            string carid = CarModel.SelectedItem.Value;

            if (Convert.ToInt32(carid) > 0)
            {
                int    id       = Convert.ToInt32(carid);
                string carmodel = CarModel.SelectedItem.Text;
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    var model = entity.Car.Where(x => x.ID == id && x.CarModel == carmodel).FirstOrDefault();
                    if (model != null)
                    {
                        if (oneyear.Checked == true)
                        {
                            this.rzzlfy.InnerHtml = model.C1Yearzlfy + "元";
                            this.sfzj.Text        = (Convert.ToInt32(model.C1Yearzlfy) * 0.3).ToString();
                            this.yzj.Text         = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 12).ToString();
                        }
                        if (twoyear.Checked == true)
                        {
                            this.rzzlfy.InnerHtml = model.C2Yearzlfy + "元";
                            this.sfzj.Text        = (Convert.ToInt32(model.C2Yearzlfy) * 0.3).ToString();
                            this.yzj.Text         = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 24).ToString();
                        }
                        if (threeyear.Checked == true)
                        {
                            this.rzzlfy.InnerHtml = model.C3Yearzlfy + "元";
                            this.sfzj.Text        = (Convert.ToInt32(model.C3Yearzlfy) * 0.3).ToString();
                            this.yzj.Text         = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 36).ToString();
                        }
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string name     = this.Name.Text.Trim();
            string tel      = this.Tel.Text.Trim();
            string address  = this.Address.Text.Trim();
            string describe = this.Describe.Text.Trim();
            string remark   = this.Remark.Text.Trim();

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Shop shop = new Model.Shop();
                    shop.Name     = name;
                    shop.Tel      = tel;
                    shop.Address  = address;
                    shop.Describe = describe;
                    shop.Remark   = remark;
                    entity.AddToShop(shop);
                    entity.SaveChanges();
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #9
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void BtnLogin_Click(object sender, EventArgs e)
 {
     string name = this.txtUserName.Text.Trim();
     string password = this.txtPassword.Text.Trim();
     string md5password=Common.Md5.GetMd5Hash(password);
     try
     {
         using (var db = new Model.ZLzucheEntities())
         {
             var entity = db.Customer.FirstOrDefault(model => (model.LoginID == name || model.Phone == name || model.Email == name || model.PapersNumber == name) && model.Password == md5password);
             if (entity != null && entity.ID > 0)
             {
                 Session["CustomerId"] = entity.ID;
                 Session["LoginId"] = entity.LoginID;
                 var url = this.ResolveUrl("~/Index.aspx");
                 Response.Redirect(url);
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户名或密码错误');</script>");
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户登录失败');</script>");
         return;
     }
 }
コード例 #10
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string cartypename = this.CarTypeName.Text.Trim();
            string describe = this.Describe.Text.Trim();
            string remark = this.Remark.Text.Trim();
            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.CarType cartype = new Model.CarType();
                    cartype.CarTypeName = cartypename;
                    cartype.Describe = describe;

                    cartype.Remark = remark;
                    entity.AddToCarType(cartype);
                    entity.SaveChanges();
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #11
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            string name        = this.txtUserName.Text.Trim();
            string password    = this.txtPassword.Text.Trim();
            string md5password = Common.Md5.GetMd5Hash(password);

            try
            {
                using (var db = new Model.ZLzucheEntities())
                {
                    var entity = db.Customer.FirstOrDefault(model => (model.LoginID == name || model.Phone == name || model.Email == name || model.PapersNumber == name) && model.Password == md5password);
                    if (entity != null && entity.ID > 0)
                    {
                        Session["CustomerId"] = entity.ID;
                        Session["LoginId"]    = entity.LoginID;
                        var url = this.ResolveUrl("~/Index.aspx");
                        Response.Redirect(url);
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户名或密码错误');</script>");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户登录失败');</script>");
                return;
            }
        }
コード例 #12
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNew_Click(object sender, EventArgs e)
 {
     string newtype = this.NewType.SelectedItem.Text; ;
     string subject = this.Subject.Text.Trim();
     string hidcontent = this.hidcontent.Value;
     string content = HttpUtility.UrlDecode(hidcontent);
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             ZLzuche.Model.News news = new Model.News();
             news.NewType = newtype;
             news.Subject = subject;
             news.Content =content;
             news.CreateBy = Convert.ToInt32(Session["ID"] == null ? "0" : Session["ID"].ToString());
             news.CreateTime = DateTime.Now;
             entity.AddToNews(news);
             entity.SaveChanges();
         }
         Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
         Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
         return;
     }
 }
コード例 #13
0
 /// <summary>
 /// 
 /// </summary>
 public void BindCarType()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var cartypelist = entity.CarType.ToList();
         cartypelist.Insert(0, new Model.CarType() { CarTypeName = "--请选择--", ID = 0 });
         this.CarTypeId.DataSource = cartypelist;
         this.CarTypeId.DataTextField = "CarTypeName";
         this.CarTypeId.DataValueField = "ID";
         this.CarTypeId.DataBind();
         this.CarTypeId.SelectedIndex = 0;
     }
 }
コード例 #14
0
 private void BindData()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         //短租(取车城市)
         var takeCityList = entity.Shop.OrderBy(model => model.City).Select(model => new { City = model.City }).Distinct();
         if (takeCityList.Count() == 1)
         {
             var item = takeCityList.ToList()[0];
             lblShortRentTakeCity.Text = item.City;
         }
     }
 }
コード例 #15
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var customerList = entity.Customer.ToList();
             this.CustomerGrid.DataSource = customerList;
             this.CustomerGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #16
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var ordersList = entity.Orders.OrderByDescending(x => x.CreateTime).ToList();
             this.OrderGrid.DataSource = ordersList;
             this.OrderGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #17
0
 public string GetShopName(string shopId)
 {
     int id = Convert.ToInt32(shopId);
     string shopname = string.Empty;
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var shopmodel = entity.Shop.Where(x => x.ID == id).FirstOrDefault();
         if (shopmodel != null)
         {
             shopname = shopmodel.Name;
         }
     }
     return shopname;
 }
コード例 #18
0
 public string GetCarTypeName(string cartypeid)
 {
     int id = Convert.ToInt32(cartypeid);
     string cartypename = string.Empty;
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var cartypemodel = entity.CarType.Where(x => x.ID == id).FirstOrDefault();
         if (cartypemodel != null)
         {
             cartypename = cartypemodel.CarTypeName;
         }
     }
     return cartypename;
 }
コード例 #19
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var foucsimagelist = entity.FocusImage.OrderByDescending(x => x.CreateTime).ToList();
             this.CarTypeGrid.DataSource = foucsimagelist;
             this.CarTypeGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #20
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string id            = Session["CustomerId"] == null ? string.Empty : Session["CustomerId"].ToString();
            string oldpassword   = this.OldPassword.Text.Trim();
            string newpassword   = this.NewPassword.Text.Trim();
            string renewpassword = this.ReNewPassword.Text.Trim();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户标识为空,不能修改密码');</script>");
                    Response.Redirect("~/Account/Login.aspx");
                    return;
                }
                if (newpassword.Equals(renewpassword) == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新密码和确认密码输入不一致,请重新输入');</script>");
                    this.NewPassword.Text   = string.Empty;
                    this.ReNewPassword.Text = string.Empty;
                    this.NewPassword.Focus();
                    return;
                }
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    int uid = Convert.ToInt32(id);
                    //string md5password=Common.Md5.GetMd5Hash(password);
                    string md5password = Common.Md5.GetMd5Hash(oldpassword);
                    var    model       = entity.Customer.Where(x => x.ID == uid && x.Password == md5password).FirstOrDefault();
                    if (model == null)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('原始密码输入错误,请重新输入');</script>");
                        this.OldPassword.Text = string.Empty;
                        this.OldPassword.Focus();
                        return;
                    }
                    else
                    {
                        model.Password = Common.Md5.GetMd5Hash(newpassword);
                        entity.SaveChanges();
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('密码修改成功');</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改密码发生异常');</script>");
                return;
            }
        }
コード例 #21
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var ordersList = entity.Orders.OrderByDescending(x=>x.CreateTime).ToList();
             this.OrderGrid.DataSource = ordersList;
             this.OrderGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #22
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var foucsimagelist = entity.FocusImage.OrderByDescending(x=>x.CreateTime).ToList();
             this.CarTypeGrid.DataSource = foucsimagelist;
             this.CarTypeGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #23
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var customerList = entity.Customer.ToList();
             this.CustomerGrid.DataSource = customerList;
             this.CustomerGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #24
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var cartypelist = entity.CarType.ToList();
             this.CarTypeGrid.DataSource = cartypelist;
             this.CarTypeGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #25
0
 /// <summary>
 /// 绑定订单
 /// </summary>
 /// <param name="customerId"></param>
 private void BindGrid(int customerId)
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var ordersList = entity.Orders.Where(x => x.CustomerID == customerId).ToList();
             this.OrderGrid.DataSource = ordersList;
             this.OrderGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #26
0
        public string GetShopName(string shopId)
        {
            int    id       = Convert.ToInt32(shopId);
            string shopname = string.Empty;

            using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
            {
                var shopmodel = entity.Shop.Where(x => x.ID == id).FirstOrDefault();
                if (shopmodel != null)
                {
                    shopname = shopmodel.Name;
                }
            }
            return(shopname);
        }
コード例 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetCustomerName(string customerId)
        {
            int    id           = Convert.ToInt32(customerId);
            string customerName = string.Empty;

            using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
            {
                var customerModel = entity.Customer.Where(x => x.ID == id).FirstOrDefault();
                if (customerModel != null)
                {
                    customerName = customerModel.CustomerName;
                }
            }
            return(customerName);
        }
コード例 #28
0
        public string GetCarTypeName(string cartypeid)
        {
            int    id          = Convert.ToInt32(cartypeid);
            string cartypename = string.Empty;

            using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
            {
                var cartypemodel = entity.CarType.Where(x => x.ID == id).FirstOrDefault();
                if (cartypemodel != null)
                {
                    cartypename = cartypemodel.CarTypeName;
                }
            }
            return(cartypename);
        }
コード例 #29
0
 private void BindShop()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var shopList = entity.Shop.ToList();
         this.ShopId.DataSource = shopList;
         shopList.Insert(0, new Model.Shop()
         {
             Name = "--请选择--", ID = 0
         });
         this.ShopId.DataTextField  = "Name";
         this.ShopId.DataValueField = "ID";
         this.ShopId.DataBind();
         this.ShopId.SelectedIndex = 0;
     }
 }
コード例 #30
0
 /// <summary>
 ///
 /// </summary>
 public void BindCarType()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var cartypelist = entity.CarType.ToList();
         cartypelist.Insert(0, new Model.CarType()
         {
             CarTypeName = "--请选择--", ID = 0
         });
         this.CarTypeId.DataSource     = cartypelist;
         this.CarTypeId.DataTextField  = "CarTypeName";
         this.CarTypeId.DataValueField = "ID";
         this.CarTypeId.DataBind();
         this.CarTypeId.SelectedIndex = 0;
     }
 }
コード例 #31
0
        protected void CarTypeGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id = CarTypeGrid.DataKeys[e.RowIndex].Value.ToString();

            if (!string.IsNullOrEmpty(id))
            {
                try
                {
                    using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                    {
                        int intid = Convert.ToInt32(id);
                        var model = entity.CarType.FirstOrDefault(x => x.ID == intid);
                        if (model != null)
                        {
                            var carList = entity.Car.Where(x => x.CarTypeId == intid).ToList();
                            if (carList.Count > 0)
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请先删除该品牌下的所有汽车,再删除该品牌');</script>");
                                return;
                            }
                            else
                            {
                                entity.DeleteObject(model);
                                entity.SaveChanges();
                                BindGrid();
                            }
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除失败,没找到该汽车品牌');</script>");
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除发生异常');</script>");
                    return;
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除失败');</script>");
                return;
            }
        }
コード例 #32
0
 protected void CarTypeGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     string id = CarTypeGrid.DataKeys[e.RowIndex].Value.ToString();
     if (!string.IsNullOrEmpty(id))
     {
         try
         {
             using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
             {
                 int intid = Convert.ToInt32(id);
                 var model = entity.Shop.FirstOrDefault(x => x.ID == intid);
                 if (model != null)
                 {
                     var carList = entity.Car.Where(x => x.ShopId == intid).ToList();
                     if (carList.Count > 0)
                     {
                         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请先删除该店铺下的所有汽车,再删除该店铺');</script>");
                         return;
                     }
                     else
                     {
                         entity.DeleteObject(model);
                         entity.SaveChanges();
                         BindGrid();
                     }
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除失败');</script>");
                     return;
                 }
             }
         }
         catch (Exception ex)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除发生异常');</script>");
             return;
         }
     }
     else
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除失败');</script>");
         return;
     }
 }
コード例 #33
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnRegister_Click(object sender, EventArgs e)
        {
            string phone      = this.phone.Text.Trim();
            string email      = this.email.Text.Trim();
            string name       = this.name.Text.Trim();
            string cardno     = this.cardno.Text.Trim();
            string password   = this.password.Text.Trim();
            string repassword = this.repassword.Text.Trim();
            string checkcode  = this.checkcode.Text.Trim();
            string ischeck    = Session["UserCode"].ToString();

            if (password.Equals(repassword) == false)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致');</script>");
                return;
            }
            if (ischeck.Equals(checkcode.ToUpper()) == false)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('验证码输入错误');</script>");
                return;
            }
            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Customer customer = new Model.Customer();
                    customer.LoginID      = name;
                    customer.Phone        = phone;
                    customer.Email        = email;
                    customer.CustomerName = name;
                    customer.PapersNumber = cardno;
                    customer.Password     = Common.Md5.GetMd5Hash(password);
                    customer.RegisterTime = DateTime.Now;
                    entity.AddToCustomer(customer);
                    entity.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户注册失败');</script>");
                return;
            }
        }
コード例 #34
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void BtnRegister_Click(object sender, EventArgs e)
 {
     string phone = this.phone.Text.Trim();
     string email = this.email.Text.Trim();
     string name = this.name.Text.Trim();
     string cardno = this.cardno.Text.Trim();
     string password = this.password.Text.Trim();
     string repassword = this.repassword.Text.Trim();
     string checkcode = this.checkcode.Text.Trim();
     string ischeck = Session["UserCode"].ToString();
     if (password.Equals(repassword) == false)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致');</script>");
         return;
     }
     if (ischeck.Equals(checkcode.ToUpper()) == false)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('验证码输入错误');</script>");
         return;
     }
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             ZLzuche.Model.Customer customer = new Model.Customer();
             customer.LoginID = name;
             customer.Phone = phone;
             customer.Email = email;
             customer.CustomerName = name;
             customer.PapersNumber = cardno;
             customer.Password = Common.Md5.GetMd5Hash(password);
             customer.RegisterTime = DateTime.Now;
             entity.AddToCustomer(customer);
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户注册失败');</script>");
         return;
     }
 }
コード例 #35
0
        public string GetCarName(string orderId)
        {
            int    id      = Convert.ToInt32(orderId);
            string carName = string.Empty;

            using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
            {
                var orderdetail = entity.OrderDetails.Where(x => x.OrderId == id).FirstOrDefault();
                if (orderdetail != null)
                {
                    int carid    = Convert.ToInt32(orderdetail.CarId);
                    var carmodel = entity.Car.Where(x => x.ID == carid).FirstOrDefault();
                    if (carmodel != null)
                    {
                        carName = carmodel.CarName;
                    }
                }
            }
            return(carName);
        }
コード例 #36
0
 public void BindCarName()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         List<ZLzuche.Model.Car> carlist = new List<Model.Car>();
         int cartypeid = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
         if (cartypeid > 0)
         {
             carlist = entity.Car.Where(x => x.CarTypeId == cartypeid).ToList();
         }
         //else
         //{
         //    carlist = entity.Car.ToList();
         //}
         carlist.Insert(0, new Model.Car() { CarName = "--请选择--", ID = 0 });
         this.CarName.DataSource = carlist;
         this.CarName.DataTextField = "CarName";
         this.CarName.DataValueField = "ID";
         this.CarName.DataBind();
         this.CarName.SelectedIndex = 0;
     }
 }
コード例 #37
0
 public void BindNew(int newid)
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var newmodel = entity.News.Where(x => x.Id == newid).FirstOrDefault();
             if (newmodel == null)
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('该新闻不存在');</script>");
                 return;
             }
             else
             {
                 this.labTitle.InnerHtml   = newmodel.Subject;
                 this.buildTime.InnerHtml  = "发表时间:" + newmodel.CreateTime.ToString();
                 this.divContent.InnerHtml = newmodel.Content;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #38
0
        private JsonResult OnLogin()
        {
            var userName = Request.Params["username"];
            var password = Request.Params["password"];
            var md5pwd   = Common.Md5.GetMd5Hash(password);

            using (var db = new Model.ZLzucheEntities())
            {
                var entity =
                    db.Customer.FirstOrDefault(
                        model =>
                        (model.LoginID == userName || model.Phone == userName || model.Email == userName ||
                         model.PapersNumber == userName) && model.Password == md5pwd);
                var result = new JsonResult();
                if (entity != null && entity.ID > 0)
                {
                    Session["CustomerId"] = entity.ID;
                    Session["LoginId"]    = entity.LoginID;
                    result.IsSuccess      = true;
                    result.Result         = entity.CustomerName;
                }
                return(result);
            }
        }
コード例 #39
0
 private JsonResult OnLogin()
 {
     var userName = Request.Params["username"];
     var password = Request.Params["password"];
     var md5pwd = Common.Md5.GetMd5Hash(password);
     using (var db = new Model.ZLzucheEntities())
     {
         var entity =
             db.Customer.FirstOrDefault(
                 model =>
                 (model.LoginID == userName || model.Phone == userName || model.Email == userName ||
                  model.PapersNumber == userName) && model.Password == md5pwd);
         var result = new JsonResult();
         if (entity != null && entity.ID > 0)
         {
             Session["CustomerId"] = entity.ID;
             Session["LoginId"] = entity.LoginID;
             result.IsSuccess = true;
             result.Result = entity.CustomerName;
         }
         return result;
     }
 }
コード例 #40
0
 private void BindGrid()
 {
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var shoplist = entity.Shop.ToList();
             this.CarTypeGrid.DataSource = shoplist;
             this.CarTypeGrid.DataBind();
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #41
0
 protected void CarTypeGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     string id = CarTypeGrid.DataKeys[e.RowIndex].Value.ToString();
     string name = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtName"))).Text.ToString();//通过 DataKeyNames 属性来设置
     string address = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtAddress"))).Text.ToString();
     string tel = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtTel"))).Text.ToString();
     string describe = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtDescribe"))).Text.ToString();//获取当前行当前列的值,重点
     string remark = ((TextBox)(CarTypeGrid.Rows[e.RowIndex].FindControl("txtRemark"))).Text.ToString();//获取当前行当前列的值,重点
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             int intid = Convert.ToInt32(id);
             var model = entity.Shop.FirstOrDefault(x => x.ID == intid);
             if (model != null)
             {
                 model.Name = name;
                 model.Address = address;
                 model.Tel = tel;
                 model.Describe = describe;
                 model.Remark = remark;
                 entity.SaveChanges();
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑失败');</script>");
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑发生异常');</script>");
         return;
     }
     CarTypeGrid.EditIndex = -1;//设置当前编辑行为空
     BindGrid();
 }
コード例 #42
0
 private void BindData()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         //短租(取车城市)
         var takeCityList = entity.Shop.OrderBy(model => model.City).Select(model => new { City = model.City }).Distinct();
         if (takeCityList.Count() == 1)
         {
             var item = takeCityList.ToList()[0];
             lblShortRentTakeCity.Text = item.City;
         }
     }
 }
コード例 #43
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int    AddedFcousImageId = 0;
            string describe          = this.Describe.Text.Trim();
            string linkUrl           = this.LinkUrl.Text.Trim();
            string remark            = this.Remark.Text.Trim();

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.FocusImage model = new Model.FocusImage();
                    model.Describe   = describe;
                    model.LinkURL    = linkUrl;
                    model.CreateTime = DateTime.Now;
                    model.Remark     = remark;
                    entity.AddToFocusImage(model);
                    entity.SaveChanges();

                    if (foucsimage.HasFile)
                    {
                        try
                        {
                            //图片尺寸:621*268
                            AddedFcousImageId = model.ID;
                            string name = foucsimage.FileName;                       //文件的名字
                            string size = foucsimage.PostedFile.ContentLength.ToString();
                            string last = name.Substring(name.LastIndexOf(".") + 1); //得到文件的后缀名(gif/jpg)
                            if ((last == "bmp") || (last == "gif") || (last == "jpg"))
                            {
                                using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(foucsimage.PostedFile.InputStream))
                                {
                                    if (myImage.Width != 621 && myImage.Height != 268)
                                    {
                                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('只能上传621*268尺寸的图片');</script>");
                                        return;
                                    }
                                }
                                string filename    = AddedFcousImageId + "." + last;
                                string webFilePath = Server.MapPath("../images/FocusImage/" + filename);
                                foucsimage.SaveAs(webFilePath);

                                model.FileName = filename;
                                entity.SaveChanges();
                            }
                            else
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('只能上传bmp、gif、jpg格式的图片');</script>");
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #44
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int AddedFcousImageId = 0;
            string describe = this.Describe.Text.Trim();
            string linkUrl = this.LinkUrl.Text.Trim();
            string remark = this.Remark.Text.Trim();
            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.FocusImage model = new Model.FocusImage();
                    model.Describe = describe;
                    model.LinkURL = linkUrl;
                    model.CreateTime = DateTime.Now;
                    model.Remark = remark;
                    entity.AddToFocusImage(model);
                    entity.SaveChanges();

                    if (foucsimage.HasFile)
                    {
                        try
                        {
                            //图片尺寸:621*268
                            AddedFcousImageId = model.ID;
                            string name = foucsimage.FileName;//文件的名字
                            string size = foucsimage.PostedFile.ContentLength.ToString();
                            string last = name.Substring(name.LastIndexOf(".") + 1);//得到文件的后缀名(gif/jpg)
                            if ((last == "bmp") || (last == "gif") || (last == "jpg"))
                            {
                                using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(foucsimage.PostedFile.InputStream))
                                {
                                    if (myImage.Width != 621 && myImage.Height != 268)
                                    {
                                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('只能上传621*268尺寸的图片');</script>");
                                        return;
                                    }
                                }
                                string filename = AddedFcousImageId + "." + last;
                                string webFilePath = Server.MapPath("../images/FocusImage/" + filename);
                                foucsimage.SaveAs(webFilePath);

                                model.FileName = filename;
                                entity.SaveChanges();
                            }
                            else
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('只能上传bmp、gif、jpg格式的图片');</script>");
                                return;
                            }

                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #45
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int     AddedCarId       = 0;
            int     shipId           = Convert.ToInt32(this.ShopId.SelectedItem.Value);
            int     cartypeid        = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
            string  carname          = this.CarName.Text.Trim();
            string  carmodel         = this.CarModel.Text.Trim();
            string  basicInsure      = this.BasicInsure.Text.Trim();
            string  PreAuthorization = this.PreAuthorization.Text.Trim();
            decimal price            = Convert.ToDecimal(this.Price.Text.Trim());
            string  IsMileage        = this.IsMileage.SelectedItem.Value;
            string  Status           = this.Status.SelectedItem.Value;
            string  describe         = this.Describe.Text.Trim();
            string  remark           = this.Remark.Text.Trim();

            int     carnum     = Convert.ToInt32(this.CarNum.Text.Trim());
            string  carage     = this.CarAge.Text.Trim();
            string  derailleur = this.drpDerailleur.SelectedItem.Text;
            decimal monthprice = Convert.ToDecimal(this.MonthPrice.Text.Trim());

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Car car = new Model.Car();
                    car.ShopId           = shipId;
                    car.CarTypeId        = cartypeid;
                    car.CarName          = carname;
                    car.CarModel         = carmodel;
                    car.BasicInsure      = basicInsure;
                    car.PreAuthorization = PreAuthorization;
                    car.Price            = Convert.ToDecimal(price);
                    car.IsMileage        = IsMileage;
                    car.Status           = Status;
                    car.Describe         = describe;
                    car.Remark           = remark;

                    car.carnum     = carnum;
                    car.CarAge     = carage;
                    car.Derailleur = derailleur;
                    car.MonthPrice = monthprice;
                    entity.AddToCar(car);
                    entity.SaveChanges();

                    if (carpic.HasFile)
                    {
                        try
                        {
                            AddedCarId = car.ID;
                            string name        = carpic.FileName;                           //文件的名字
                            string size        = carpic.PostedFile.ContentLength.ToString();
                            string last        = name.Substring(name.LastIndexOf(".") + 1); //得到文件的后缀名(gif/jpg)
                            string filename    = AddedCarId + "." + last;
                            string webFilePath = Server.MapPath("../images/CarImage/" + filename);
                            carpic.SaveAs(webFilePath);
                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
コード例 #46
0
 protected void rdo_CheckedChanged(object sender, EventArgs e)
 {
     string carid = CarModel.SelectedItem.Value;
     if (Convert.ToInt32(carid) > 0)
     {
         int id = Convert.ToInt32(carid);
         string carmodel = CarModel.SelectedItem.Text;
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             var model = entity.Car.Where(x => x.ID == id && x.CarModel == carmodel).FirstOrDefault();
             if (model != null)
             {
                 if (oneyear.Checked == true)
                 {
                     this.rzzlfy.InnerHtml = model.C1Yearzlfy + "元";
                     this.sfzj.Text = (Convert.ToInt32(model.C1Yearzlfy) * 0.3).ToString();
                     this.yzj.Text = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 12).ToString();
                 }
                 if (twoyear.Checked == true)
                 {
                     this.rzzlfy.InnerHtml = model.C2Yearzlfy + "元";
                     this.sfzj.Text = (Convert.ToInt32(model.C2Yearzlfy) * 0.3).ToString();
                     this.yzj.Text = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 24).ToString();
                 }
                 if (threeyear.Checked == true)
                 {
                     this.rzzlfy.InnerHtml = model.C3Yearzlfy + "元";
                     this.sfzj.Text = (Convert.ToInt32(model.C3Yearzlfy) * 0.3).ToString();
                     this.yzj.Text = Convert.ToInt32(Convert.ToInt32(model.C3Yearzlfy) * 0.7 / 36).ToString();
                 }
             }
         }
     }
 }
コード例 #47
0
 private void BindShop()
 {
     using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
     {
         var shopList = entity.Shop.ToList();
         this.ShopId.DataSource = shopList;
         shopList.Insert(0, new Model.Shop() { Name = "--请选择--", ID = 0 });
         this.ShopId.DataTextField = "Name";
         this.ShopId.DataValueField = "ID";
         this.ShopId.DataBind();
         this.ShopId.SelectedIndex = 0;
     }
 }
コード例 #48
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int AddedCarId = 0;
            int shipId = Convert.ToInt32(this.ShopId.SelectedItem.Value);
            int cartypeid = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
            string carname = this.CarName.Text.Trim();
            string carmodel = this.CarModel.Text.Trim();
            string basicInsure = this.BasicInsure.Text.Trim();
            string PreAuthorization = this.PreAuthorization.Text.Trim();
            decimal price = Convert.ToDecimal(this.Price.Text.Trim());
            string IsMileage = this.IsMileage.SelectedItem.Value;
            string Status = this.Status.SelectedItem.Value;
            string describe = this.Describe.Text.Trim();
            string remark = this.Remark.Text.Trim();

            int carnum = Convert.ToInt32(this.CarNum.Text.Trim());
            string carage = this.CarAge.Text.Trim();
            string derailleur = this.drpDerailleur.SelectedItem.Text;
            decimal monthprice = Convert.ToDecimal(this.MonthPrice.Text.Trim());
            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Car car = new Model.Car();
                    car.ShopId = shipId;
                    car.CarTypeId = cartypeid;
                    car.CarName = carname;
                    car.CarModel = carmodel;
                    car.BasicInsure = basicInsure;
                    car.PreAuthorization = PreAuthorization;
                    car.Price = Convert.ToDecimal(price);
                    car.IsMileage = IsMileage;
                    car.Status = Status;
                    car.Describe = describe;
                    car.Remark = remark;

                    car.carnum = carnum;
                    car.CarAge = carage;
                    car.Derailleur = derailleur;
                    car.MonthPrice = monthprice;
                    entity.AddToCar(car);
                    entity.SaveChanges();

                    if (carpic.HasFile)
                    {
                        try
                        {
                            AddedCarId = car.ID;
                            string name = carpic.FileName;//文件的名字
                            string size = carpic.PostedFile.ContentLength.ToString();
                            string last = name.Substring(name.LastIndexOf(".") + 1);//得到文件的后缀名(gif/jpg)
                            string filename = AddedCarId + "." + last;
                            string webFilePath = Server.MapPath("../images/CarImage/" + filename);
                            carpic.SaveAs(webFilePath);
                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }