hey

i have a problem...
i am working on a car dealership object-oriented program project
and i am working on the (admin part) in which i can add cars, delete cars, and modify cars... so that as soon as i change info on cars, other users can see the changes...
anyways, my code seems to be logically true, and its compiling, but the DELETE car, and modify car buttons DOESN'T work:rolleyes: , but add car works!!!!!!!
i uploaded the zipped file, if anybody wants to help
tha username is admin password: 4444
other username is karim password:3333


and this is the code(if u don`t wanna download the file)

Class --> Car

/****************** ***********/
public class Car
{
#region Attributes
private int _ID;
private int _CustomerID;
private string _Make;
private string _Model;
private string _Type;
private int _Year;
private string _NewOrUsed;
private string _Colour;
private string _Transmission;
private string _PicturePath;
private int _Price;
private int _quantity;
#endregion
#region Properties
public int Quantity
{
get { return _quantity; }
set { _quantity = value; }
}
public int Price
{
get { return _Price; }
set { _Price = value; }
}
public string PicturePath
{
get { return _PicturePath; }
set { _PicturePath = value; }
}
public string Transmission
{
get { return _Transmission; }
set { _Transmission = value; }
}
public string Colour
{
get { return _Colour; }
set { _Colour = value; }
}
public string NewOrUsed
{
get { return _NewOrUsed; }
set { _NewOrUsed = value; }
}
public int Year
{
get { return _Year; }
set { _Year = value; }
}
public string Type
{
get { return _Type; }
set { _Type = value; }
}
public string Model
{
get { return _Model; }
set { _Model = value; }
}
public string Make
{
get { return _Make; }
set { _Make = value; }
}
public int CustomerID
{
get { return _CustomerID; }
set { _CustomerID = value; }
}
public int ID
{
get { return _ID; }
set { _ID = value; }
}
#endregion
#region Constructors
public Car() { }
public Car(
int id,
string make,
string model,
string type,
int year,
string newOrUsed,
string transmission,
string picturePath)
{
ID = id;
Make = make;
Model = model;
Type = type;
Year = year;
NewOrUsed = newOrUsed;
Transmission = transmission;
PicturePath = picturePath;
Quantity = this.CarQuantity(id);
}
#endregion

tblCarTableAdapter _carTA = new tblCarTableAdapter();
CarDS.tblCarDataTable table;
#region Data Access
public Car GetCarByID(int id)
{
table = BLL.CarDA.GetDatabyID(id); //_carTA.GetDataByID(id);
CarDS.tblCarRow row = (CarDS.tblCarRow)table.Rows[0];
Car aCar = new Car(
row.ID,
row.Make,
row.Model,
row.Type,
row.Year,
row._New_Used,
row.Transmission,
row.PicturePath);
return aCar;
}

public int GetDataByIDDesc()
{
table = _carTA.GetDataByIDDESC();
CarDS.tblCarRow row = (CarDS.tblCarRow)table.Rows[0];
return row.ID;
}
public BindingList<Car> GetData()
{
BindingList<Car> cars = new BindingList<Car>();
table = _carTA.GetData();
foreach (CarDS.tblCarRow row in table)
{
cars.Add(new Car(row.ID,
row.Make,
row.Model,
row.Type,
row.Year,
row._New_Used,
row.Transmission,
row.PicturePath));
}
return cars;

}
public void InsertCar(Car c)
{
BLL.CarDA.InsertCar(c.ID, c.Make, c.Model, c.Price, c.Type, c.Year, c.NewOrUsed, c.Transmission);
}
public void UpdateCar(Car c)
{
Car oldCar = c.GetCarByID(c.ID);
CarDA.UpdateCar(c.Make, c.Model, c.Type, c.Price, c.Year, c.NewOrUsed, c.Transmission, c.ID);
}
public void DeleteCar(Car c)
{
_carTA.DeleteCar(c.ID);
}

/****************************************/

and this is the form C# code

/*******************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CarDealership.BLL;
using CarDealership.DAL.CarDSTableAdapters;

namespace CarDealership.GUI
{
public partial class frmCarList : Form
{
bool statusAdd = false;
public frmCarList()
{
InitializeComponent();
}
private void frmCarList_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'carDS.tblCar' table. You can move, or remove it, as needed.
this.tblCarTableAdapter.Fill(this.carDS.tblCar);
Car objCar = new Car();
//tblCarBindingSource.DataSource = objCar.GetData();
}

private void btnAdd_Click(object sender, EventArgs e)
{
if (!statusAdd)
{
tblCarBindingSource.AddNew();
statusAdd = true;
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (statusAdd == true)
{
tblCarBindingSource.RemoveCurrent();
statusAdd = false;
}
else
{
Car c = new Car();
c.ID = Convert.ToInt32(iDTextBox.Text);
c.DeleteCar(c);
tblCarBindingSource.DataSource = c.GetData();
}
}
private void btnUpdate_Click(object sender, EventArgs e)
{

int CarID = Convert.ToInt32(iDTextBox.Text);
string make = makeTextBox.Text;
string model = modelTextBox.Text;
string type = typeTextBox.Text;
int price = Convert.ToInt32(priceTextBox.Text);
string year = yearTextBox.Text;
string newOrUsed = new_UsedTextBox.Text;
string transmission = transmissionTextBox.Text;
if (!statusAdd)
{
Car c = new Car(CarID, make, model, type, price, year, newOrUsed, transmission);
c.UpdateCar(c);
tblCarBindingSource.DataSource = c.GetData();
}
else
{
Car c = new Car(CarID, make, model, type, price, year, newOrUsed, transmission);
c.InsertCar(c);
tblCarBindingSource.DataSource = c.GetData();
statusAdd = false;
}
}

}
}

/**********************************/

i appreciate any help:-| :sad:
plz help

This article has been dead for over six months. Start a new discussion instead.