Пример #1
0
        private void FrmInventoryDetail_Load(object sender, EventArgs e)
        {
            clsInventory vehicle = clsInventory.searchInventory(vehicleLoaded.InventoryID);

            tbMake.Text            = vehicle.Make;
            tbColor.Text           = vehicle.Color;
            tbModel.Text           = vehicle.Model;
            tbMileage.Text         = vehicle.Mileage.ToString();
            tbPrice.Text           = vehicle.StickerPrice.ToString();
            tbPurchaseOrderID.Text = vehicle.PurchaseOrderID;
            tbSalespersonID.Text   = vehicle.SalespersonID;
            tbType.Text            = vehicle.BodyType;
            tbVIN.Text             = vehicle.Vin;
            tbYear.Text            = vehicle.Year.ToString();
            tbCustomerHold.Text    = vehicle.CustomerHold;
            tbDealerCost.Text      = vehicle.CostPaid.ToString();

            if (vehicle.Available == true)
            {
                tbAvailable.Text = "Available";
            }
            else
            {
                tbAvailable.Text = "Not Available";
            }


            tbTimeOnLot.Text = Convert.ToInt32((DateTime.Now - vehicle.ArrivedOnLot).TotalDays).ToString();
        }
Пример #2
0
 // copy constructor
 public clsInventory(clsInventory otherItem, int marker)
 {
     this.InventoryID     = otherItem.InventoryID;
     this.Make            = otherItem.Make;
     this.Model           = otherItem.Model;
     this.Color           = otherItem.Color;
     this.Year            = otherItem.Year;
     this.Mileage         = otherItem.Mileage;
     this.ArrivedOnLot    = otherItem.ArrivedOnLot;
     this.CostPaid        = otherItem.CostPaid;
     this.StickerPrice    = otherItem.StickerPrice;
     this.BodyType        = otherItem.BodyType;
     this.Vin             = otherItem.Vin;
     this.PurchaseOrderID = otherItem.PurchaseOrderID;
     this.SalespersonID   = otherItem.SalespersonID;
     this.CustomerHold    = otherItem.CustomerHold;
     this.Available       = otherItem.Available;
 }
Пример #3
0
        private void FrmSalesOrder_Load(object sender, EventArgs e)
        {
            clsInventory vehicle = clsInventory.searchInventory(vehicleLoaded.InventoryID);

            tbMake.Text             = vehicle.Make;
            tbColor.Text            = vehicle.Color;
            tbModel.Text            = vehicle.Model;
            numMileage.Value        = vehicle.Mileage;
            tbVIN.Text              = vehicle.Vin;
            numYear.Value           = vehicle.Year;
            cboStatus.SelectedIndex = 4;
            //tbSalesperson.Text = [current user].FirstName + " " + [current user].LastName
            tbSalesperson.Text = "John P. Salesman";

            //Will load customer list from DB to combo box and display first name, last name

            btnSave.Enabled = false;
        }
Пример #4
0
        private void BtnHold_Click(object sender, EventArgs e)
        {
            clsInventory vehicle = clsInventory.searchInventory(vehicleLoaded.InventoryID);

            if (btnHold.Text == "Add/Edit Hold")
            {
                tbCustomerHold.Enabled  = true;
                tbCustomerHold.ReadOnly = false;
                btnHold.Text            = "Save Hold";
            }
            else if (btnHold.Text == "Save Hold")
            {
                vehicle.CustomerHold = tbCustomerHold.Text;
                clsInventory.insertInventory(vehicle);
                btnHold.Text            = "Add/Edit Hold";
                tbCustomerHold.Enabled  = false;
                tbCustomerHold.ReadOnly = true;
            }
        }
Пример #5
0
 public static void insertInventory(clsInventory newVehicle)
 {
     deleteInventory(newVehicle.InventoryID);
     GlobalListForTesting.totalInventoryList.Add(newVehicle);
 }
Пример #6
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            if (btnAction.Text == "Delete")
            {
                if (cboInventory.SelectedIndex > -1)
                {
                    if (MessageBox.Show("Are you sure you want to delete vehicle " + cboInventory.SelectedItem.ToString() + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                        MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clsInventory.deleteInventory((cboInventory.SelectedItem as clsInventory).InventoryID);
                    }

                    cboInventory.DataSource = null;
                    cboInventory.DataSource = clsInventory.selectAllInventory();
                }
                else
                {
                    MessageBox.Show("No vehicle selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            else if (btnAction.Text == "Save")
            {
                if (cboInventory.SelectedIndex > -1)
                {
                    clsInventory DBVersion      = clsInventory.searchInventory((cboInventory.SelectedItem as clsInventory).InventoryID);
                    clsInventory LoadedVersion  = new clsInventory(cboInventory.SelectedItem as clsInventory, 1);
                    clsInventory UpdatedVersion = new clsInventory((cboInventory.SelectedItem as clsInventory).InventoryID, tbMake.Text, tbModel.Text, tbColor.Text, Convert.ToInt32(numYear.Value), Convert.ToInt32(numMileage.Value), dtpLotArrival.Value,
                                                                   numDealerCost.Value, numPrice.Value, tbType.Text.ToString(), tbVIN.Text.ToString(), tbPurchaseOrderID.Text.ToString(), LoadedVersion.SalespersonID, LoadedVersion.CustomerHold, LoadedVersion.Available);

                    if (DBVersion == LoadedVersion)
                    {
                        // error message
                        MessageBox.Show("Edits not saved", "Abject Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        clsInventory.insertInventory(UpdatedVersion);
                    }

                    cboInventory.DataSource = null;
                    cboInventory.DataSource = clsInventory.selectAllInventory();
                }
                else
                {
                    MessageBox.Show("No vehicle selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else if (btnAction.Text == "Add")
            {
                clsInventory newItem = new clsInventory(DateTime.Now.ToString(), tbMake.Text, tbModel.Text, tbColor.Text, Convert.ToInt32(numYear.Value), Convert.ToInt32(numMileage.Value), dtpLotArrival.Value,
                                                        numDealerCost.Value, numPrice.Value, tbType.Text.ToString(), tbVIN.Text.ToString(), tbPurchaseOrderID.Text.ToString(), "", "", true);

                clsInventory.insertInventory(newItem);
                MessageBox.Show("Vehicle added", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                cboInventory.DataSource = null;
                cboInventory.DataSource = clsInventory.selectAllInventory();
                clearInputs();
            }
            else if (btnAction.Text == "Detail")
            {
                if (cboInventory.SelectedIndex > -1)
                {
                    frmInventoryDetail frmDetail = new frmInventoryDetail();
                    frmDetail.vehicleLoaded = clsInventory.searchInventory((cboInventory.SelectedItem as clsInventory).InventoryID);
                    showMdiChild(frmDetail, "Vehicle Detail");
                }
                else
                {
                    MessageBox.Show("No vehicle selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }