public void AddPurchaseTest() { Vehicle v = new Vehicle("type", "color", 100, "model", "make", true, true, 10, "here"); DBController.Save(v, DBObject.SaveTypes.Insert); DateTime startDate1 = new DateTime(2018, 1, 1); DateTime endDate1 = new DateTime(2018, 1, 2); Vehicle v2 = VehicleControl.FilterCar("type", "color", "make", 99, 101, true, true, "here", startDate1, endDate1).FirstOrDefault(); Assert.IsNotNull(v2); Customer c1 = new Customer("John", "Doe", "username", "password"); DBController.Save(c1, DBObject.SaveTypes.Insert); DateTime startDate = new DateTime(2018, 1, 1); DateTime endDate = new DateTime(2018, 1, 2); Purchase p1 = new Purchase(startDate, "here", v2, c1); PurchaseControl.AddPurchase(p1); Vehicle v3 = VehicleControl.FilterCar("type", "color", "make", 99, 101, true, true, "here", startDate, endDate).FirstOrDefault(); Assert.IsNull(v3); Vehicle v4 = VehicleControl.GetAllVehicles().Where(vehicle => vehicle.VehicleID == p1.VehicleID).FirstOrDefault(); Assert.IsTrue(v4.IsRented); }
private void ViewPurchasesForm_Load(object sender, EventArgs e) { PurchaseControl c = new PurchaseControl(); c.Dock = DockStyle.Fill; this.Controls.Add(c); this.WindowState = FormWindowState.Maximized; }
public void DeterminePurchaseCostTest() { Purchase p1 = DBController.GetAllRecords <Purchase>().FirstOrDefault(); Vehicle v1 = DBController.GetByPrimaryKey <Vehicle>(p1.VehicleID); int vehicleRate = v1.Rate; int amountT = vehicleRate * 100; PurchaseControl.DeterminePurchaseCost(p1); double amount = p1.Cost; Assert.AreEqual(amount, amountT); }
/// <summary> /// Once the purchase button is pressed, the information is stored in /// the purchase table, and the user is notified of their purchase order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buyButton_Click(object sender, System.EventArgs e) { _purchaseToPayFor.Location = _vehicleToPayFor.CurrentLocation; _purchaseToPayFor.PurchaseDate = _purchaseToPayFor.PurchaseDate.Date; PurchaseControl.AddPurchase(_purchaseToPayFor); ConfirmationPage c = new ConfirmationPage(_purchaseToPayFor) { MdiParent = MdiParent, ClientSize = new Size(), FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill }; WindowState = FormWindowState.Normal; c.Show(); }
public void FindPurchaseTest() { Vehicle v1 = new Vehicle(); VehicleControl.AddVehicle(v1); int key = v1.PrimaryKey; Purchase p1 = PurchaseControl.FindPurchase(key); Assert.IsNull(p1); p1 = new Purchase(); p1.VehicleID = key; Customer c1 = DBController.GetAllRecords <Customer>().FirstOrDefault(); p1.CustomerID = c1.PrimaryKey; PurchaseControl.AddPurchase(p1); Purchase p2 = PurchaseControl.FindPurchase(key); Assert.IsNotNull(p2); }
/// <summary> /// Enter button <seealso cref="Admin"/> presses after entering /// <seealso cref="Vehicle"/> ID. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { errorLabel.Visible = false; errorLabel.ForeColor = Color.Crimson; int vehicleID = (Int32)returnCarID.Value; Vehicle vehicle = DBController.GetByPrimaryKey <Vehicle>(vehicleID); if (vehicle != null) { if (vehicle.IsRented) { Purchase p = PurchaseControl.FindPurchase(vehicleID); if (p != null) { setLabel(LabelType.Purchase); return; } vehicle.IsRented = false; DBController.Save(vehicle, DBObject.SaveTypes.Update); Rental r = DBController.GetAllRecords <Rental>().Where(rent => rent.VehicleID == vehicle.VehicleID && rent.Active == true).FirstOrDefault(); if (r == null) { setLabel(LabelType.Return); } r.Active = false; r.Comment = commentTB.Text; DBController.Save(r, DBObject.SaveTypes.Update); setLabel(LabelType.Success); } else { setLabel(LabelType.NoRent); } } else { setLabel(LabelType.NoData); } }
public bool Process(SimDescription sim) { if (!mNonPersistableData.IsEnabled) { return(false); } if (mProtected > 0) { mProtected--; } else if (mProtected <= 0) { mVirulence = 1f; } if ((RawStrength <= 0) || (SimTypes.IsDead(sim))) { mStageType = VectorControl.StageType.Resisted; return(false); } if ((IsInoculated) || (IsResisted)) { return(false); } bool noticeShown = false; if (mNextCheck > 0) { mNextCheck--; } else { if (InRemission) { mResistance = 0; mNotices &= ~Notices.FirstSign; } mStageType = mNonPersistableData.AdjustStage(this, sim, out mStage, out mNextCheck); mNextCheck = (int)(mNextCheck * (Vector.Settings.mStageRatio / 100f)); string key = mNonPersistableData.GetStory(mStage, IsIdentified); if (!string.IsNullOrEmpty(key)) { if ((SimTypes.IsSelectable(sim)) || (!IsIgnored)) { Common.Notify(sim.CreatedSim, Common.Localize("Story:" + key, sim.IsFemale, new object[] { sim, GetLocalizedName(sim.IsFemale) })); noticeShown = true; } } else if ((!ShowingSigns) && (HadFirstSign)) { if (SimTypes.IsSelectable(sim)) { if (IsIdentified) { Common.Notify(sim.CreatedSim, Common.Localize("Vector:Better", sim.IsFemale, new object[] { sim, GetLocalizedName(sim.IsFemale) })); } else { Common.Notify(sim.CreatedSim, Common.Localize("Vector:BetterUnknown", sim.IsFemale, new object[] { sim })); } } mNotices &= ~Notices.FirstSign; } if (IsResisted) { return(false); } } if (ShowingSigns) { if (!HadFirstSign) { mNotices |= Notices.FirstSign; if (!noticeShown) { if (SimTypes.IsSelectable(sim)) { Common.Notify(sim.CreatedSim, Common.Localize("Vector:FirstSign", sim.IsFemale, new object[] { sim })); } else if (!IsIgnored) { OutbreakControl.ShowNotice(sim, this, Common.kDebugging ? "Showing: " : ""); } } } if (sim.CreatedSim != null) { BuffGermy.BuffInstanceGermy germy = sim.CreatedSim.BuffManager.GetElement(BuffNames.Germy) as BuffGermy.BuffInstanceGermy; if (germy == null) { OccultTypes currentOccultTypes = sim.OccultManager.mCurrentOccultTypes; try { sim.OccultManager.mCurrentOccultTypes = OccultTypes.None; if (sim.CreatedSim.BuffManager.AddElement(BuffNames.Germy, sFromInfectionOrigin)) { germy = sim.CreatedSim.BuffManager.GetElement(BuffNames.Germy) as BuffGermy.BuffInstanceGermy; } } finally { sim.OccultManager.mCurrentOccultTypes = currentOccultTypes; } } if (germy != null) { if (germy.GermyContagionBroadcaster != null) { germy.GermyContagionBroadcaster.Dispose(); germy.GermyContagionBroadcaster = null; } germy.mCurrentTotalDurationIncrease = 0; germy.ModifyDuration(30); } } mNonPersistableData.Symptomize(sim.CreatedSim, this); } if (IsMutating) { Mutate(); } PurchaseControl.AddCheck(sim.Household); return(true); }