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!");
     }
 }
Exemplo n.º 2
0
        public static void AddSaleVehicle(SaleVehicle _vehicleModel)
        {
            API.shared.consoleOutput("COUNT : " + currentSaleVehicleList.Items.Count + " | model null : " + (_vehicleModel == null).ToString());

            _vehicleModel.ID = currentSaleVehicleList.Items.Count > 0 ? currentSaleVehicleList.Items.LastOrDefault().ID + 1 : 1;
            currentSaleVehicleList.Items.Add(_vehicleModel);
            SaveChanges();
        }