private void saveAndClose() { Boolean isAnyEmpty = false; ArrayList arrParam = new ArrayList(); errorMessage(""); isAnyEmpty = _Inputs.Any(x => x.Text.Equals("")); if (isAnyEmpty) { errorMessage("Veuillez remplir tout les élements du formulaire"); return; } if (_Title.Equals("agenda")) { TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDATE")); if (!isDateValid(textBox.Text)) { errorMessage("Date non conforme(ex:01.01.2019)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXHEURE")); if (!isHourValid(textBox.Text)) { errorMessage("Heure non conforme (ex:08:15)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOMCLIENT")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arrParam.Add(textBox.Text); //insert agenda with query DataSetISpaDataTableAdapters.VW_AGENDATableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_AGENDATableAdapter(); int resp = tableAdapter.InsertQuery(Convert.ToDateTime(arrParam[0]), Convert.ToDateTime(arrParam[1]), arrParam[2].ToString(), arrParam[3].ToString()); Console.WriteLine(resp); //tableAdapter.InsertQuery(Convert.ToDateTime(arrParam[0]), Convert.ToDateTime(arrParam[1]), arrParam[2].ToString(), arrParam[3].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("clients")) { //first_name,last_name,d.o.b,email,adresse TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRENOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDOB")); if (!isDateValid(textBox.Text)) { errorMessage("Date de naissance non conforme (ex:01.01.2019"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXEMAIL")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXADRESSE")); arrParam.Add(textBox.Text); //insert client with query DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter(); tableAdapter.InsertQuery(arrParam[0].ToString(), arrParam[1].ToString(), Convert.ToDateTime(arrParam[2]), arrParam[3].ToString(), arrParam[4].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("factures")) { //Date d'ouverture,ID Client,Nom Client,Type,Prix,Payé TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDATE")); if (!isDateValid(textBox.Text)) { errorMessage("Date de naissance non conforme (ex:01.01.2019)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXHEURE")); if (!isHourValid(textBox.Text)) { errorMessage("Heure non conforme (ex:08:15)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOMCLIENT")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRIX")); String val = textBox.Text; val.Replace(',', '.'); double outDouble; if (!double.TryParse(textBox.Text, out outDouble)) { errorMessage("Prix non conforme (ex: 5.50)"); return; } val.Replace('.', ','); arrParam.Add(val); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPAYE")); if (!(textBox.Text.ToLower() == "true" || textBox.Text.ToLower() == "false")) { errorMessage("Boolean de paiement non conforme (ex:true ou false"); return; } arrParam.Add(textBox.Text == "true" ? 1 : 0); DateTime date1 = Convert.ToDateTime(arrParam[0]); DateTime time1 = Convert.ToDateTime(arrParam[1]); //insert factures with query DataSetISpaDataTableAdapters.VW_FACTURETableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_FACTURETableAdapter(); tableAdapter.InsertQuery(date1, time1, arrParam[2].ToString(), arrParam[3].ToString(), arrParam[4].ToString(), Convert.ToDecimal(arrParam[5])); _MotherForm.addRow(arrParam); } if (_Title.Equals("products")) { //nom,description,fournisseur,prix TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDESCRIPTION")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXFOURNISSEUR")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRIX")); String val = textBox.Text; val.Replace(',', '.'); double outDouble; if (!double.TryParse(textBox.Text, out outDouble)) { errorMessage("Prix non conforme (ex: 5.50)"); return; } val.Replace('.', ','); arrParam.Add(val); //insert product with query DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter(); tableAdapter.InsertQuery(arrParam[0].ToString(), arrParam[1].ToString(), arrParam[2].ToString(), arrParam[3].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("users")) { DataSetISpaData datas = new DataSetISpaData(); ArrayList arr = new ArrayList(); // set attributes from form TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPASSWORD")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXACTIF")); if (!(textBox.Text.ToLower() == "true" || textBox.Text.ToLower() == "false")) { errorMessage("Boolean Actif non conforme (ex:true ou false)"); return; } arr.Add(textBox.Text == "true" ? 1 : 0); //insert user with query DataSetISpaDataTableAdapters.VW_USERTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_USERTableAdapter(); tableAdapter.InsertQuery(arr[0].ToString(), arr[1].ToString(), arr[2].ToString(), Convert.ToDecimal(arr[3])); //refresh current table _MotherForm.addRow(arrParam); } if (_Title.Equals("changer de mot de passe")) { String username; lblError.Text = ""; TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxAncien mot de passe")); String oldPass = textBox.Text.Trim(); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxNouveau mot de passe")); String newPass = textBox.Text.Trim(); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxRépéter nouveau mot de passe")); String secondNewPass = textBox.Text.Trim(); DataSetISpaDataTableAdapters.VW_USERTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_USERTableAdapter(); DataSetISpaData.VW_USERDataTable dataTable; textBox = _Inputs.Find(x => x.Name.Contains("txtBoxNom utilisateur")); if (textBox is null) { username = _ArrayParam[0].ToString(); dataTable = tableAdapter.GetDataByUser(username); } else { username = textBox.Text.Trim(); dataTable = tableAdapter.GetDataByUser(username); } if (dataTable.Rows.Count == 0) { errorMessage("Votre compte à été supprimé de la base, veuillez contacter l'admin"); return; } DataRow row = dataTable.Rows[0]; if (row != null) { if (row["XNOM"].ToString().Trim().Equals(username.Trim()) && row["XPASSWORD"].ToString().Trim().Equals(oldPass.Trim())) { if (row["XACTIF"].ToString().Trim() == "0") { errorMessage("Votre compte à été désactivé, veuillez contacter l'admin"); return; } Console.WriteLine("cred ok " + username + " " + oldPass); if (!newPass.Equals(secondNewPass)) { errorMessage("Vous n'avez pas écrit le même nouveau mot de passe"); return; } tableAdapter.UpdateQuery(username, newPass, row["XTYPE"].ToString().Trim(), Convert.ToDecimal(row["XACTIF"]), username); this.Close(); return; } errorMessage("Erreur de votre ancien mot de passe, veuillez réessayer"); return; } errorMessage("Votre compte à été supprimé de la base, veuillez contacter l'admin"); return; } this.Close(); }
private void loadDataInGrid(String xFileName) { _CurrentTitle = xFileName; lblWelcome.Text = xFileName; this.canEdit = false; this.changeEditButton(); // read datas and put them in datagridview1 string pathName = dir + "/datas/" + xFileName + ".csv"; System.IO.StreamReader sr = new System.IO.StreamReader(pathName, Encoding.Default, true); //bdd access DataSetISpaData dataISpa = new DataSetISpaData(); Console.WriteLine("file name" + xFileName); switch (xFileName) { case "agenda": DataSetISpaDataTableAdapters.VW_AGENDATableAdapter liste1 = new DataSetISpaDataTableAdapters.VW_AGENDATableAdapter(); liste1.Fill(dataISpa.VW_AGENDA); _CurrentDataTable = dataISpa.VW_AGENDA; this.dgv.DataSource = dataISpa.VW_AGENDA.DefaultView; break; case "clients": DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter liste2 = new DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter(); liste2.Fill(dataISpa.VW_CLIENT); _CurrentDataTable = dataISpa.VW_CLIENT; this.dgv.DataSource = dataISpa.VW_CLIENT.DefaultView; break; case "products": DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter liste3 = new DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter(); liste3.Fill(dataISpa.VW_PRODUIT); _CurrentDataTable = dataISpa.VW_PRODUIT; this.dgv.DataSource = dataISpa.VW_PRODUIT.DefaultView; break; case "factures": DataSetISpaDataTableAdapters.VW_FACTURETableAdapter liste4 = new DataSetISpaDataTableAdapters.VW_FACTURETableAdapter(); liste4.Fill(dataISpa.VW_FACTURE); _CurrentDataTable = dataISpa.VW_FACTURE; this.dgv.DataSource = dataISpa.VW_FACTURE.DefaultView; break; case "users": DataSetISpaDataTableAdapters.VW_USERTableAdapter liste5 = new DataSetISpaDataTableAdapters.VW_USERTableAdapter(); liste5.Fill(dataISpa.VW_USER); _CurrentDataTable = dataISpa.VW_USER; this.dgv.DataSource = dataISpa.VW_USER.DefaultView; break; default: DataSetISpaDataTableAdapters.VW_AGENDATableAdapter liste6 = new DataSetISpaDataTableAdapters.VW_AGENDATableAdapter(); liste6.Fill(dataISpa.VW_AGENDA); _CurrentDataTable = dataISpa.VW_AGENDA; this.dgv.DataSource = dataISpa.VW_AGENDA.DefaultView; Console.WriteLine("Default case"); break; } ; Console.WriteLine("START"); String[] arrHeader = new String[10]; int i = 0; foreach (DataColumn col in _CurrentDataTable.Columns) { arrHeader[i] = col.ColumnName; if (col.ColumnName == "XHEURE") { this.dgv.Columns[i].DefaultCellStyle.Format = "HH:mm"; } if (col.ColumnName == "XDATE" || col.ColumnName == "XDOB") { this.dgv.Columns[i].DefaultCellStyle.Format = "dd.MM.yyyy"; } i++; } Console.WriteLine("salut" + arrHeader[0] + arrHeader[1] + arrHeader[2] + arrHeader[3] + arrHeader[4] + arrHeader[5]); _CurrentHeaders = arrHeader; this.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; this.dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; this.dgv.Sort(this.dgv.Columns[0], ListSortDirection.Ascending); this.dgv.ReadOnly = true; }
private void saveAndClose() { Boolean isAnyEmpty = false; ArrayList arrParam = new ArrayList(); errorMessage(""); isAnyEmpty = _Inputs.Any(x => x.Text.Equals("")); if (isAnyEmpty) { errorMessage("Veuillez remplir tout les élements du formulaire"); return; } if (_Title.Equals("agenda")) { TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDATE")); if (!isDateValid(textBox.Text)) { errorMessage("Date non conforme(ex:01.01.2019)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXHEURE")); if (!isHourValid(textBox.Text)) { errorMessage("Heure non conforme (ex:08:15)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOMCLIENT")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arrParam.Add(textBox.Text); //insert agenda with query DataSetISpaDataTableAdapters.VW_AGENDATableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_AGENDATableAdapter(); int resp = tableAdapter.InsertQuery(Convert.ToDateTime(arrParam[0]), Convert.ToDateTime(arrParam[1]), arrParam[2].ToString(), arrParam[3].ToString()); Console.WriteLine(resp); //tableAdapter.InsertQuery(Convert.ToDateTime(arrParam[0]), Convert.ToDateTime(arrParam[1]), arrParam[2].ToString(), arrParam[3].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("clients")) { //first_name,last_name,d.o.b,email,adresse TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRENOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDOB")); if (!isDateValid(textBox.Text)) { errorMessage("Date de naissance non conforme (ex:01.01.2019"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXEMAIL")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXADRESSE")); arrParam.Add(textBox.Text); //insert client with query DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter(); tableAdapter.InsertQuery(arrParam[0].ToString(), arrParam[1].ToString(), Convert.ToDateTime(arrParam[2]), arrParam[3].ToString(), arrParam[4].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("factures")) { //Date d'ouverture,ID Client,Nom Client,Type,Prix,Payé TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDATE")); if (!isDateValid(textBox.Text)) { errorMessage("Date de naissance non conforme (ex:01.01.2019)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXHEURE")); if (!isHourValid(textBox.Text)) { errorMessage("Heure non conforme (ex:08:15)"); return; } arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOMCLIENT")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRIX")); String val = textBox.Text; val.Replace(',', '.'); double outDouble; if (!double.TryParse(textBox.Text, out outDouble)) { errorMessage("Prix non conforme (ex: 5.50)"); return; } val.Replace('.', ','); arrParam.Add(val); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPAYE")); if (!(textBox.Text.ToLower() == "true" || textBox.Text.ToLower() == "false")) { errorMessage("Boolean de paiement non conforme (ex:true ou false"); return; } arrParam.Add(textBox.Text == "true" ? 1 : 0); DateTime date1 = Convert.ToDateTime(arrParam[0]); DateTime time1 = Convert.ToDateTime(arrParam[1]); //insert factures with query DataSetISpaDataTableAdapters.VW_FACTURETableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_FACTURETableAdapter(); tableAdapter.InsertQuery(date1, time1, arrParam[2].ToString(), arrParam[3].ToString(), arrParam[4].ToString(), Convert.ToDecimal(arrParam[5])); _MotherForm.addRow(arrParam); } if (_Title.Equals("products")) { //nom,description,fournisseur,prix TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXDESCRIPTION")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXFOURNISSEUR")); arrParam.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPRIX")); String val = textBox.Text; val.Replace(',', '.'); double outDouble; if (!double.TryParse(textBox.Text, out outDouble)) { errorMessage("Prix non conforme (ex: 5.50)"); return; } val.Replace('.', ','); arrParam.Add(val); //insert product with query DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter(); tableAdapter.InsertQuery(arrParam[0].ToString(), arrParam[1].ToString(), arrParam[2].ToString(), arrParam[3].ToString()); _MotherForm.addRow(arrParam); } if (_Title.Equals("users")) { DataSetISpaData datas = new DataSetISpaData(); ArrayList arr = new ArrayList(); // set attributes from form TextBox textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXNOM")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXPASSWORD")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXTYPE")); arr.Add(textBox.Text); textBox = _Inputs.Find(x => x.Name.Contains("txtBoxXACTIF")); if (!(textBox.Text.ToLower() == "true" || textBox.Text.ToLower() == "false")) { errorMessage("Boolean Actif non conforme (ex:true ou false)"); return; } arr.Add(textBox.Text == "true" ? 1 : 0); //insert user with query DataSetISpaDataTableAdapters.VW_USERTableAdapter tableAdapter = new DataSetISpaDataTableAdapters.VW_USERTableAdapter(); tableAdapter.InsertQuery(arr[0].ToString(), arr[1].ToString(), arr[2].ToString(), Convert.ToDecimal(arr[3])); //refresh current table _MotherForm.addRow(arrParam); } this.Close(); }
private void cellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals(_OldValue.ToString())) { return; } DataSetISpaData datas = new DataSetISpaData(); Console.WriteLine(_CurrentTitle); String[] arr = new String[dgv.Rows[e.RowIndex].Cells.Count]; for (int i = 0; i < dgv.Rows[e.RowIndex].Cells.Count; i++) { arr[i] = dgv.Rows[e.RowIndex].Cells[i].Value.ToString(); } int posKey; String primaryKey; int[] posKeys; String[] primaryKeys; switch (_CurrentTitle) { case "agenda": // pos 0 1 et 2 Sont les valeurs de la cle primaire primaryKeys = new String[3]; primaryKeys[0] = arr[0]; primaryKeys[1] = arr[1]; primaryKeys[2] = arr[2]; for (int i = 0; i < primaryKeys.Length; i++) { if (i == _OldValuePos) { primaryKeys[i] = _OldValue.ToString(); } } DataSetISpaDataTableAdapters.VW_AGENDATableAdapter tableAdapter1 = new DataSetISpaDataTableAdapters.VW_AGENDATableAdapter(); DateTime date = Convert.ToDateTime(arr[0]); DateTime time = Convert.ToDateTime(arr[1]); DateTime dateKey = Convert.ToDateTime(primaryKeys[0]); DateTime timeKey = Convert.ToDateTime(primaryKeys[1]); tableAdapter1.UpdateQuery(date, time, arr[2].ToString(), arr[3].ToString(), dateKey, timeKey, primaryKeys[2].ToString()); Console.WriteLine("old value " + _OldValue); Console.WriteLine("new value " + dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); break; case "clients": // pos 3 est la valeur de la cle primaire posKey = 3; primaryKey = arr[posKey]; if (_OldValuePos == posKey) { primaryKey = _OldValue.ToString(); } DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter tableAdapte2 = new DataSetISpaDataTableAdapters.VW_CLIENTTableAdapter(); tableAdapte2.UpdateQuery(arr[0], arr[1], Convert.ToDateTime(arr[2]), arr[3], arr[4], primaryKey.ToString()); Console.WriteLine("old value " + _OldValue); Console.WriteLine("new value " + dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); break; case "products": // pos 0 et 2 Sont les valeurs de la cle primaire primaryKeys = new String[3]; primaryKeys[0] = arr[0]; primaryKeys[2] = arr[2]; for (int i = 0; i < primaryKeys.Length; i++) { if (i == _OldValuePos) { primaryKeys[i] = _OldValue.ToString(); } } DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter tableAdapter3 = new DataSetISpaDataTableAdapters.VW_PRODUITTableAdapter(); tableAdapter3.UpdateQuery(arr[0], arr[1], arr[2], arr[3].ToString().Trim(), primaryKeys[0].ToString(), primaryKeys[2].ToString()); Console.WriteLine("old value " + _OldValue); Console.WriteLine("new value " + dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); break; case "factures": // pos 0 1 et 2 Sont les valeurs de la cle primaire primaryKeys = new String[3]; primaryKeys[0] = arr[0]; primaryKeys[1] = arr[1]; primaryKeys[2] = arr[2]; for (int i = 0; i < primaryKeys.Length; i++) { if (i == _OldValuePos) { primaryKeys[i] = _OldValue.ToString(); } } DateTime date2 = Convert.ToDateTime(arr[0]); DateTime time2 = Convert.ToDateTime(arr[1]); DateTime dateKey2 = Convert.ToDateTime(primaryKeys[0]); DateTime timeKey2 = Convert.ToDateTime(primaryKeys[1]); DataSetISpaDataTableAdapters.VW_FACTURETableAdapter tableAdapte4 = new DataSetISpaDataTableAdapters.VW_FACTURETableAdapter(); tableAdapte4.UpdateQuery(date2, time2, arr[2].ToString(), arr[3].ToString(), arr[4].ToString(), Convert.ToDecimal(arr[5]), dateKey2, timeKey2, primaryKeys[2].ToString()); Console.WriteLine("old value " + _OldValue); Console.WriteLine("new value " + dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); break; case "users": // pos 0 est la valeur de la cle primaire posKey = 0; primaryKey = arr[posKey]; if (_OldValuePos == posKey) { primaryKey = _OldValue.ToString(); } DataSetISpaDataTableAdapters.VW_USERTableAdapter tableAdapter5 = new DataSetISpaDataTableAdapters.VW_USERTableAdapter(); tableAdapter5.UpdateQuery(arr[0], arr[1], arr[2], Convert.ToDecimal(arr[3]), primaryKey.ToString()); Console.WriteLine("old value " + _OldValue); Console.WriteLine("new value " + dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); break; } }