Exemplo n.º 1
0
        private void btnAddRow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(Txt_NumeroTable.Text) || string.IsNullOrEmpty(txtcode.Text) ||
                    string.IsNullOrEmpty(txtref.Text) || string.IsNullOrEmpty(txtcentre.Text))
                {
                    MessageBox.Show("All fiedls are required before inserting");
                    return;
                }

                aTa add = new aTa()
                {
                    NUM     = Convert.ToInt16(Txt_NumeroTable.Text),
                    LIBELLE = txtref.Text,
                    CODE    = txtcode.Text,
                    DMAJ    = DateTime.Now,
                    CENTRE  = txtcentre.Text
                };

                newData.Add(add);
                lvwResultat.ItemsSource = null;
                donnesDatagrid.Add(add);

                lvwResultat.ItemsSource = donnesDatagrid;

                resetInsertData();
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
Exemplo n.º 2
0
        void GetData(int numtable)
        {
            try
            {
                donnesDatagrid.Clear();
                newData.Clear();
                majData.Clear();

                rowcomboselectedObject.Clear();
                rowselectDate.Clear();

                ParametrageClient client = new ParametrageClient(Utility.Protocole(), Utility.EndPoint("Parametrage"));
                client.SELECTALLByNUMTABLECompleted += (ssender, args) =>
                {
                    if (args.Cancelled || args.Error != null)
                    {
                        string error = args.Error.Message;
                        MessageBox.Show(error, "SELECTALLByNUMTABLE", MessageBoxButton.OK);
                        desableProgressBar();
                        this.DialogResult = true;
                        return;
                    }

                    if (args.Result == null || args.Result.Count == 0)
                    {
                        MessageBox.Show("No data found ", "SELECTALLByNUMTABLE", MessageBoxButton.OK);
                        desableProgressBar();
                        this.DialogResult = true;
                        return;
                    }

                    aTa emptyplace = new aTa();
                    donnesDatagrid.Clear();
                    lvwResultat.ItemsSource = null;


                    donnesDatagrid.AddRange(args.Result);
                    donnesDatagrid.Add(emptyplace);
                    lvwResultat.ItemsSource = donnesDatagrid;
                };
                client.SELECTALLByNUMTABLEAsync(numtable);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
Exemplo n.º 3
0
        private void lvwResultat_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
        {
            try
            {
                aTa u = e.Row.DataContext as aTa; //fetch the row data

                if (majData.Count > 0 && majData != null)
                {
                    if (majData.First(p => p.CENTRE == u.CENTRE && p.ROWID == u.ROWID && u.CODE == p.CODE) != null)
                    {
                        foreach (aTa t in majData)
                        {
                            if (t.CODE == u.CODE && t.ROWID == u.ROWID)
                            {
                                t.CENTRE  = u.CENTRE;
                                t.CODE    = u.CODE;
                                t.LIBELLE = u.LIBELLE;
                                t.NUM     = u.NUM;
                                t.DMAJ    = DateTime.Now;
                            }
                        }
                    }
                    else
                    {
                        majData.Add(u);
                    }
                }
                else
                {
                    majData.Add(u);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }