public CarModel UploadCarImage(string carNumber, string img) { CarModel carModel = GetOneCar(carNumber); carModel.carPicture = img; if (GlobalVariable.queryType == 0) { CAR car = DB.CARS.Where(c => c.carNumber.Equals(carNumber)).SingleOrDefault(); if (car == null) { return(null); } car.carPicture = img; DB.SaveChanges(); return(GetOneCar(car.carNumber)); } else { return(DB.UpdateCar(carModel.carKm, carModel.carPicture, carModel.carInShape, carModel.carAvaliable, carModel.carNumber, carModel.carBranchID, carModel.carTypeID).Select(c => new CarModel { carNumber = c.carNumber, carTypeID = c.carTypeID, carKm = c.carKm, carPicture = c.carPicture != null ? "/assets/images/cars/" + c.carPicture : null, carInShape = c.carInShape, carAvaliable = c.carAvaliable, carBranchID = c.carBranchID }).SingleOrDefault()); } }
public CarModel AddCar(CarModel carModel) { if (GlobalVariable.queryType == 0) { CAR car = new CAR { carNumber = carModel.carNumber, carTypeID = carModel.carTypeID, carKm = carModel.carKm, carPicture = carModel.carPicture, carInShape = carModel.carInShape, carAvaliable = carModel.carAvaliable, carBranchID = carModel.carBranchID }; DB.CARS.Add(car); DB.SaveChanges(); return(GetOneCar(car.carNumber)); } else { return(DB.AddCar(carModel.carKm, carModel.carPicture, carModel.carInShape, carModel.carAvaliable, carModel.carNumber, carModel.carBranchID, carModel.carTypeID).Select(c => new CarModel { carNumber = c.carNumber, carTypeID = c.carTypeID, carKm = c.carKm, carPicture = c.carPicture != null ? "/assets/images/cars/" + c.carPicture : null, carInShape = c.carInShape, carAvaliable = c.carAvaliable, carBranchID = c.carBranchID }).SingleOrDefault()); } }
/// <summary> /// Create a new CAR object. /// </summary> /// <param name="id">Initial value of ID.</param> /// <param name="cNAME">Initial value of CNAME.</param> /// <param name="iDCLASS">Initial value of IDCLASS.</param> public static CAR CreateCAR(int id, string cNAME, int iDCLASS) { CAR cAR = new CAR(); cAR.ID = id; cAR.CNAME = cNAME; cAR.IDCLASS = iDCLASS; return(cAR); }
public ActionResult Edit([Bind(Include = "Kenteken,Merk,AutoType,DealerNr")] CAR cAR) { if (ModelState.IsValid) { db.Entry(cAR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DealerNr = new SelectList(db.DEALER, "DealerNr", "Naam", cAR.DealerNr); return(View(cAR)); }
public ActionResult Create([Bind(Include = "Kenteken,Merk,AutoType,DealerNr")] CAR cAR) { if (ModelState.IsValid) { cAR.InUse = 1; db.CAR.Add(cAR); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DealerNr = new SelectList(db.DEALER, "DealerNr", "Naam"); return(View(cAR)); }
private int AddNewCar(string cname, int cclass) { CAR c = new CAR(); c.CNAME = cname; c.IDCLASS = cclass; using (CWMEntities cwm = new CWMEntities(EnCon)) { cwm.AddToCAR(c); cwm.SaveChanges(); } return(c.ID); }
// GET: CAR/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CAR cAR = db.CAR.Find(id); if (cAR == null) { return(HttpNotFound()); } return(View(cAR)); }
public void AddCars(int id, string name, float price, int year, string Fuel, string Transmition, float kmDriven) { CAR car = new CAR(); car.Id = id; car.NAME = name; car.Price = price; car.YEAR = year; car.FUEL = Fuel; car.TRANSMITION = Transmition; car.KMDRIVEN = kmDriven; vehicleDBM.CARs.Add(car); vehicleDBM.SaveChanges(); }
static void Main(string[] args) { CAR ccCar = new CAR(); Owner ccOwner = new Owner(); ccCar.SetName("AXeme"); int year = int.Parse(Console.ReadLine()); ccCar.SetYear(year); Console.WriteLine(ccCar.GetYear()); ccCar.Year = year; Console.WriteLine(ccCar.Year); }
public ActionResult ChangeConfirmed(string id) { CAR cAR = db.CAR.Find(id); if (cAR.InUse == 1) { cAR.InUse = 0; } else { cAR.InUse = 1; } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(string id) { CAR cAR = db.CAR.Find(id); db.CAR.Remove(cAR); try { db.SaveChanges(); } catch (Exception err) { ModelState.AddModelError("error", err.Message); } return(RedirectToAction("Index")); }
// GET: CAR/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CAR cAR = db.CAR.Find(id); if (cAR == null) { return(HttpNotFound()); } ViewBag.DealerNr = new SelectList(db.DEALER, "DealerNr", "Naam", cAR.DealerNr); return(View(cAR)); }
public string DeleteCar(string num) { if (GlobalVariable.queryType == 0) { CAR car = DB.CARS.Where(c => c.carPicture.Equals(num)).SingleOrDefault(); DB.CARS.Attach(car); if (car == null) { return(""); } string str = car.carPicture; DB.CARS.Remove(car); DB.SaveChanges(); return(str); } else { return(DB.DeleteCar(num).ToString()); } }
private void AddCarButton(object sender) { Console.WriteLine(Mark); Console.WriteLine(model); Console.WriteLine(Registration); Console.WriteLine(Date); Console.WriteLine(engine); if (date == null || engine == 0 || mark == null || registration == null || model == null) { MessageBox.Show("всички полета са задължителни"); return; } CAR c = new CAR(); c.DATA = date; c.ENGINE_LITERS = engine; c.MARK = mark; c.REGISTRATION = registration; c.MODEL = model; bool flag = false; var q = (from a in ctx.OWNERS select a).ToList(); ObservableCollection <OWNER> owners = new ObservableCollection <OWNER>(q); foreach (OWNER o in owners) { if (o.NAME == NavigaterWindow.user.OWNER.NAME) { o.CARS.Add(c); ctx.Entry(o).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); flag = true; MessageBox.Show("adding car finished"); } } if (!flag) { MessageBox.Show("Error adding car"); } }
public void InsertCar(CAR car) { carRepo.CreateCar(car); }
/// <summary> /// Created By: HytechPro /// Created Date: 24-06-2015 /// Modified By: /// Modified Date: /// Objective: This method will save new car record to database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveData_Click(object sender, EventArgs e) { // ECRFEntities context=new ECRFEntities(); CAR objCar = new CAR(); bool blValue = ValidateRadioButton(); DateTime? dtDateIssued = null; DateTime? dtDatePressNotification = null; DateTime? dtDateDue = null; DateTime? dtDatePlannedComp1 = null; DateTime? dtDatePlannedComp2 = null; DateTime? dtDateActionPlanned = null; DateTime? dtDateApprove = null; DateTime? dtDateClose = null; List<CAR_Reference> lstCarReference = new List<CAR_Reference>(); string activeType = objsessionVariables.carType; if (!string.IsNullOrEmpty(txtDateIssued.Text)) dtDateIssued = DateTime.ParseExact(txtDateIssued.Text, "MM-dd-yyyy", null); else dtDateIssued = null; objCar.DateIssued = dtDateIssued; if (!blValue) { // message for check radio button ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('please select options below for satisfactory,accepted,effective and close car')", true); return; } else { try { objCar.Type = activeType; objCar.CarNumber = Convert.ToInt32(txtCarNumber.Text); if (ddlIssuedBy.SelectedIndex > 0) objCar.FK_DBKeyIssuedBy = (Convert.ToInt32(ddlIssuedBy.SelectedValue)); else objCar.FK_DBKeyIssuedBy = null; if (!string.IsNullOrEmpty(txtPlannedCompDate1.Text)) { dtDatePlannedComp2 = DateTime.ParseExact(txtPlannedCompDate2.Text, "MM-dd-yyyy", null); objCar.DatePlannedComplete = dtDatePlannedComp2; } else if (!string.IsNullOrEmpty(txtPlannedCompDate1.Text)) { dtDatePlannedComp1 = DateTime.ParseExact(txtPlannedCompDate1.Text, "MM-dd-yyyy", null); objCar.DatePlannedComplete = dtDatePlannedComp1; } else objCar.DatePlannedComplete = null; if (ddlIssuedTo.SelectedIndex > 0) objCar.FK_DBKeyIssuedTo = (Convert.ToInt32(ddlIssuedTo.SelectedValue)); else objCar.FK_DBKeyIssuedTo = null; //find dbkey of assigne To. int? intDbkeyAssignee = GetAssigneeDbKey(objCar.FK_DBKeyIssuedTo, txtAssignedTo.Text); if (intDbkeyAssignee != 0) objCar.FK_DBKeyDefaultAssigneeIssuedTo = intDbkeyAssignee; else objCar.FK_DBKeyDefaultAssigneeIssuedTo = null; if (!string.IsNullOrEmpty(txtResponseDue.Text)) dtDateDue = DateTime.ParseExact(txtResponseDue.Text, "MM-dd-yyyy", null); else dtDateDue = null; objCar.DateDue = dtDateDue; if (rdbtnEffectiveYes.Checked) objCar.Effective = true; else objCar.Effective = false; objCar.RootCause = txtareaRootCause.InnerText; objCar.PreventativeAction = txtareaPrsentativeAction.InnerText; objCar.CorrectiveAction = txtareaCorrectiveAction.InnerText; if (!string.IsNullOrEmpty(txtDateActionPlannedSubmitted.Text)) dtDateActionPlanned = DateTime.ParseExact(txtDateActionPlannedSubmitted.Text, "MM-dd-yyyy", null); else dtDateActionPlanned = null; objCar.DatePlannedSubmitted = dtDateActionPlanned; if (!string.IsNullOrEmpty(txtApproveDate.Text)) dtDateApprove = DateTime.ParseExact(txtApproveDate.Text, "MM-dd-yyyy", null); else dtDateApprove = null; objCar.EffIReviewDate = dtDateApprove; objCar.SubmittedBy = txtsubmittedBy.Text; objCar.EffReviewBy = txtAppBy.Text; objCar.Comments = txtComments.Text; objCar.Evidence = txtEvidence.Text; objCar.ClosedOutBy = txtCloseBy.Text; if (!string.IsNullOrEmpty(txtCloseDate.Text)) dtDateClose = DateTime.ParseExact(txtCloseDate.Text, "MM-dd-yyyy", null); else dtDateClose = null; objCar.DateClosed = dtDateClose; if (rdbtnMajor.Checked) objCar.Severity = true; else objCar.Severity = false; if (rdbtnSatisfactoryYes.Checked) objCar.Satisfactory = true; else objCar.Satisfactory = false; if (rdbtnCloseCarYes.Checked) objCar.CloseCar = true; else objCar.CloseCar = false; if (rdbtnAcceptedYes.Checked) objCar.Accepted = true; else objCar.Accepted = false; if (ddlFrom.SelectedIndex > 0) objCar.FK_DBKeyFrom = Convert.ToInt32(ddlFrom.SelectedValue); else objCar.FK_DBKeyFrom = null; if (ddlTo.SelectedIndex > 0) objCar.FK_DBKeyTo = Convert.ToInt32(ddlTo.SelectedValue); else objCar.FK_DBKeyTo = null; if (ViewState["ProjectDbKey"] != null) objCar.FK_DBKeyProject = Convert.ToInt32(ViewState["ProjectDbKey"]); else objCar.FK_DBKeyProject = null; if (!string.IsNullOrEmpty(txtDatePresident.Text)) dtDatePressNotification = DateTime.ParseExact(txtDatePresident.Text, "MM-dd-yyyy", null); else dtDatePressNotification = null; if (rdbtnPerfMeasure.Checked) objCar.PerfMeasures = true; else objCar.PerfMeasures = false; if (rdbtnResourceReq.Checked) objCar.ResourceReq = true; else objCar.ResourceReq = false; if (rdbtnKeyBussProcess.Checked) objCar.KeyBusProcess = true; else objCar.KeyBusProcess = false; if (rdbtnCorpObjective.Checked) objCar.CorpObj = true; else objCar.CorpObj = false; if (rdbtnOther.Checked) objCar.Other = txtareaOther.InnerText; else objCar.Other = string.Empty; objCar.PresNotification = dtDatePressNotification; objCar.PreparedBy = txtPrepredBy.Text; objCar.SystemAffected = txtsysAffected.Text; objCar.Drawing = txtDwgNo.Text; objCar.ItemAffected = txtItemAffected.Text; objCar.ItemNumber = txtItemNumber.Text; objCar.ActionID = txtCustomerCarNo.Text; objCar.Discrepancy = txtareaDeficiency.InnerText; objCar.Status = ConfigurationManager.AppSettings["ValidStatus"].ToString(); if (objsessionVariables.mode == ConfigurationManager.AppSettings["CreateMode"].ToString()) { //save car to database if (!IsDuplicateCar(objCar.CarNumber, objCar.Type, objCar.DateIssued.Value.Year)) { clsCAR.SaveCar(objCar); //save references to database int carDbKey = GetCarDbKey(activeType, objCar.DateIssued.Value.Year, objCar.CarNumber); string strRefrenes = string.Empty; foreach (ListItem li in lstboxRefs.Items) { CAR_Reference objCarReference = new CAR_Reference(); objCarReference.FK_DBKeyCAR = carDbKey; objCarReference.CarNumber = objCar.CarNumber; objCarReference.CarType = objCar.Type; objCarReference.Year = objCar.DateIssued.Value.Year.ToString(); objCarReference.Reference = li.ToString(); lstCarReference.Add(objCarReference); } clsCAR.SaveReferences(lstCarReference); DisableControls(Page, false); DisableTextAreas(true); btnSaveData.Enabled = false; btnOpenForEdit.Enabled = true; btnPreview.Enabled = false; btnPrintPdf.Enabled = false; btnVoidResc.Enabled = false; btnNotify.Enabled = false; btnClear.Enabled = false; objsessionVariables.mode = ConfigurationManager.AppSettings["ViewMode"].ToString(); } else { // duplicate message. ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('duplicate car number')", true); return; } } else if (objsessionVariables.mode == ConfigurationManager.AppSettings["EditMode"].ToString()) { if (objsessionVariables.carNumber != 0) objCar.DBKey = objsessionVariables.carNumber; else objCar.DBKey = GetCarDbKey(activeType, objCar.DateIssued.Value.Year, objCar.CarNumber); objCar.FK_DBKeyProject = (int?)ViewState["ProjectDBKey"]; clsCAR.UpdateCar(objCar); string strRefrenes = string.Empty; foreach (ListItem li in lstboxRefs.Items) { CAR_Reference objCarReference = new CAR_Reference(); objCarReference.FK_DBKeyCAR = objCar.DBKey; objCarReference.CarNumber = objCar.CarNumber; objCarReference.CarType = objCar.Type; objCarReference.Year = objCar.DateIssued.Value.Year.ToString(); objCarReference.Reference = li.ToString(); lstCarReference.Add(objCarReference); } List<CAR_Reference> carRereferencesToDelete = clsCAR.ReferencesToDelete(objCar.DBKey); clsCAR.DeleteReferences(carRereferencesToDelete); clsCAR.SaveReferences(lstCarReference); DisableControls(Page, false); DisableTextAreas(true); btnSaveData.Enabled = false; btnOpenForEdit.Enabled = true; btnPreview.Enabled = false; btnPrintPdf.Enabled = false; btnVoidResc.Enabled = false; btnNotify.Enabled = false; btnClear.Enabled = false; } } catch (Exception ex) { ErrorLog.WriteErrorLog("CAR", "CAR_Create.aspx", "btnSaveData_Click", ex.Message); } } }
public void CreateCar(CAR car) { db.CAR.Add(car); db.SaveChanges(); }
/// <summary> /// There are no comments for CAR in the schema. /// </summary> public void AddToCAR(CAR cAR) { base.AddObject("CAR", cAR); }