private static Model.Vehicle SetVehicle(WC.Table table) { Model.Vehicle vehicleEntity; vehicleEntity = new Model.Vehicle(); UpdateVehicle(vehicleEntity, table); return(vehicleEntity); }
private static void UpdateVehicle(Model.Vehicle vehicleEntity, WC.Table table) { vehicleEntity.Year = GetCellByLabel <int>(table, "Year:", true); vehicleEntity.Make = GetCellByLabel(table, "Make:"); vehicleEntity.Model = GetCellByLabel(table, "Model:"); vehicleEntity.TrimLevel = GetCellByLabel(table, "Trim Level:"); vehicleEntity.Odometer = GetCellByLabel <int>(table, "Odometer:", true); vehicleEntity.InServiceDate = GetCellByLabel(table, "In-Service Date:"); vehicleEntity.FuelType = GetCellByLabel(table, "Fuel Type:"); vehicleEntity.Engine = GetCellByLabel(table, "Engine:"); vehicleEntity.Displacement = GetCellByLabel(table, "Displacement:"); vehicleEntity.Transmission = GetCellByLabel(table, "Transmission:"); vehicleEntity.ExteriorColor = GetCellByLabel(table, "Exterior Color:"); vehicleEntity.InteriorColor = GetCellByLabel(table, "Interior Color:"); vehicleEntity.WindowSticker = GetCellByLabel(table, "Window Sticker:"); vehicleEntity.VIN = GetCellByLabel(table, "VIN:"); vehicleEntity.BodyStyle = GetCellByLabel(table, "Body Style:"); vehicleEntity.Doors = GetCellByLabel <int>(table, "Doors:", true); vehicleEntity.VehicleType = GetCellByLabel(table, "Vehicle Type:"); vehicleEntity.Salvage = GetCellByLabel(table, "Salvage:") != "No"; vehicleEntity.TitleState = GetCellByLabel(table, "Title State:"); vehicleEntity.TitleStatus = GetCellByLabel(table, "Title Status:"); vehicleEntity.DriveTrain = GetCellByLabel(table, "Drive Train:"); vehicleEntity.InteriorType = GetCellByLabel(table, "Interior Type:"); vehicleEntity.TopType = GetCellByLabel(table, "Top Type:"); vehicleEntity.Stereo = GetCellByLabel(table, "Stereo:"); vehicleEntity.Airbags = GetCellByLabel(table, "Airbags:"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserKey"] != null) { u = Model.UserDb.GetUserById(Session["UserKey"]); Master.LabelOnMasterPage.Text = u.FullName; // If the userType is not Passenger, redirect to main page. if(u.UserType != 1) { Response.Redirect("Default.aspx"); } else { if (Request.QueryString["id"] != "") { vehicleId = Convert.ToInt32(Request.QueryString["id"]); v = Model.VehicleDb.getVehicleById(vehicleId); lblDriver.Text = Model.UserDb.GetUserById(v.DriverId).FullName; lblModel.Text = v.Model; lblCost.Text = v.Cost.ToString(); } else { Response.Redirect("Default.aspx"); } } } else { Response.Redirect("Default.aspx"); } }
private bool DoAdd() { bool result = false; Model.Vehicle model = new Model.Vehicle(); BLL.Vehicle bll = new BLL.Vehicle(); model.MotorcadeName = ddlMotorcadeName.SelectedValue; model.CarCode = txtCarCode.Text.Trim(); model.CarNumber = string.IsNullOrEmpty(txtCarNumber.Text.Trim()) ? model.CarCode : txtCarNumber.Text.Trim(); model.MotorcycleType = ddlMotorcycleType.SelectedValue; model.EngineType = txtEngineType.Text.Trim(); model.ChassisNumber = txtChassisNumber.Text.Trim(); model.FrameNumber = txtFrameNumber.Text.Trim(); model.InsuranceNumber = txtInsuranceNumber.Text.Trim(); model.LoadingCapacity = Utils.StrToDecimal(txtLoadingCapacity.Text.Trim(), 0.00M); model.Remarks = txtRemarks.Text.Trim(); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.CarCode); //记录日志 result = true; } return(result); }
protected void SubmitButton_Click(object sender, EventArgs e) { Model.VehicleModel model = new Model.VehicleModel { Id = Convert.ToInt32(vehicleModelDropDown.SelectedItem.Value) }; Model.Vehicle vehicle = new Model.Vehicle { RegisterNumber = registerNumberTextBox.Text, EngineNumber = engineNumberTextBox.Text, ChassisNumber = chassisNumberTextBox.Text, EnginePower = Convert.ToInt32(enginePowerTextBox.Text), NumberOfSeats = Convert.ToInt32(numberOfSeatsTextBox.Text), Model = model, Price = Convert.ToDecimal(priceTextBox.Text), ProductionYear = Convert.ToInt32(productionYearTextBox.Text) }; string regNumber = Request.QueryString["regNumber"]; if (string.IsNullOrEmpty(regNumber)) { vehicleDao.InsertVehicle(vehicle); } else { vehicleDao.UpdateVehicle(vehicle); } Response.Redirect("~/Pages/Vehicle/Vehicles.aspx"); }
/// <summary> /// 获得数据列表 /// </summary> public List <Model.Vehicle> DataTableToList(DataTable dt) { List <Model.Vehicle> modelList = new List <Model.Vehicle>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Vehicle model; for (int n = 0; n < rowsCount; n++) { model = new Model.Vehicle(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.CarCode = dt.Rows[n]["CarCode"].ToString(); model.CarNumber = dt.Rows[n]["CarNumber"].ToString(); model.MotorcadeName = dt.Rows[n]["MotorcadeName"].ToString(); model.MotorcycleType = dt.Rows[n]["MotorcycleType"].ToString(); if (dt.Rows[n]["LoadingCapacity"].ToString() != "") { model.LoadingCapacity = decimal.Parse(dt.Rows[n]["LoadingCapacity"].ToString()); } model.EngineType = dt.Rows[n]["EngineType"].ToString(); model.FrameNumber = dt.Rows[n]["FrameNumber"].ToString(); model.ChassisNumber = dt.Rows[n]["ChassisNumber"].ToString(); model.InsuranceNumber = dt.Rows[n]["InsuranceNumber"].ToString(); model.Remarks = dt.Rows[n]["Remarks"].ToString(); modelList.Add(model); } } return(modelList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindModelDropDownValues(); string regNumber = Request.QueryString["regNumber"]; if (!string.IsNullOrEmpty(regNumber)) { Model.Vehicle vehicleForEditing = vehicleDao.GetVehicle(regNumber); if (vehicleForEditing == null) { throw new Exception("Nema vozila sa tim registarskim brojem."); } heading.Text = "<h1>Izmeni vozilo</h1>"; submitButton.Text = "Izmeni"; registerNumberTextBox.ReadOnly = true; registerNumberTextBox.Text = vehicleForEditing.RegisterNumber; engineNumberTextBox.Text = vehicleForEditing.EngineNumber; chassisNumberTextBox.Text = vehicleForEditing.ChassisNumber; enginePowerTextBox.Text = Convert.ToString(vehicleForEditing.EnginePower); numberOfSeatsTextBox.Text = Convert.ToString(vehicleForEditing.NumberOfSeats); vehicleModelDropDown.SelectedValue = Convert.ToString(vehicleForEditing.Model.Id); priceTextBox.Text = Convert.ToString(vehicleForEditing.Price); productionYearTextBox.Text = Convert.ToString(vehicleForEditing.ProductionYear); } } }
//Airport's actions private void doVehicle() { Model.Vehicle mAirport = new Model.Vehicle(); Controller.Vehicle cAirport = new Controller.Vehicle(); if (cmbVehicleActions.SelectedIndex == 0)//nothing { MessageBox.Show("Please, choose an action!"); } else if (cmbVehicleActions.SelectedIndex == 1)//select { refreshVehicles(); } else if (cmbVehicleActions.SelectedIndex == 2)//delete { int select = dgvVehicles.CurrentCell.RowIndex; mAirport.id = Convert.ToInt32(dgvVehicles.Rows[select].Cells["cVehicleId"].Value.ToString()); cAirport = new Controller.Vehicle(mAirport); cAirport.delete(); refreshAirports(); } else if (cmbVehicleActions.SelectedIndex == 3)//update { saveVecicle(); } else if (cmbVehicleActions.SelectedIndex == 4)//insert { saveVecicle(); } }
/// <summary> /// 获得数据列表 /// </summary> public List<Model.Vehicle> DataTableToList(DataTable dt) { List<Model.Vehicle> modelList = new List<Model.Vehicle>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Vehicle model; for (int n = 0; n < rowsCount; n++) { model = new Model.Vehicle(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.CarCode = dt.Rows[n]["CarCode"].ToString(); model.CarNumber = dt.Rows[n]["CarNumber"].ToString(); model.MotorcadeName = dt.Rows[n]["MotorcadeName"].ToString(); model.MotorcycleType = dt.Rows[n]["MotorcycleType"].ToString(); if (dt.Rows[n]["LoadingCapacity"].ToString() != "") { model.LoadingCapacity = decimal.Parse(dt.Rows[n]["LoadingCapacity"].ToString()); } model.EngineType = dt.Rows[n]["EngineType"].ToString(); model.FrameNumber = dt.Rows[n]["FrameNumber"].ToString(); model.ChassisNumber = dt.Rows[n]["ChassisNumber"].ToString(); model.InsuranceNumber = dt.Rows[n]["InsuranceNumber"].ToString(); model.Remarks = dt.Rows[n]["Remarks"].ToString(); modelList.Add(model); } } return modelList; }
public bool Add(Model.Vehicle model, Model.Driver driver) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mtms_Vehicle("); strSql.Append("CarCode,CarNumber,MotorcadeName,MotorcycleType,LoadingCapacity,EngineType,FrameNumber,ChassisNumber,InsuranceNumber,Remarks"); strSql.Append(") values ("); strSql.Append("@CarCode,@CarNumber,@MotorcadeName,@MotorcycleType,@LoadingCapacity,@EngineType,@FrameNumber,@ChassisNumber,@InsuranceNumber,@Remarks"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CarCode", SqlDbType.VarChar, 254), new SqlParameter("@CarNumber", SqlDbType.VarChar, 254), new SqlParameter("@MotorcadeName", SqlDbType.VarChar, 254), new SqlParameter("@MotorcycleType", SqlDbType.VarChar, 254), new SqlParameter("@LoadingCapacity", SqlDbType.Decimal, 9), new SqlParameter("@EngineType", SqlDbType.VarChar, 254), new SqlParameter("@FrameNumber", SqlDbType.VarChar, 254), new SqlParameter("@ChassisNumber", SqlDbType.VarChar, 254), new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254), new SqlParameter("@Remarks", SqlDbType.VarChar, 254) }; parameters[0].Value = model.CarCode; parameters[1].Value = model.CarNumber; parameters[2].Value = model.MotorcadeName; parameters[3].Value = model.MotorcycleType; parameters[4].Value = model.LoadingCapacity; parameters[5].Value = model.EngineType; parameters[6].Value = model.FrameNumber; parameters[7].Value = model.ChassisNumber; parameters[8].Value = model.InsuranceNumber; parameters[9].Value = model.Remarks; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); new Driver().Add(conn, trans, driver); trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }
private void ShowInfo(int _id) { BLL.Vehicle bll = new BLL.Vehicle(); Model.Vehicle model = bll.GetModel(_id); txtPlateNumber.Text = model.PlateNumber; txtDriver.Text = model.Driver; txtLinkTel.Text = model.LinkTel; txtLinkAddress.Text = model.LinkAddress; txtRemark.Text = model.Remark; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Vehicle model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mtms_Vehicle set "); strSql.Append(" CarCode = @CarCode , "); strSql.Append(" CarNumber = @CarNumber , "); strSql.Append(" MotorcadeName = @MotorcadeName , "); strSql.Append(" MotorcycleType = @MotorcycleType , "); strSql.Append(" LoadingCapacity = @LoadingCapacity , "); strSql.Append(" EngineType = @EngineType , "); strSql.Append(" FrameNumber = @FrameNumber , "); strSql.Append(" ChassisNumber = @ChassisNumber , "); strSql.Append(" InsuranceNumber = @InsuranceNumber , "); strSql.Append(" Remarks = @Remarks "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@CarCode", SqlDbType.VarChar, 254), new SqlParameter("@CarNumber", SqlDbType.VarChar, 254), new SqlParameter("@MotorcadeName", SqlDbType.VarChar, 254), new SqlParameter("@MotorcycleType", SqlDbType.VarChar, 254), new SqlParameter("@LoadingCapacity", SqlDbType.Decimal, 9), new SqlParameter("@EngineType", SqlDbType.VarChar, 254), new SqlParameter("@FrameNumber", SqlDbType.VarChar, 254), new SqlParameter("@ChassisNumber", SqlDbType.VarChar, 254), new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254), new SqlParameter("@Remarks", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CarCode; parameters[2].Value = model.CarNumber; parameters[3].Value = model.MotorcadeName; parameters[4].Value = model.MotorcycleType; parameters[5].Value = model.LoadingCapacity; parameters[6].Value = model.EngineType; parameters[7].Value = model.FrameNumber; parameters[8].Value = model.ChassisNumber; parameters[9].Value = model.InsuranceNumber; parameters[10].Value = model.Remarks; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void ThenDelegatesToVehicleRepository() { var vehicle = new Model.Vehicle { VehicleId = DefaultVehicleId, Name = "Name" }; _vehicleRepo .Setup(vr => vr.GetVehicle(UserId, DefaultVehicleId)) .Returns(vehicle); var handler = new DeleteVehicle(_vehicleRepo.Object); handler.Execute(UserId, DefaultVehicleId); _vehicleRepo.Verify(r => r.Delete(DefaultVehicleId), Times.Once()); }
public static Model.Vehicle ConvertFromDomain(DomainModel.Vehicle source) { var destin = new Model.Vehicle(); destin.Id = source.Id; destin.Route = source.Route; destin.Latitude = source.Latitude; destin.Longitude = source.Longitude; destin.SecondsSinceReport = source.SecondsSinceReport; destin.Distance = source.DistanceFromBusStop.ToString("N0"); destin.CreatedOn = DateTime.Now; return(destin); }
public static void PostVehicle(Model.Vehicle vehicle) { try { using (var context = DBParkingHRSEntities.Instance) { context.Vehicle.Add(vehicle); context.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static void PutVehicle(Model.Vehicle vehicle) { try { using (var context = DBParkingHRSEntities.Instance) { context.Entry(vehicle).State = EntityState.Modified; context.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void ThenDelegatesToVehicleRepository() { var vehicle = new Model.Vehicle { VehicleId = DefaultVehicleId, Name = "Name" }; _vehicleRepo .Setup(vr => vr.GetVehicle(UserId, DefaultVehicleId)) .Returns(vehicle); var handler = new DeleteVehicle(_vehicleRepo.Object); handler.Execute(UserId, DefaultVehicleId); _vehicleRepo.Verify(r => r.Delete(DefaultVehicleId), Times.Once()); }
private void ShowInfo(int _id) { BLL.Vehicle bll = new BLL.Vehicle(); Model.Vehicle model = bll.GetModel(_id); ddlMotorcadeName.SelectedValue = model.MotorcadeName; txtCarCode.Text = model.CarCode; txtCarNumber.Text = model.CarNumber; ddlMotorcycleType.SelectedValue = model.MotorcycleType; txtEngineType.Text = model.EngineType; txtChassisNumber.Text = model.ChassisNumber; txtFrameNumber.Text = model.FrameNumber; txtInsuranceNumber.Text = model.InsuranceNumber; txtLoadingCapacity.Text = model.LoadingCapacity.ToString(); txtRemarks.Text = model.Remarks; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Vehicle model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mtms_Vehicle("); strSql.Append("CarCode,CarNumber,MotorcadeName,MotorcycleType,LoadingCapacity,EngineType,FrameNumber,ChassisNumber,InsuranceNumber,Remarks"); strSql.Append(") values ("); strSql.Append("@CarCode,@CarNumber,@MotorcadeName,@MotorcycleType,@LoadingCapacity,@EngineType,@FrameNumber,@ChassisNumber,@InsuranceNumber,@Remarks"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CarCode", SqlDbType.VarChar, 254), new SqlParameter("@CarNumber", SqlDbType.VarChar, 254), new SqlParameter("@MotorcadeName", SqlDbType.VarChar, 254), new SqlParameter("@MotorcycleType", SqlDbType.VarChar, 254), new SqlParameter("@LoadingCapacity", SqlDbType.Decimal, 9), new SqlParameter("@EngineType", SqlDbType.VarChar, 254), new SqlParameter("@FrameNumber", SqlDbType.VarChar, 254), new SqlParameter("@ChassisNumber", SqlDbType.VarChar, 254), new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254), new SqlParameter("@Remarks", SqlDbType.VarChar, 254) }; parameters[0].Value = model.CarCode; parameters[1].Value = model.CarNumber; parameters[2].Value = model.MotorcadeName; parameters[3].Value = model.MotorcycleType; parameters[4].Value = model.LoadingCapacity; parameters[5].Value = model.EngineType; parameters[6].Value = model.FrameNumber; parameters[7].Value = model.ChassisNumber; parameters[8].Value = model.InsuranceNumber; parameters[9].Value = model.Remarks; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int _id) { BLL.Vehicle bll = new BLL.Vehicle(); Model.Vehicle model = bll.GetModel(_id); if (model != null) { txtCarCode.Text = model.CarCode; BLL.Driver driverBLL = new BLL.Driver(); Model.Driver driver = driverBLL.GetModel(model.CarCode); if (driver != null) { txtRealName.Text = driver.RealName; txtLinkTel.Text = driver.LinkTel; } } }
private bool DoEdit(int _id) { bool result = false; BLL.Vehicle bll = new BLL.Vehicle(); Model.Vehicle model = bll.GetModel(_id); string carNumber = model.CarNumber; model.MotorcadeName = ""; model.CarCode = txtCarCode.Text.Trim(); model.CarNumber = model.CarCode; model.MotorcycleType = ""; model.EngineType = ""; model.ChassisNumber = ""; model.FrameNumber = ""; model.InsuranceNumber = ""; model.LoadingCapacity = 0.00M; model.Remarks = ""; BLL.Driver driverBll = new BLL.Driver(); Model.Driver driver = driverBll.GetModel(carNumber); driver.CarNumber = model.CarNumber; driver.RealName = txtRealName.Text.Trim(); driver.RealNameCode = ""; driver.IdCardNumber = ""; driver.LinkTel = txtLinkTel.Text.Trim(); driver.LinkAddress = ""; driver.BeganWorkDate = DateTime.Now; driver.IssuedDate = DateTime.Now; driver.AnnualDate = DateTime.Now; driver.DrivingLicence = ""; driver.DrivingPermitNumber = ""; driver.DrivingPermitType = ""; driver.IsDimission = 0; driver.Remarks = ""; if (bll.Update(model, driver)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改车辆信息:" + model.CarCode); //记录日志 result = true; } return(result); }
private void btnSave_Click(object sender, EventArgs e) { if (txtVehicleNo.Text == String.Empty) { MessageBox.Show("Please type Vehicle No"); } else if (txtVehicleName.Text == String.Empty) { MessageBox.Show("Please type Vehicle Name"); } else if (txtRatePerDay.Text == String.Empty) { MessageBox.Show("Please type Rate Per Day"); } else if (txtRatePerWeek.Text == String.Empty) { MessageBox.Show("Please type rate per Week"); } else if (txtRatePerMonth.Text == String.Empty) { MessageBox.Show("Please type rate per Month"); } else { if (db.Vehicles.Any(p => p.VehicleNo == txtVehicleNo.Text)) { MessageBox.Show("This Vehicle No already Recorded. Please type Unique Vehicle No..."); } else { Model.Vehicle model = new Model.Vehicle() { VehicleNo = txtVehicleNo.Text, VehicleName = txtVehicleName.Text, RatePerDay = Convert.ToInt32(txtRatePerDay.Text), RatePerWeek = Convert.ToInt32(txtRatePerWeek.Text), RatePerMonth = Convert.ToInt32(txtRatePerMonth.Text) }; db.Vehicles.Add(model); db.SaveChanges(); MessageBox.Show("Vehicle details Successfully Saved"); this.Close(); } } }
private bool DoAdd() { bool result = false; Model.Vehicle model = new Model.Vehicle(); BLL.Vehicle bll = new BLL.Vehicle(); model.PlateNumber = txtPlateNumber.Text; model.Driver = txtDriver.Text; model.LinkTel = txtLinkTel.Text; model.LinkAddress = txtLinkAddress.Text; model.Remark = txtRemark.Text; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.PlateNumber); //记录日志 result = true; } return result; }
protected void SubmitButton_Click(object sender, EventArgs e) { Model.Affiliate affiliate = new Model.Affiliate { Id = Convert.ToInt32(affiliateDropDown.SelectedItem.Value) }; Model.Agent agent = new Model.Agent { Id = Convert.ToInt32(agentDropDown.SelectedItem.Value) }; Model.RiskPackage riskPackage = new Model.RiskPackage { Id = Convert.ToInt32(riskPackageDropDown.SelectedItem.Value) }; Model.Insured insured = new Model.Insured { Id = Convert.ToInt32(insuredDropDown.SelectedItem.Value) }; Model.Vehicle vehicle = new Model.Vehicle { RegisterNumber = registerNumberDropDown.SelectedItem.Value }; Model.Policy policy = new Model.Policy { CreatedOn = DateTime.Now, StartDate = Convert.ToDateTime(startDateTextBox.Value), EndDate = Convert.ToDateTime(expireDateTextBox.Value), Affiliate = affiliate, Agent = agent, Insured = insured, Premium = Convert.ToDecimal(premiumTextBox.Text), RiskPackage = riskPackage, Vehicle = vehicle }; policyDao.InsertPolicy(policy); Response.Redirect("~/Pages/Policy/Policies.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Vehicle GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, CarCode, CarNumber, MotorcadeName, MotorcycleType, LoadingCapacity, EngineType, FrameNumber, ChassisNumber, InsuranceNumber, Remarks "); strSql.Append(" from mtms_Vehicle "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.Vehicle model = new Model.Vehicle(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.CarCode = ds.Tables[0].Rows[0]["CarCode"].ToString(); model.CarNumber = ds.Tables[0].Rows[0]["CarNumber"].ToString(); model.MotorcadeName = ds.Tables[0].Rows[0]["MotorcadeName"].ToString(); model.MotorcycleType = ds.Tables[0].Rows[0]["MotorcycleType"].ToString(); if (ds.Tables[0].Rows[0]["LoadingCapacity"].ToString() != "") { model.LoadingCapacity = decimal.Parse(ds.Tables[0].Rows[0]["LoadingCapacity"].ToString()); } model.EngineType = ds.Tables[0].Rows[0]["EngineType"].ToString(); model.FrameNumber = ds.Tables[0].Rows[0]["FrameNumber"].ToString(); model.ChassisNumber = ds.Tables[0].Rows[0]["ChassisNumber"].ToString(); model.InsuranceNumber = ds.Tables[0].Rows[0]["InsuranceNumber"].ToString(); model.Remarks = ds.Tables[0].Rows[0]["Remarks"].ToString(); return(model); } else { return(null); } }
private bool DoAdd() { bool result = false; Model.Vehicle model = new Model.Vehicle(); BLL.Vehicle bll = new BLL.Vehicle(); model.PlateNumber = txtPlateNumber.Text; model.Driver = txtDriver.Text; model.LinkTel = txtLinkTel.Text; model.LinkAddress = txtLinkAddress.Text; model.Remark = txtRemark.Text; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.PlateNumber); //记录日志 result = true; } return(result); }
private bool DoAdd() { bool result = false; Model.Vehicle model = new Model.Vehicle(); BLL.Vehicle bll = new BLL.Vehicle(); model.MotorcadeName = ""; model.CarCode = txtCarCode.Text.Trim(); model.CarNumber = model.CarCode; model.MotorcycleType = ""; model.EngineType = ""; model.ChassisNumber = ""; model.FrameNumber = ""; model.InsuranceNumber = ""; model.LoadingCapacity = 0.00M; model.Remarks = ""; Model.Driver driver = new Model.Driver(); BLL.Driver driverBll = new BLL.Driver(); driver.CarNumber = model.CarNumber; driver.RealName = txtRealName.Text.Trim(); driver.RealNameCode = ""; driver.IdCardNumber = ""; driver.LinkTel = txtLinkTel.Text.Trim(); driver.LinkAddress = ""; driver.BeganWorkDate = DateTime.Now; driver.IssuedDate = DateTime.Now; driver.AnnualDate = DateTime.Now; driver.DrivingLicence = ""; driver.DrivingPermitNumber = ""; driver.DrivingPermitType = ""; driver.IsDimission = 0; driver.Remarks = ""; if (bll.Add(model, driver)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.CarCode); //记录日志 result = true; } return result; }
private bool DoEdit(int _id) { bool result = false; BLL.Vehicle bll = new BLL.Vehicle(); Model.Vehicle model = bll.GetModel(_id); model.PlateNumber = txtPlateNumber.Text; model.Driver = txtDriver.Text; model.LinkTel = txtLinkTel.Text; model.LinkAddress = txtLinkAddress.Text; model.Remark = txtRemark.Text; if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改车辆:" + model.PlateNumber); //记录日志 result = true; } return(result); }
//saves an vehicle private void saveVecicle() { try { Model.Vehicle mVehicle = new Model.Vehicle(); int select = dgvVehicles.CurrentCell.RowIndex; mVehicle.make = dgvVehicles.Rows[select].Cells["cVehicleMake"].Value.ToString(); mVehicle.model = dgvVehicles.Rows[select].Cells["cVehicleModel"].Value.ToString(); mVehicle.id = Convert.ToInt32(dgvVehicles.Rows[select].Cells["cVehicleId"].Value.ToString()); mVehicle.type = dgvVehicles.Rows[select].Cells["cVehicleType"].Value.ToString(); mVehicle.price = Convert.ToDouble(dgvVehicles.Rows[select].Cells["cVehiclePrice"].Value.ToString()); mVehicle.ammount = Convert.ToInt32(dgvVehicles.Rows[select].Cells["cVehicleAmmount"].Value.ToString()); Controller.Vehicle cVehcle = new Controller.Vehicle(mVehicle); cVehcle.insert(); refreshVehicles(); } catch (Exception e) { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserKey"] != null) { u = Model.UserDb.GetUserById(Session["UserKey"]); Master.LabelOnMasterPage.Text = u.FullName; uVehicle = Model.VehicleDb.getVehicleByUserId(u.Id); // If the user has a vehicle registered, insert vehicle data in web forms. if (uVehicle != null) { if(!IsPostBack) // This control is needed for update process. { txtModel.Text = uVehicle.Model; txtYear.Text = uVehicle.Year.ToString(); txtLicenseNumber.Text = uVehicle.LicenseNumber; txtCity.Text = uVehicle.City; txtCost.Text = uVehicle.Cost.ToString(); } // If the user has already a vehicle registered, show them update button. btnAdd.Visible = false; btnUpdate.Visible = true; } else { // If the user has no vehicle registered, show them add button. btnAdd.Visible = true; btnUpdate.Visible = false; } } else { Response.Redirect("Default.aspx"); } }
private bool DoAdd() { bool result = false; Model.Vehicle model = new Model.Vehicle(); BLL.Vehicle bll = new BLL.Vehicle(); model.MotorcadeName = ddlMotorcadeName.SelectedValue; model.CarCode = txtCarCode.Text.Trim(); model.CarNumber = string.IsNullOrEmpty(txtCarNumber.Text.Trim()) ? model.CarCode : txtCarNumber.Text.Trim(); model.MotorcycleType = ddlMotorcycleType.SelectedValue; model.EngineType = txtEngineType.Text.Trim(); model.ChassisNumber = txtChassisNumber.Text.Trim(); model.FrameNumber = txtFrameNumber.Text.Trim(); model.InsuranceNumber = txtInsuranceNumber.Text.Trim(); model.LoadingCapacity = Utils.StrToDecimal(txtLoadingCapacity.Text.Trim(), 0.00M); model.Remarks = txtRemarks.Text.Trim(); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.CarCode); //记录日志 result = true; } return result; }
protected void btnUpdateVehicle_Click(object sender, EventArgs e) { if (txtModel.Text.Trim() != "" && txtYear.Text.Trim() != "" && txtLicenseNumber.Text.Trim() != "" && txtCity.Text.Trim() != "" && txtCost.Text.Trim() != "") { Model.Vehicle v = new Model.Vehicle() { Id = uVehicle.Id, Model = txtModel.Text.Trim(), Year = Int32.Parse(txtYear.Text.Trim()), LicenseNumber = txtLicenseNumber.Text.Trim(), City = txtCity.Text.Trim(), Cost = float.Parse(txtCost.Text.Trim()) }; bool result = Model.VehicleDb.Update(v); if (result) lblInfo.Text = "Your vehicle has been updated successfully."; else lblInfo.Text = "An error has been occured while updating."; } else lblInfo.Text = "You must fill out all the required fields."; }
public Vehicle() { this.vehicles = new Model.Vehicle(); }
public bool Update(Model.Vehicle model, Model.Driver driver) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update mtms_Vehicle set "); strSql.Append(" CarCode = @CarCode , "); strSql.Append(" CarNumber = @CarNumber , "); strSql.Append(" MotorcadeName = @MotorcadeName , "); strSql.Append(" MotorcycleType = @MotorcycleType , "); strSql.Append(" LoadingCapacity = @LoadingCapacity , "); strSql.Append(" EngineType = @EngineType , "); strSql.Append(" FrameNumber = @FrameNumber , "); strSql.Append(" ChassisNumber = @ChassisNumber , "); strSql.Append(" InsuranceNumber = @InsuranceNumber , "); strSql.Append(" Remarks = @Remarks "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@CarCode", SqlDbType.VarChar, 254), new SqlParameter("@CarNumber", SqlDbType.VarChar, 254), new SqlParameter("@MotorcadeName", SqlDbType.VarChar, 254), new SqlParameter("@MotorcycleType", SqlDbType.VarChar, 254), new SqlParameter("@LoadingCapacity", SqlDbType.Decimal, 9), new SqlParameter("@EngineType", SqlDbType.VarChar, 254), new SqlParameter("@FrameNumber", SqlDbType.VarChar, 254), new SqlParameter("@ChassisNumber", SqlDbType.VarChar, 254), new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254), new SqlParameter("@Remarks", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CarCode; parameters[2].Value = model.CarNumber; parameters[3].Value = model.MotorcadeName; parameters[4].Value = model.MotorcycleType; parameters[5].Value = model.LoadingCapacity; parameters[6].Value = model.EngineType; parameters[7].Value = model.FrameNumber; parameters[8].Value = model.ChassisNumber; parameters[9].Value = model.InsuranceNumber; parameters[10].Value = model.Remarks; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); new Driver().Update(conn, trans, driver); trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }
public Vehicle(Model.Vehicle vehicles) { this.vehicles = vehicles; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Vehicle GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, CarCode, CarNumber, MotorcadeName, MotorcycleType, LoadingCapacity, EngineType, FrameNumber, ChassisNumber, InsuranceNumber, Remarks "); strSql.Append(" from mtms_Vehicle "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; Model.Vehicle model = new Model.Vehicle(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.CarCode = ds.Tables[0].Rows[0]["CarCode"].ToString(); model.CarNumber = ds.Tables[0].Rows[0]["CarNumber"].ToString(); model.MotorcadeName = ds.Tables[0].Rows[0]["MotorcadeName"].ToString(); model.MotorcycleType = ds.Tables[0].Rows[0]["MotorcycleType"].ToString(); if (ds.Tables[0].Rows[0]["LoadingCapacity"].ToString() != "") { model.LoadingCapacity = decimal.Parse(ds.Tables[0].Rows[0]["LoadingCapacity"].ToString()); } model.EngineType = ds.Tables[0].Rows[0]["EngineType"].ToString(); model.FrameNumber = ds.Tables[0].Rows[0]["FrameNumber"].ToString(); model.ChassisNumber = ds.Tables[0].Rows[0]["ChassisNumber"].ToString(); model.InsuranceNumber = ds.Tables[0].Rows[0]["InsuranceNumber"].ToString(); model.Remarks = ds.Tables[0].Rows[0]["Remarks"].ToString(); return model; } else { return null; } }
public Model.Vehicle Add(Model.Vehicle entity) { return(RepositoryProvider.Instance.Add(entity)); }
public bool Update(Model.Vehicle entity) { return(RepositoryProvider.Instance.Update(entity)); }
public bool Remove(Model.Vehicle entity) { return(RepositoryProvider.Instance.Remove(entity)); }