/// <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; } }
/// <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; } }
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(); }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
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; } }
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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
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(); }