Exemplo n.º 1
0
 public CarModel()
 {
     InitializeComponent();
     cb_CarBrand.DataSource            = brand.SelectAll();
     cb_CarBrand.DisplayMember         = "BrandName";
     cb_CarBrand.ValueMember           = "ID";
     cb_CarBrand.SelectedIndex         = -1;
     dataGridView1.AutoGenerateColumns = false;
     dataGridView1.DataSource          = model.SelectAll();
 }
Exemplo n.º 2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.RowIndex;
            int id    = int.Parse(dataGridView1.Rows[index].Cells["Column4"].Value.ToString());

            if (e.ColumnIndex == 6)
            {
                List <usp_SelectAllClient_CarsByID_Result> items = clientCar.SelectAll(id);
                txt_car_No.Text = items[0].CarNo.Split('-')[0];
                try
                {
                    textBox2.Text = items[0].CarNo.Split('-')[1];
                }
                catch { }
                txt_Km.Text = items[0].KM;
                cb_CarBrand.SelectedValue = (int)model.SelectAll((int)items[0].CarID)[0].BrandID;
                cb_model.SelectedValue    = (int)items[0].CarID;
                panel2.Tag = items[0].ID;
                cb_colors.SelectedValue = (int)items[0].ColorID;
                //panel2.Tag = items[0]
            }

            else if (e.ColumnIndex == 7)
            {
                clientCar.Delete(id);
                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.DataSource          = clientCar.SelectAllByCar((int)id);
            }
        }