private void btnAddJob_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtJobTitle.Text) && !string.IsNullOrEmpty(cmbContractors.Text) && !string.IsNullOrEmpty(cmbConStatus.Text))
     {
         ve = new VehicleManagementEntities();
         if (ve.Jobs.Any(r => r.JobTitle == txtJobTitle.Text))
         {
             MessageBox.Show("This job is already exists!");
         }
         else
         {
             cmbBoxValues selCon             = cmbContractors.SelectedItem as cmbBoxValues;
             int          selectedContractor = selCon.cmbVal;
             Job          job = new Job()
             {
                 JobTitle    = txtJobTitle.Text,
                 VehicleId   = vehicleId,
                 Contractor  = long.Parse(selectedContractor.ToString()),
                 Amount      = float.Parse(txtJobAmount.Value.ToString()),
                 Status      = cmbConStatus.Text,
                 CreatedDate = DateTime.Now
             };
             ve.Jobs.Add(job);
             ve.SaveChanges();
             MessageBox.Show("Contractor successfully added!");
             fetchJobs();
             clearJobFields();
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtBrand.Text))
     {
         ve = new VehicleManagementEntities();
         if (ve.Brands.Any(o => o.Brand1 == txtBrand.Text) == false)
         {
             Brand brand = new Brand()
             {
                 Brand1 = txtBrand.Text
             };
             ve.Brands.Add(brand);
             ve.SaveChanges();
             MessageBox.Show("Brand added successfully!");
             clearValues();
             fetchData();
         }
         else
         {
             MessageBox.Show("this brand already exists in the system");
         }
     }
     else
     {
         MessageBox.Show("Ypu cannot submit empty values");
     }
 }
 private void btnAddSale_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtBuyerName.Text) && !string.IsNullOrEmpty(txtBuyerNIC.Text) && !string.IsNullOrEmpty(txtBuyerPhone.Text) &&
         !string.IsNullOrEmpty(txtBuyerAddress.Text))
     {
         if (numSaleAmount.Value != 0)
         {
             ve = new VehicleManagementEntities();
             SaleVehicle sale = new SaleVehicle()
             {
                 VehicleId  = vehicleId,
                 BuyerName  = txtBuyerName.Text,
                 NIC        = txtBuyerNIC.Text,
                 Address    = txtBuyerAddress.Text,
                 Phone      = txtBuyerPhone.Text,
                 SaleAmount = float.Parse(numSaleAmount.Value.ToString()),
                 Status     = "0",
                 DateSold   = DateTime.Now
             };
             ve.SaleVehicles.Add(sale);
             ve.SaveChanges();
             MessageBox.Show("Contractor successfully added!");
             fetchSale();
             clearSaleFields();
         }
         else
         {
             MessageBox.Show("You must enter sale amount!");
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
 private void btnAddExpense_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtExpTitle.Text) && !string.IsNullOrEmpty(cmbExpType.Text))
     {
         ve = new VehicleManagementEntities();
         if (ve.Expenses.Any(r => r.ExpenseTitle == txtExpTitle.Text))
         {
             MessageBox.Show("This expense is already exists!");
         }
         else
         {
             Expens expenses = new Expens()
             {
                 ExpenseTitle = txtExpTitle.Text,
                 VehicleId    = vehicleId,
                 ExpenseType  = cmbExpType.Text,
                 Amount       = long.Parse(numExpAmount.Value.ToString()),
                 DateCreated  = DateTime.Now
             };
             ve.Expenses.Add(expenses);
             ve.SaveChanges();
             MessageBox.Show("Expense successfully added!");
             fetchExpenses();
             clearExpenseFields();
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
Ejemplo n.º 5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtItem.Text != null)
     {
         ve = new VehicleManagementEntities();
         if (ve.InventoryItems.Any(o => o.ItemName == txtItem.Text))
         {
             MessageBox.Show("Item already exists");
         }
         else
         {
             InventoryItem inventoryItem = new InventoryItem()
             {
                 ItemName = txtItem.Text
             };
             ve.InventoryItems.Add(inventoryItem);
             ve.SaveChanges();
             MessageBox.Show("Successfully saved");
             clearValues();
             displayData();
         }
     }
     else
     {
         MessageBox.Show("Cannot submit empty fields");
     }
 }
 private void btnAddIncome_Click(object sender, EventArgs e)
 {
     if (numInstAmount.Value != 0 && !string.IsNullOrEmpty(txtInvoiceNumber.Text))
     {
         if (totalDueAmount < numInstAmount.Value)
         {
             MessageBox.Show("Installment amount should be less than total vehicle value.");
         }
         else
         {
             ve = new VehicleManagementEntities();
             Payment payment = new Payment()
             {
                 VehicleId     = vehicleId,
                 SaleId        = selectedSaleId,
                 Installment   = (installmentCount + 1).ToString(),
                 InvoiceNumber = txtInvoiceNumber.Text,
                 Amount        = (double)numInstAmount.Value,
                 DatePayed     = DateTime.Now
             };
             ve.Payments.Add(payment);
             ve.SaveChanges();
             MessageBox.Show("Payment saved succesfully!");
             clearPaymentFields();
             fetchPayments();
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
        private void btnUpdateIncome_Click(object sender, EventArgs e)
        {
            if (numInstAmount.Value != 0 && !string.IsNullOrEmpty(txtInvoiceNumber.Text))
            {
                if (totalDueAmount < numInstAmount.Value)
                {
                    MessageBox.Show("Installment amount should be less than total vehicle value.");
                }
                else
                {
                    ve = new VehicleManagementEntities();

                    var singlePayment = ve.Payments.Where(r => r.PaymentId == selectedPayment).First();
                    singlePayment.InvoiceNumber = txtInvoiceNumber.Text;
                    singlePayment.Amount        = float.Parse(numInstAmount.Value.ToString());
                    ve.SaveChanges();
                    MessageBox.Show("Payment successfully updated!");
                    fetchPayments();
                    clearPaymentFields();
                    selectedPayment = 0;
                }
            }
            else
            {
                MessageBox.Show("You must fill all fields!");
            }
        }
Ejemplo n.º 8
0
 private void BtnSave(object sender, EventArgs e)
 {
     if (txtUsername.Text != null && txtPassword.Text != null)
     {
         ve = new VehicleManagementEntities();
         if (ve.Users.Any(o => o.Username == txtUsername.Text))
         {
             MessageBox.Show("User already exists");
         }
         else
         {
             User users = new User()
             {
                 Username = txtUsername.Text,
                 Password = BCrypt.Net.BCrypt.HashString(txtPassword.Text),
             };
             ve.Users.Add(users);
             ve.SaveChanges();
             txtUsername.Text = "";
             txtPassword.Text = "";
             MessageBox.Show("Successfully added!");
             displayData();
             txtUsername.Text = "";
             txtPassword.Text = "";
         }
     }
     else
     {
         MessageBox.Show("All fields are required!");
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtCategory.Text != null)
     {
         ve = new VehicleManagementEntities();
         if (ve.Categories.Any(o => o.Category1 == txtCategory.Text))
         {
             MessageBox.Show("Category already exists");
         }
         else
         {
             Category category = new Category()
             {
                 Category1 = txtCategory.Text,
             };
             ve.Categories.Add(category);
             ve.SaveChanges();
             txtCategory.Text = "";
             MessageBox.Show("Successfully added!");
             displayData();
             txtCategory.Text = "";
         }
     }
     else
     {
         MessageBox.Show("All fields are required!");
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (selectedId == 0)
     {
         if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtAddress.Text) &&
             !string.IsNullOrEmpty(txtPhone.Text) && !string.IsNullOrEmpty(cmbType.Text))
         {
             ve = new VehicleManagementEntities();
             if (ve.VehicleSellers.Any(r => r.SellerName == txtName.Text && r.VehicleNumber == regNum) == false)
             {
                 VehicleSeller vehicleSeller = new VehicleSeller()
                 {
                     SellerName          = txtName.Text,
                     SellerAddress       = txtAddress.Text,
                     SellerContactNumber = txtPhone.Text,
                     SellerType          = cmbType.Text,
                     VehicleNumber       = regNum
                 };
                 ve.VehicleSellers.Add(vehicleSeller);
                 ve.SaveChanges();
                 MessageBox.Show("Seller data saved successfully!");
                 clearValues();
                 frmSingleVehicle singleVehicle = new frmSingleVehicle();
                 singleVehicle.fetchSellerData();
                 btnSave.Text    = "Update";
                 btnSave.Enabled = false;
             }
             else
             {
                 MessageBox.Show("This seller already exists");
             }
         }
         else
         {
             MessageBox.Show("All fields are required");
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtAddress.Text) &&
             !string.IsNullOrEmpty(txtPhone.Text) && !string.IsNullOrEmpty(cmbType.Text))
         {
             ve = new VehicleManagementEntities();
             var singleSeller = ve.VehicleSellers.Where(r => r.VehicleSellerId == selectedId).First();
             singleSeller.SellerName          = txtName.Text;
             singleSeller.SellerAddress       = txtAddress.Text;
             singleSeller.SellerContactNumber = txtPhone.Text;
             singleSeller.SellerType          = cmbType.Text;
             ve.SaveChanges();
             MessageBox.Show("Successfully updated!");
             btnSave.Text    = "Update";
             btnSave.Enabled = false;
         }
     }
 }
Ejemplo n.º 11
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Are you sure you want to Delete?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                ve = new VehicleManagementEntities();
                var singleContractor = ve.Contractors.Where(r => r.ContractorId == id).First();
                ve.Contractors.Remove(singleContractor);
                ve.SaveChanges();
                MessageBox.Show("Contractor successfully deleted!");
                displayData();
            }
        }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtVehicleType.Text))
     {
         ve = new VehicleManagementEntities();
         var singleVehiType = ve.VehicleTypes.Where(r => r.VehicleTypeId == Id).First();
         singleVehiType.VehiType = txtVehicleType.Text;
         ve.SaveChanges();
         displayData();
         MessageBox.Show("Successfully updated!");
         Id = 0;
         txtVehicleType.Text = "";
     }
 }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtBrand.Text))
     {
         ve = new VehicleManagementEntities();
         var singleBrand = ve.Brands.Where(r => r.BrandId == Id).First();
         singleBrand.Brand1 = txtBrand.Text;
         ve.SaveChanges();
         MessageBox.Show("Brand updated successfully!");
         clearValues();
         fetchData();
         Id = 0;
     }
 }
        private void btnDeleteJob_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Are you sure you want to Delete this Job?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                ve = new VehicleManagementEntities();
                var singleJob = ve.Jobs.Where(r => r.JobId == selectedJobID).First();
                ve.Jobs.Remove(singleJob);
                ve.SaveChanges();
                MessageBox.Show("Job successfully deleted!");
                fetchJobs();
                clearJobFields();
            }
        }
        private void btnDeleteExpense_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Are you sure you want to Delete this Expense?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                ve = new VehicleManagementEntities();
                var singleExp = ve.Expenses.Where(r => r.ExpenseId == selectedExpenseId).First();
                ve.Expenses.Remove(singleExp);
                ve.SaveChanges();
                MessageBox.Show("Expense successfully deleted!");
                fetchExpenses();
                clearExpenseFields();
            }
        }
        private void btnDeleteIncome_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Are you sure you want to Delete this Payment? You cannot reverse this action.", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.OK)
            {
                ve = new VehicleManagementEntities();
                var singlePayment = ve.Payments.Where(r => r.PaymentId == selectedPayment).First();
                ve.Payments.Remove(singlePayment);
                ve.SaveChanges();
                MessageBox.Show("Payment successfully deleted!");
                fetchPayments();
                clearPaymentFields();
                selectedPayment = 0;
            }
        }
Ejemplo n.º 17
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtNic.Text) && !string.IsNullOrEmpty(txtPhone.Text) && !string.IsNullOrEmpty(cmbType.Text))
     {
         bool isPhone = validatePhone();
         bool isNic   = validateNic();
         if (isPhone == false)
         {
             MessageBox.Show("A Phone number should have 10 digits.");
         }
         else
         {
             if (isNic == false)
             {
                 MessageBox.Show("A NIC should have 10 or 12 digits.");
             }
             else
             {
                 ve = new VehicleManagementEntities();
                 if (ve.Contractors.Any(c => c.ContractorNic == txtNic.Text))
                 {
                     MessageBox.Show("This contractor is already exists!");
                 }
                 else
                 {
                     Contractor contractor = new Contractor()
                     {
                         ContractorName  = txtName.Text,
                         ContractorNic   = txtNic.Text,
                         ContractorPhone = txtPhone.Text,
                         ContractorType  = cmbType.Text
                     };
                     ve.Contractors.Add(contractor);
                     ve.SaveChanges();
                     MessageBox.Show("Contractor successfully added!");
                     displayData();
                     clearFields();
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
Ejemplo n.º 18
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtItem.Text))
     {
         ve = new VehicleManagementEntities();
         var singleItem = ve.InventoryItems.Where(r => r.InventoryItemId == Id).First();
         singleItem.ItemName = txtItem.Text;
         ve.SaveChanges();
         clearValues();
         displayData();
         MessageBox.Show("Succesfully updated!");
     }
     else
     {
         MessageBox.Show("Cannot submit empty fields");
     }
 }
Ejemplo n.º 19
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtUsername.Text) && !string.IsNullOrEmpty(txtPassword.Text))
     {
         ve = new VehicleManagementEntities();
         var singleUser = ve.Users.Where(r => r.UserId == Id).First();
         singleUser.Username = txtUsername.Text;
         singleUser.Password = BCrypt.Net.BCrypt.HashString(txtPassword.Text);
         ve.SaveChanges();
         MessageBox.Show("Successfully updated!");
         Id = 0;
         displayData();
         txtPassword.Text = "";
         txtUsername.Text = "";
     }
     else
     {
         MessageBox.Show("Cannot update empty fields!");
     }
 }
        private void btnUpdateExpense_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtExpTitle.Text) && !string.IsNullOrEmpty(cmbExpType.Text))
            {
                ve = new VehicleManagementEntities();

                var singleExp = ve.Expenses.Where(r => r.ExpenseId == selectedExpenseId).First();
                singleExp.ExpenseTitle = txtExpTitle.Text;
                singleExp.ExpenseType  = cmbExpType.Text;
                singleExp.Amount       = float.Parse(numExpAmount.Value.ToString());
                ve.SaveChanges();
                MessageBox.Show("Expense successfully updated!");
                fetchExpenses();
                clearExpenseFields();
                selectedExpenseId = 0;
            }
            else
            {
                MessageBox.Show("You must fill all fields!");
            }
        }
Ejemplo n.º 21
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtNic.Text) && !string.IsNullOrEmpty(txtPhone.Text) && !string.IsNullOrEmpty(cmbEmpType.Text) && !string.IsNullOrEmpty(cmbSalType.Text) && !string.IsNullOrEmpty(txtSalary.Text))
     {
         ve = new VehicleManagementEntities();
         var singleEmployee = ve.Employees.Where(r => r.EmployeeId == Id).First();
         singleEmployee.EmployeeName = txtName.Text;
         singleEmployee.Nic          = txtNic.Text;
         singleEmployee.Phone        = txtPhone.Text;
         singleEmployee.EmpType      = cmbEmpType.Text;
         singleEmployee.SalaryType   = cmbSalType.Text;
         singleEmployee.Salary       = Int32.Parse(txtSalary.Text);
         ve.SaveChanges();
         MessageBox.Show("Successfully updated!");
         displayData();
         clearFields();
     }
     else
     {
         MessageBox.Show("Cannnot submit empty fields.");
     }
 }
Ejemplo n.º 22
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtName.Text != null && txtNic.Text != null && txtPhone.Text != null && cmbEmpType.SelectedItem != null && cmbSalType.SelectedItem != null)
     {
         ve = new VehicleManagementEntities();
         if (ve.Employees.Any(o => o.Nic == txtNic.Text))
         {
             MessageBox.Show("Employee already exists");
         }
         else
         {
             Employee employee = new Employee()
             {
                 EmployeeName = txtName.Text,
                 Nic          = txtNic.Text,
                 Phone        = txtPhone.Text,
                 EmpType      = cmbEmpType.Text,
                 SalaryType   = cmbSalType.Text,
                 Salary       = Int32.Parse(txtSalary.Text)
             };
             ve.Employees.Add(employee);
             ve.SaveChanges();
             txtName.Text    = "";
             txtNic.Text     = "";
             txtPhone.Text   = "";
             txtSalary.Text  = "";
             cmbEmpType.Text = "";
             cmbSalType.Text = "";
             displayData();
             MessageBox.Show("Saved successfully");
         }
     }
     else
     {
         MessageBox.Show("All fields are required");
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtVehicleType.Text != null)
     {
         ve = new VehicleManagementEntities();
         if (ve.VehicleTypes.Any(o => o.VehiType == txtVehicleType.Text))
         {
             MessageBox.Show("Vehicle Type already exists");
         }
         else
         {
             VehicleType vehicleType = new VehicleType()
             {
                 VehiType = txtVehicleType.Text
             };
             ve.VehicleTypes.Add(vehicleType);
             ve.SaveChanges();
             txtVehicleType.Text = "";
             MessageBox.Show("Successfully saved!");
             displayData();
             txtVehicleType.Text = "";
         }
     }
 }
        private void btnUpdateSale_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtBuyerName.Text) && !string.IsNullOrEmpty(txtBuyerNIC.Text) && !string.IsNullOrEmpty(txtBuyerPhone.Text) &&
                !string.IsNullOrEmpty(txtBuyerAddress.Text))
            {
                ve = new VehicleManagementEntities();

                var singleSale = ve.SaleVehicles.Where(r => r.SaleId == selectedSaleId).First();
                singleSale.BuyerName  = txtBuyerName.Text;
                singleSale.NIC        = txtBuyerNIC.Text;
                singleSale.Phone      = txtBuyerPhone.Text;
                singleSale.Address    = txtBuyerAddress.Text;
                singleSale.SaleAmount = float.Parse(numSaleAmount.Value.ToString());
                ve.SaveChanges();
                MessageBox.Show("Sale successfully updated!");
                fetchSale();
                clearSaleFields();
                selectedSaleId = 0;
            }
            else
            {
                MessageBox.Show("You must fill all fields!");
            }
        }
Ejemplo n.º 25
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtNic.Text) && !string.IsNullOrEmpty(txtPhone.Text) && !string.IsNullOrEmpty(cmbType.Text))
     {
         bool isPhone = validatePhone();
         bool isNic   = validateNic();
         if (isPhone == false)
         {
             MessageBox.Show("A Phone number should have 10 digits.");
         }
         else
         {
             if (isNic == false)
             {
                 MessageBox.Show("A NIC should have 10 or 12 digits.");
             }
             else
             {
                 ve = new VehicleManagementEntities();
                 var singleContractor = ve.Contractors.Where(r => r.ContractorId == id).First();
                 singleContractor.ContractorName  = txtName.Text;
                 singleContractor.ContractorNic   = txtNic.Text;
                 singleContractor.ContractorPhone = txtPhone.Text;
                 singleContractor.ContractorType  = cmbType.Text;
                 ve.SaveChanges();
                 MessageBox.Show("Contractor successfully updated!");
                 displayData();
                 clearFields();
             }
         }
     }
     else
     {
         MessageBox.Show("You must fill all fields!");
     }
 }
        private void btnUpdateJob_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtJobTitle.Text) && !string.IsNullOrEmpty(cmbContractors.Text) && !string.IsNullOrEmpty(cmbConStatus.Text))
            {
                ve = new VehicleManagementEntities();
                cmbBoxValues selCon             = cmbContractors.SelectedItem as cmbBoxValues;
                int          selectedContractor = selCon.cmbVal;

                var singleJob = ve.Jobs.Where(r => r.JobId == selectedJobID).First();
                singleJob.JobTitle   = txtJobTitle.Text;
                singleJob.Contractor = long.Parse(selectedContractor.ToString());
                singleJob.Amount     = float.Parse(txtJobAmount.Value.ToString());
                singleJob.Status     = cmbConStatus.Text;
                ve.SaveChanges();
                MessageBox.Show("Job successfully updated!");
                fetchJobs();
                clearJobFields();
                selectedJobID = 0;
            }
            else
            {
                MessageBox.Show("You must fill all fields!");
            }
        }
Ejemplo n.º 27
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     //MessageBox.Show(cmbType.SelectedValue.ToString());
     if (!string.IsNullOrEmpty(txtModel.Text) && !string.IsNullOrEmpty(txtModelYear.Text) &&
         !string.IsNullOrEmpty(cmbType.Text) && !string.IsNullOrEmpty(cmbVehicleCategory.Text) &&
         !string.IsNullOrEmpty(txtRegNum.Text) && !string.IsNullOrEmpty(txtRegYear.Text) &&
         !string.IsNullOrEmpty(txtEngineNumber.Text) && !string.IsNullOrEmpty(txtEngineCapacity.Text) &&
         !string.IsNullOrEmpty(txtMilage.Text) && !string.IsNullOrEmpty(cmbFuelType.Text) &&
         !string.IsNullOrEmpty(cmbBrand.Text) && !string.IsNullOrEmpty(cmbCondition.Text) &&
         !string.IsNullOrEmpty(cmbTransmission.Text))
     {
         System.Text.StringBuilder sb = new System.Text.StringBuilder();
         if (lbSelectedItems.Items.Count != 0)
         {
             foreach (object item in lbSelectedItems.Items)
             {
                 sb.Append(item.ToString());
                 sb.Append(",");
             }
             ve = new VehicleManagementEntities();
             if (ve.Vehicles.Any(o => o.RegNum == txtRegNum.Text) == true)
             {
                 MessageBox.Show("This vehicle already exists on the system!");
             }
             else
             {
                 Vehicle vehicle = new Vehicle()
                 {
                     Brand          = cmbBrand.Text,
                     Model          = txtModel.Text,
                     ModelYear      = Int32.Parse(txtModelYear.Text),
                     TypeId         = long.Parse(cmbType.SelectedValue.ToString()),
                     CategoryId     = long.Parse(cmbVehicleCategory.SelectedValue.ToString()),
                     RegNum         = txtRegNum.Text,
                     RegYear        = Int32.Parse(txtRegYear.Text),
                     EngineNumber   = txtEngineNumber.Text,
                     ChassieNumber  = txtChassieNumber.Text,
                     Milage         = Int32.Parse(txtMilage.Text),
                     Condition      = cmbCondition.Text,
                     Transmission   = cmbTransmission.Text,
                     EngineCapacity = float.Parse(txtEngineCapacity.Text),
                     FuelType       = cmbFuelType.Text,
                     PartInventory  = sb.ToString(),
                     Note           = txtNote.Text,
                     DateCreated    = DateTime.Now
                 };
                 ve.Vehicles.Add(vehicle);
                 ve.SaveChanges();
                 MessageBox.Show("Vehicle added successfully!");
                 clearValues();
             }
         }
         else
         {
             MessageBox.Show("Please add available parts of the vehicle!");
         }
     }
     else
     {
         MessageBox.Show("Cannot add empty values");
     }
 }