Esempio n. 1
0
 void dataGridView1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         if (this.dgvListForm.SelectedRows.Count == 1)
         {
             if (MessageBox.Show("Do you want delete this?") == System.Windows.Forms.DialogResult.OK)
             {
                 XeView selected =
                     (XeView)this.dgvListForm.SelectedRows[0].DataBoundItem;
                 var db      = new WorkerFileEntities();
                 Xe  deleted = db.Xes.Find(selected.License_Plates);
                 db.Xes.Remove(deleted);
                 db.SaveChanges();
                 string   bienSoXe = selected.License_Plates;
                 string   tenXe    = selected.Name;
                 int      hangXe   = business.ReManufacure(selected.Manufacture);
                 DateTime time     = DateTime.Parse(selected.Time_Parking);
                 business.AddBikes(bienSoXe, tenXe, hangXe, time);
                 MessageBox.Show("Successfully deleted");
                 this.OnLoad(null);
             }
         }
     }
 }
Esempio n. 2
0
 void ListForm_Load(object sender, EventArgs e)
 {
     this.dgvListForm.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
     Xe[]     data = business.GetBikes();
     XeView[] view = new XeView[data.Length];
     for (int i = 0; i < data.Length; i++)
     {
         view[i]                = new XeView();
         view[i].Name           = data[i].Name;
         view[i].License_Plates = data[i].License_Plates;
         view[i].Manufacture    = business.GetManufacture(data[i].Manufacture);
         view[i].Time_Parking   = data[i].Time_Parking.ToShortDateString();
     }
     this.dgvListForm.DataSource = view;
 }
Esempio n. 3
0
        void btnRestore_Click(object sender, EventArgs e)
        {
            XeView selected =
                (XeView)this.dgvRecycle.SelectedRows[0].DataBoundItem;
            var       db       = new WorkerFileEntities();
            XeDeleted restored = db.XeDeleteds.Find(selected.License_Plates);

            db.XeDeleteds.Remove(restored);
            db.SaveChanges();
            string   bienSoXe = selected.License_Plates;
            string   tenXe    = selected.Name;
            int      hangXe   = business.ReManufacure(selected.Manufacture);
            DateTime time     = DateTime.Parse(selected.Time_Parking);

            business.AddBike(bienSoXe, tenXe, hangXe, time);
            MessageBox.Show("Restore Successfully");
            this.OnLoad(null);
        }
Esempio n. 4
0
 void dgvRecycle_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         if (this.dgvRecycle.SelectedRows.Count == 1)
         {
             if (MessageBox.Show("Are you sure?") == System.Windows.Forms.DialogResult.OK)
             {
                 XeView selected =
                     (XeView)this.dgvRecycle.SelectedRows[0].DataBoundItem;
                 var       db      = new WorkerFileEntities();
                 XeDeleted deleted = db.XeDeleteds.Find(selected.License_Plates);
                 db.XeDeleteds.Remove(deleted);
                 db.SaveChanges();
                 MessageBox.Show("Successfully deleted");
                 this.OnLoad(null);
             }
         }
     }
 }