/// <summary> /// 修改 /// </summary> /// <param name="car"></param> /// <returns></returns> public Model.Car_Cars getcheers(ref Model.Car_Cars car) { Car_Cars cars = CarsManager.GetAllCarsById(Id); car.BuyData = DateTime.Parse(txtBuyDate.Text.ToString()); car.BuyMoney = Decimal.Parse(txtBuyMoney.Text.ToString()); car.Buywork = txtChangJia.Text.ToString(); car.CarMark = txtLisence.Text.ToString(); car.ReMark = txtRemark.Text.ToString(); car.State = ddlState.SelectedValue.ToString(); car.Seating = Convert.ToInt32(txtSeating.Text); if (rdo1.Checked) { car.Typeid.TypeId = 1; } if (rdo2.Checked) { car.Typeid.TypeId = 2; } if (rdo3.Checked) { car.Typeid.TypeId = 3; } if (rdo4.Checked) { car.Typeid.TypeId = 4; } return(car); }
/// <summary> /// 删除一条记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCars_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "del") { string Id = e.CommandArgument.ToString(); try { Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id)); if (cars.State == "已出车" || cars.State == "维修中") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true); } else { int num = CarsManager.DcseteCars(Id); if (num > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');", true); } gvCars.DataSourceID = null; gvCars.DataSource = odsCars; gvCars.DataBind(); } } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true); return; } } }
/// <summary> /// 根据ID查询车辆信息 /// </summary> /// <param name="Id"></param> /// <returns></returns> public Car_Cars GetAllCarsById(int Id) { string sql = "usp_SelcectCarsById"; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(sql, new SqlParameter("@Id", Id))) { if (reader.Read()) { Car_Cars Car = new Car_Cars(); Car.Car_Id = (int)reader["Car_Id"]; Car.CarMark = (string)reader["CarMark"]; Car.Seating = (int)reader["Seating"]; Car.Typeid = carType.GetAllCarsById((int)reader["Typeid"]); Car.BuyData = (DateTime)reader["BuyData"]; Car.BuyMoney = Convert.ToDecimal(reader["BuyMoney"]); Car.Buywork = (string)reader["Buywork"]; Car.State = (string)reader["State"]; Car.ReMark = (string)reader["ReMark"]; return(Car); } else { reader.Close(); return(null); } } }
/// <summary> /// 删除一条记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCars_RowCommand(object sender, GridViewCommandEventArgs e) { //string cmd = e.CommandName;//获取命令名称 //int Id = Convert.ToInt32(e.CommandArgument);//获取命令参数 if (e.CommandName == "del") { string Id = e.CommandArgument.ToString(); try { Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id)); if (cars.State == "已出车" || cars.State == "维修") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true); } else { int num = CarsManager.DcseteCars(Id); if (num > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');", true); } ucpage.PageIndex = 0; ucpage_onPageIndexChanging(ucpage.PageIndex); //gvCars.DataSourceID = null; //gvCars.DataSource = odsCars; //gvCars.DataBind(); } } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true); return; } } else if (e.CommandName == "weixiou") { try { string Id = e.CommandArgument.ToString(); Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id)); int num = CarsManager.UpadteCarsByIdSate(Convert.ToInt32(Id)); if (num > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改成功!');", true); } ucpage.PageIndex = 0; ucpage_onPageIndexChanging(ucpage.PageIndex); } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('维修失败!');", true); } } }
/// <summary> /// 修改车辆信息 /// </summary> /// <param name="cs"></param> /// <returns></returns> public static int UpdateCars(Car_Cars cs) { try { return(carService.UpdateCars(cs)); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
/// <summary> /// 根据状态查看车牌号码 /// </summary> /// <param name="State"></param> /// <returns></returns> public IList <Car_Cars> SelectCarMarkState(string State) { string proName = "usp_SelectCarMarkState"; DataTable tb = DBHelper.GetDataTableProc(proName, new SqlParameter("@State", State)); IList <Car_Cars> list = new List <Car_Cars>(); foreach (DataRow r in tb.Rows) { Car_Cars car = new Car_Cars(); car.CarMark = (string)r["CarMark"]; list.Add(car); } return(list); }
/// <summary> /// 删除车辆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click1(object sender, EventArgs e) { CheckBox chckbx = null; LinkButton lkbtnDelete = null; string Id = ""; for (int i = 0; i < this.gvCars.Rows.Count; i++) { chckbx = this.gvCars.Rows[i].FindControl("chSelect") as CheckBox; lkbtnDelete = this.gvCars.Rows[i].FindControl("lnkdel") as LinkButton; if (chckbx.Checked) { string Id1 = lkbtnDelete.CommandArgument.ToString(); Id += Id1 + ","; } } if (Id != "") { try { Id = Id.Substring(0, Id.Length - 1); Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(Id)); if (cars.State == "已出车" || cars.State == "维修中") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('此车不是未出车状态不可删除!');", true); } else { CarsManager.DcseteCars(Id); gvCars.DataSourceID = null; gvCars.DataSource = CarsManager.SelectCarsDark(txtDept.Text, drlCarType.SelectedValue, drlCarStae.SelectedValue); gvCars.DataBind(); } } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true); return; } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择要删除的项!');", true); } }
/// <summary> /// 添加车辆 /// </summary> /// <param name="cs"></param> /// <returns></returns> public int InsertCars(Car_Cars cs) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BuyData", cs.BuyData), new SqlParameter("@BuyMoney", cs.BuyMoney), new SqlParameter("@Buywork", cs.Buywork), new SqlParameter("@CarMark", cs.CarMark), new SqlParameter("@ReMark", cs.ReMark), new SqlParameter("@State", cs.State), new SqlParameter("@Typeid", cs.Typeid.TypeId), new SqlParameter("@seating", cs.Seating) }; int num = DBHelper.ExecuteNonQueryProc("usp_AddCars", para); return(num); }
public List <Car_Cars> GetCars(SqlDataReader reader) { List <Car_Cars> list = new List <Car_Cars>(); while (reader.Read()) { Car_Cars Car = new Car_Cars(); Car.Car_Id = (int)reader["Car_Id"]; Car.CarMark = (string)reader["CarMark"]; Car.Seating = (int)reader["Seating"]; Car.Typeid = carType.GetAllCarsById((int)reader["Typeid"]); Car.BuyData = (DateTime)reader["BuyData"]; Car.BuyMoney = Convert.ToDecimal(reader["BuyMoney"]); Car.Buywork = (string)reader["Buywork"]; Car.State = (string)reader["State"]; Car.ReMark = (string)reader["ReMark"]; list.Add(Car); } return(list); }
/// <summary> /// 光棒效果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCars_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { HiddenField CarId = e.Row.FindControl("lblWei") as HiddenField; Car_Cars cars = CarsManager.GetAllCarsById(Convert.ToInt32(CarId.Value)); if (cars.State == "已出车" || cars.State == "维修") { LinkButton lbReturn = e.Row.FindControl("lbSend") as LinkButton; LinkButton lndel = e.Row.FindControl("lbDel") as LinkButton; lbReturn.Enabled = false; lndel.Enabled = false; } //设置行颜色 e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ff9900'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); } }
protected void ddlCarMark_SelectedIndexChanged(object sender, EventArgs e) { string name = "0"; name = Request.QueryString["DR_name"]; int id = Convert.ToInt32(ddlCarMark.SelectedValue); if (id != 0) { Car_Cars car = CarsManager.GetAllCarsById(id); Car_Type cartype = (Car_Type)CarTypeManager.GetAllCarsById(car.Typeid.TypeId); rblDR_CarType.SelectedValue = cartype.Genre; if (name == "Up") { rblDR_CarType.Enabled = false; } } else { rblDR_CarType.SelectedValue = "普通用车"; } }
/// <summary> /// 查询所有车辆信息 /// </summary> /// <returns></returns> public IList <Car_Cars> GetAllCars() { string cars = "usp_SelcectCas"; DataTable tb = DBHelper.GetDataTableProc(cars, null); IList <Car_Cars> list = new List <Car_Cars>(); foreach (DataRow r in tb.Rows) { Car_Cars Car = new Car_Cars(); Car.Car_Id = (int)r["Car_Id"]; Car.CarMark = (string)r["CarMark"]; Car.Seating = (int)r["Seating"]; Car.Typeid = carType.GetAllCarsById((int)r["Typeid"]); Car.BuyData = (DateTime)r["BuyData"]; Car.BuyMoney = Convert.ToDecimal(r["BuyMoney"]); Car.Buywork = (string)r["Buywork"]; Car.State = (string)r["State"]; Car.ReMark = (string)r["ReMark"]; list.Add(Car); } return(list); }
protected void btnSave_Click(object sender, EventArgs e) { try { string name = "0"; name = Request.QueryString["S_name"]; Services se = new Services(); se.S_Id = Convert.ToInt32(Request.QueryString["S_Id"]); if (ddlS_Branch.SelectedItem.Text.Trim() == "请选择") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:请选择正确的部门!');", true); return; } else { se.S_Branch = ddlS_Branch.SelectedItem.Text.Trim(); } if (ddlJerquePeople.SelectedValue.Trim() == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:该部门没人,请选择其它部门!');", true); return; } else { se.JerquePeople = ddlJerquePeople.SelectedItem.Text.Trim(); } se.BeginDate = Convert.ToDateTime(txtBeginDate.Value); se.EndDate = Convert.ToDateTime(txtEndDate.Value); if (se.BeginDate >= se.EndDate) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:进厂日期必须大于出厂日期!');", true); return; } if (ddlCarMark.SelectedItem.Text.Trim() == "请选择") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('温馨提示:请选择正确的车牌号!');", true); return; } else { se.CarMark = ddlCarMark.SelectedItem.Text.Trim(); } //图片上传判断 string FileName = ""; if (fuBillPhoto.PostedFile != null) { FileName = System.IO.Path.GetFileName(fuBillPhoto.PostedFile.FileName).ToLower(); if (FileName == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('清单照片不能为空!');", true); return; } fuBillPhoto.PostedFile.SaveAs(Server.MapPath("~/images/UpLoad/" + FileName)); se.BillPhoto = "~/images/UpLoad/" + FileName; } else { se.BillPhoto = image.ImageUrl; } image.ImageUrl = se.BillPhoto; se.CarType = rblCarType.SelectedValue.Trim(); se.S_Reason = Server.HtmlDecode(txtS_Reason.Text.Trim()); se.S_Cost = Convert.ToDouble(txtS_Cost.Text.Trim()); se.S_FactoryName = txtS_FactoryName.Text.Trim(); se.S_People = ddlS_People.SelectedItem.Text.Trim(); se.S_Result = Server.HtmlDecode(txtS_Result.Text.Trim()); se.S_Type = ddlS_Type.SelectedValue; se.UseCost = Convert.ToDouble(txtUseCost.Text.Trim()); if (name == "Up") { int result = ServicesManager.updateService(se); if (result != 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新成功!');window.location.href='Servicelist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新失败!');", true); return; } } else { int result = ServicesManager.addService(se); if (result != 0) { int id = Convert.ToInt32(ddlCarMark.SelectedItem.Value); Car_Cars car = CarsManager.GetAllCarsById(id); car.State = "未出车"; car.Car_Id = id; CarsManager.UpdateCars(car); Page.ClientScript.RegisterStartupScript(this.GetType(), "温馨提示:", "alert('添加成功!');window.location.href='Servicelist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!');", true); return; } } } catch (Exception ex) { throw new Exception(ex.ToString()); } }
protected void btnSave_Click(object sender, EventArgs e) { string name = "0"; name = Request.QueryString["S_name"]; Services se = new Services(); se.S_Id = Convert.ToInt32(Request.QueryString["S_Id"]); se.BeginDate = Convert.ToDateTime(txtBeginDate.Value); string FileName = System.IO.Path.GetFileName(fuBillPhoto.PostedFile.FileName).ToLower(); if (!string.IsNullOrEmpty(FileName)) { fuBillPhoto.PostedFile.SaveAs(Server.MapPath("~/images/UpLoad/" + FileName)); se.BillPhoto = "~/images/UpLoad/" + FileName; } else { se.BillPhoto = ""; } image.ImageUrl = se.BillPhoto; se.CarMark = ddlCarMark.SelectedItem.Text; se.CarType = rblCarType.SelectedValue; se.S_Reason = txtS_Reason.Text; se.EndDate = Convert.ToDateTime(txtEndDate.Value); se.JerquePeople = ddlJerquePeople.SelectedItem.Text; se.S_Branch = ddlS_Branch.SelectedItem.Text; se.S_Cost = Convert.ToDouble(txtS_Cost.Text); se.S_FactoryName = txtS_FactoryName.Text; se.S_People = ddlS_People.SelectedItem.Text; se.S_Result = txtS_Result.Text; se.S_Type = ddlS_Type.SelectedValue; se.UseCost = Convert.ToDouble(txtUseCost.Text); if (name == "Up") { int result = ServicesManager.updateService(se); if (result != 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新成功!');window.location.href='Servicelist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新失败!');", true); return; } } else { int result = ServicesManager.addService(se); if (result != 0) { int id = Convert.ToInt32(ddlCarMark.SelectedItem.Value); Car_Cars car = CarsManager.GetAllCarsById(id); car.State = "未出车"; car.Car_Id = id; CarsManager.UpdateCars(car); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功!');window.location.href='Servicelist.aspx'", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!');", true); return; } } }