public List <equipement_model> Viewequipe(String cmnd) { List <equipement_model> data = new List <equipement_model>(); SqlCommand req = new SqlCommand(); openconx(); req.Connection = cnn; req.CommandType = CommandType.Text; // Changer le type de la requete en text (non pas procedure) req.CommandText = cmnd; req.Parameters.Clear(); datareader = req.ExecuteReader(); while (datareader.Read()) { equipement_model item = new equipement_model(); item.Matrucil = datareader.GetValue(0).ToString(); item.Nom_equipment = datareader.GetValue(1).ToString(); item.CODE = int.Parse(datareader.GetValue(2).ToString()); data.Add(item); // data.Add(new article_model((int)datareader.GetValue(0), (String)datareader.GetValue(1),(String) datareader.GetValue(2),(String) datareader.GetValue(3), (String)datareader.GetValue(4), (String)datareader.GetValue(5),(float) datareader.GetValue(6), (int)datareader.GetValue(7), (DateTime)datareader.GetValue(8),(byte[]) datareader.GetValue(9))); } return(data); }
public void update(equipement_model item) { SqlCommand macommende = new SqlCommand(); openconx(); macommende.Connection = cnn; macommende.CommandType = CommandType.Text; macommende.CommandText = @"UPDATE equipement SET code = @code, nom = @nom, matircile = @matricile WHERE ref=" + item.Ref; SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@code", SqlDbType.VarChar, 40); param[0].Value = item.CODE; param[1] = new SqlParameter("@nom", SqlDbType.VarChar, 40); param[1].Value = item.Nom_equipment; param[2] = new SqlParameter("@matricile", SqlDbType.VarChar, 40); param[2].Value = item.Matrucil; macommende.Parameters.AddRange(param); macommende.ExecuteNonQuery(); }
private void update_data_DoWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { progresbar.Hide(); equipement_model model = ((equipement_model)e.Result); add_success add_Success = new add_success(model); add_Success.ShowDialog(); }
private void update_data_DoWork_DoWork(object sender, DoWorkEventArgs e) { equipement_model model = ((equipement_model)e.Argument); sqlcn sql = new sqlcn(); MessageBox.Show(model.Ref + "" + model.CODE + "" + model.Nom_equipment + "" + model.Matrucil); sql.update(model); e.Result = model; }
private void working_back_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { progresbar.Hide(); List <object> parameters = e.Result as List <object>; int i = int.Parse(parameters[0].ToString()); equipement_model item = (equipement_model)parameters[1]; if (i == -1) { MessageBox.Show("errure d'ajouter"); } else { add_success add_Success = new add_success(item); add_Success.ShowDialog(); } }
private void view_data_SelectionChanged(object sender, EventArgs e) { if (view_data.SelectedRows.Count > 0) { selectedRows.Clear(); for (int i = 0; i < view_data.SelectedRows.Count; i++) { DataGridViewCellCollection a = view_data.SelectedRows[i].Cells; string value = a[2].Value.ToString(); equipement_model model = new equipement_model(); selectedRows.Add(model); } } else { selectedRows.Clear(); } }
private void view_data_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewCellCollection a = view_data.Rows[e.RowIndex].Cells; string value = a[2].Value.ToString(); progresbar.Show(); equipement_model model = new equipement_model(); model.Ref = int.Parse(a[0].Value.ToString()); model.CODE = int.Parse(a[1].Value.ToString()); model.Nom_equipment = a[2].Value.ToString(); model.Matrucil = a[3].Value.ToString(); if (!update_data_DoWork.IsBusy) { update_data_DoWork.RunWorkerAsync(model); } }
public add_success(equipement_model equipement) { prgf = @"code :" + equipement.CODE + "matricul :" + equipement.Matrucil + "nom :" + equipement.Nom_equipment; InitializeComponent(); }