Exemplo n.º 1
0
        void EditArea()
        {
            int index   = (this.Owner as WorkAreas).lbox.Items.IndexOf(this.update_Area);
            int idTable = update_Area.Id;

            List <WorkArea> all    = ReadFromDatabase.ShowAllAreas(num).ToList();
            WorkArea        update = all.Where(i => i.Id == idTable).FirstOrDefault();

            update.SiteName   = name_txt.Text;
            update.Login      = login_txt.Text;
            update.Password   = paswd_txt.Text;
            update.Phone      = Convert.ToInt32(phone_txt.Text);
            update.URL        = url_txt.Text;
            update.Email      = email_txt.Text;
            update.Coments    = coments_txt.Text;
            update.DateCreate = DateTime.Now;

            string res = EditRecord.EditInfo(update, num);

            MessageBox.Show(res, "Result Update");

            (this.Owner as WorkAreas).lbox.Items.RemoveAt(index);
            (this.Owner as WorkAreas).lbox.Items.Insert(index, update);

            this.Close();
        }
Exemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int             size  = ReadFromDatabase.ShowAllAreas(num_table).Count();
            List <WorkArea> lArea = ReadFromDatabase.ShowAllAreas(num_table).ToList();

            for (int i = 0; i < size; i++)
            {
                lbox.Items.Add(lArea[i]);
            }
            if (lbox.Items.Count == 0)
            {
                lbox.Items.Add("The table is empty. Try to add new info");
            }
        }