void DataGridDoubleClickBehavior_Click(object sender, MouseButtonEventArgs e) { if (dgINIT.SelectedItem != null) { CsInit initselected = dgINIT.SelectedItem as CsInit; } }
void btnDelete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Voulez vous vraiment supprimer cet element", "Confirmation", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { CsInit selected = dgINIT.SelectedItem as CsInit; if (selected != null) { ParametrageClient delete = new ParametrageClient(Utility.Protocole(), Utility.EndPoint("Parametrage")); delete.DeleteINITCompleted += (del, argDel) => { if (argDel.Cancelled || argDel.Error != null) { string error = argDel.Error.Message; MessageBox.Show(error, "DeleteINIT", MessageBoxButton.OK); desableProgressBar(); return; } if (argDel.Result == false) { MessageBox.Show("Error on insert/update ", "DeleteINIT", MessageBoxButton.OK); desableProgressBar(); return; } int rank = dgINIT.SelectedIndex; int inc = 0; donnesDatagrid.RemoveAt(rank); dgINIT.ItemsSource = null; columnAmount.Clear(); rowcomboselectedObject.Clear(); //rowcomboselectedObject = new CsProduit[donnesDatagrid.Count]; //rowselectDate = new DateTime?[donnesDatagrid.Count]; //columnAmount = new bool[donnesDatagrid.Count]; foreach (CsInit tag in donnesDatagrid) { columnAmount.Add(tag.OBLIG == "O" ? true : false); CsProduit prod = produits.FirstOrDefault(p => p.LIBELLE == tag.PRODUIT); rowcomboselectedObject.Add(prod); } dgINIT.ItemsSource = donnesDatagrid; // verifier si l'element supprime est in item des liste NewAdded ou UpdatedList // checkInlistItem(selected); }; delete.DeleteINITAsync(selected.CENTRE, selected.PRODUIT, selected.NTABLE, selected.ZONE); } } }
private void cbo_Observation_DropDownClosed(object sender, EventArgs e) { try { var src = sender as ComboBox; string comboxselected = string.Empty; CsProduit comboObject = src.SelectedItem as CsProduit; CsProduit selectedObject = new CsProduit(); if (src != null) { comboxselected = comboObject.CODE; selectedObject = comboObject; string rank = src.Name.Substring(combobasename.Length); rowcomboselectedObject[int.Parse(rank)] = selectedObject; donnesDatagrid[int.Parse(rank)].PRODUIT = comboxselected; CsInit u = donnesDatagrid[int.Parse(rank)]; // ajout des element modifies dans la liste des elements modifies if (majData.Count > 0 && majData != null) { if (majData.FirstOrDefault(p => p.ROWID == u.ROWID) != null) { foreach (CsInit t in majData) { if (t.ROWID == u.ROWID) { t.PRODUIT = u.PRODUIT; } } } else { majData.Add(u); } } else { majData.Add(u); } } } catch (Exception ex) { string error = ex.Message; } }
void btnAddRow_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(txtAmount.Text) || string.IsNullOrEmpty(txtcentre.Text) || string.IsNullOrEmpty(txtDefValeusss.Text) || (cbo_refTables.SelectedItem as CsInit) == null || cbo_refZones.SelectedItem == null) { MessageBox.Show("All fiedls are required before inserting"); return; } CsInit add = new CsInit() { CONTENU = txtDefValeusss.Text, OBLIG = txtAmount.Text, PRODUIT = (cbo_products.SelectedItem as CsProduit).CODE, DMAJ = DateTime.Now, CENTRE = txtcentre.Text, NTABLE = cbo_refTables.SelectedValue.ToString().Trim(), ZONE = (cbo_refZones.SelectedItem as CsZone).Code }; newData.Add(add); dgINIT.ItemsSource = null; List <CsInit> oldCsinit = new List <CsInit>(); oldCsinit.AddRange(donnesDatagrid); donnesDatagrid.Clear(); donnesDatagrid.Add(add); donnesDatagrid.AddRange(oldCsinit); int inc = 0; rowcomboselectedObject.Clear(); columnAmount.Clear(); foreach (CsInit tag in donnesDatagrid) { columnAmount.Add(tag.OBLIG == "O" ? true : false); CsProduit prod = produits.FirstOrDefault(p => p.LIBELLE == tag.PRODUIT || p.CODE == tag.PRODUIT); rowcomboselectedObject.Add(prod); inc++; } dgINIT.ItemsSource = donnesDatagrid; resetInsertData(); } catch (Exception ex) { string error = ex.Message; } }
void dtpMaj_CalendarClosed(object sender, RoutedEventArgs e) { try { var src = sender as DatePicker; string comboxselected = string.Empty; CTab300 selectedObject = new CTab300(); if (src != null) { string rank = src.Name.Substring(src.Name.Length - 1); rowselectDate[int.Parse(rank)] = src.SelectedDate; donnesDatagrid[int.Parse(rank)].DMAJ = src.SelectedDate; // btnOk.Visibility = System.Windows.Visibility.Visible; CsInit u = donnesDatagrid[int.Parse(rank)]; // ajout des element modifies dans la liste des elements modifies if (majData.Count > 0 && majData != null) { if (majData.First(p => p.CENTRE == u.CENTRE && p.ROWID == u.ROWID) != null) { foreach (CsInit t in majData) { if (t.ROWID == u.ROWID) { t.DMAJ = u.DMAJ; } } } else { majData.Add(u); } } else { majData.Add(u); } } } catch (Exception ex) { string error = ex.Message; } }
private void chkAmount_Click(object sender, RoutedEventArgs e) { try { var src = sender as CheckBox; string obligation = src.IsChecked == true ? "O" : "N"; string comboxselected = string.Empty; if (src != null) { string rank = src.Name.Substring(checkbasename.Length); columnAmount[int.Parse(rank)] = false; donnesDatagrid[int.Parse(rank)].OBLIG = obligation; CsInit u = donnesDatagrid[int.Parse(rank)]; // ajout des element modifies dans la liste des elements modifies if (majData.Count > 0 && majData != null) { if (majData.First(p => p.CENTRE == u.CENTRE && p.ROWID == u.ROWID) != null) { foreach (CsInit t in majData) { t.OBLIG = u.OBLIG; t.DMAJ = DateTime.Now; } } else { majData.Add(u); } } else { majData.Add(u); } } } catch (Exception ex) { string error = ex.Message; } }
void checkInlistItem(CsInit selected) { try { if (newData.Contains(selected)) { newData.Remove(selected); } if (majData.Contains(selected)) { majData.Remove(selected); } } catch (Exception ex) { string error = ex.Message; } }
void dgINIT_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e) { CsInit u = e.Row.DataContext as CsInit; //fetch the row data u.DMAJ = DateTime.Now; donnesDatagrid[e.Row.GetIndex()].CONTENU = u.CONTENU; btnOk.IsEnabled = true; btnOk.Visibility = System.Windows.Visibility.Visible; try { if (majData.Count > 0 && majData != null) { if (majData.First(p => p.ROWID == u.ROWID) != null) { foreach (CsInit t in majData) { if (t.ROWID == u.ROWID) { t.CENTRE = u.CENTRE; t.CONTENU = u.CONTENU; t.LIBELLE = u.LIBELLE; t.PRODUIT = u.PRODUIT; t.OBLIG = u.OBLIG; t.DMAJ = DateTime.Now; } } } else { majData.Add(u); } } else { majData.Add(u); } } catch (Exception ex) { string error = ex.Message; } }
void GetData(int numtable) { try { // Initialisation variables globales produits.Clear(); donnesDatagrid.Clear(); newData.Clear(); majData.Clear(); rowcomboselectedObject.Clear(); rowselectDate.Clear(); columnAmount.Clear(); ParametrageClient client = new ParametrageClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Parametrage")); client.SelectAllProductsCompleted += (ssender, args) => { if (args.Cancelled || args.Error != null) { string error = args.Error.Message; MessageBox.Show(error, ".SelectAllProducts", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } if (args.Result == null || args.Result.Count == 0) { MessageBox.Show("No data found ", ".SelectAllProducts", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } CsInit emptyplace = new CsInit(); produits.Clear(); produits.AddRange(args.Result); cbo_refproducts.ItemsSource = produits; ParametrageClient proxy = new ParametrageClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Parametrage")); proxy.SelectAll_REGROUCompleted += (s1, args1) => { if (args1.Cancelled || args1.Error != null) { string error = args1.Error.Message; MessageBox.Show(error, ".SelectInitTableData", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } if (args1.Result == null || args1.Result.Count == 0) { MessageBox.Show("No data found ", ".SelectInitTableData", MessageBoxButton.OK); desableProgressBar(); //this.DialogResult = true; return; } donnesDatagrid.Clear(); dgINIT.ItemsSource = null; donnesDatagrid.AddRange(args1.Result); dgINIT.ItemsSource = donnesDatagrid; // peupler la liste des nom de tables try { //Initializer les element du tableau rowcomboselectedObject //Initializer les element du tableau columAmount foreach (CsRegrou tag in donnesDatagrid) { CsProduit prod = produits.FirstOrDefault(p => p.CODE == tag.PRODUIT); rowcomboselectedObject.Add(prod); } } catch (Exception ex) { string error = ex.Message; } }; proxy.SelectAll_REGROUAsync(); }; client.SelectAllProductsAsync(); } catch (Exception ex) { string error = ex.Message; } }
void dgINIT_SelectionChanged(object sender, SelectionChangedEventArgs e) { CsInit itemselected = dgINIT.SelectedItem as CsInit; cbo_refTable.SelectedItem = itemselected; }
void GetData(int numtable) { try { ParametrageClient client = new ParametrageClient(Utility.Protocole(), Utility.EndPoint("Parametrage")); client.SelectAllProductsCompleted += (ssender, args) => { if (args.Cancelled || args.Error != null) { string error = args.Error.Message; MessageBox.Show(error, ".SelectAllProducts", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } if (args.Result == null || args.Result.Count == 0) { MessageBox.Show("No data found ", ".SelectAllProducts", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } CsInit emptyplace = new CsInit(); produits.Clear(); produits.AddRange(args.Result); cbo_products.ItemsSource = produits; ParametrageClient proxy = new ParametrageClient(Utility.Protocole(), Utility.EndPoint("Parametrage")); proxy.SelectInitTableDataCompleted += (s1, args1) => { if (args1.Cancelled || args1.Error != null) { string error = args1.Error.Message; MessageBox.Show(error, ".SelectInitTableData", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } if (args1.Result == null || args1.Result.Count == 0) { MessageBox.Show("No data found ", ".SelectInitTableData", MessageBoxButton.OK); desableProgressBar(); this.DialogResult = true; return; } CsInit emptyplace2 = new CsInit(); donnesDatagrid.Clear(); dgINIT.ItemsSource = null; donnesDatagrid.AddRange(args1.Result); donnesDatagrid.Add(emptyplace2); dgINIT.ItemsSource = donnesDatagrid; // peupler la liste des nom de tables IEnumerable <CsInit> distinclistes = donnesDatagrid.GroupBy(cust => cust.NTABLE).Select(grp => grp.First()); foreach (CsInit init in distinclistes) { tableNames.Add(init); } // peupler la combobox des nom de tables cbo_refTable.ItemsSource = tableNames; try { //rowcomboselectedObject = new CsProduit[donnesDatagrid.Count]; //rowselectDate = new DateTime?[donnesDatagrid.Count]; //columnAmount = new bool[donnesDatagrid.Count]; int inc = 0; //Initializer les element du tableau rowcomboselectedObject //Initializer les element du tableau columAmount foreach (CsInit tag in donnesDatagrid) { columnAmount[inc] = tag.OBLIG == "O" ? true : false; CsProduit prod = produits.FirstOrDefault(p => p.CODE == tag.PRODUIT); rowcomboselectedObject[inc] = prod; inc++; } } catch (Exception ex) { string error = ex.Message; } }; proxy.SelectInitTableDataAsync(); }; client.SelectAllProductsAsync(); } catch (Exception ex) { string error = ex.Message; } }