Example #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);
             }
         }
     }
 }
Example #2
0
        public void thayDoi(string bienSo, string tenXe, int hangXe, DateTime guiXe)
        {
            WorkerFileEntities db = new WorkerFileEntities();
            var soXe = db.Xes.Find(bienSo);

            soXe.Name         = tenXe;
            soXe.Manufacture  = hangXe;
            soXe.Time_Parking = guiXe;
            db.SaveChanges();
            db.Dispose();
        }
Example #3
0
        public void AddBikes(string bienSo, string tenXe, int hangXe, DateTime guiXe)
        {
            WorkerFileEntities db  = new WorkerFileEntities();
            XeDeleted          xed = new XeDeleted();

            xed.License_Plates = bienSo;
            xed.Name           = tenXe;
            xed.Manufacture    = hangXe;
            xed.Time_Parking   = guiXe;
            db.XeDeleteds.Add(xed);
            db.SaveChanges();
            db.Dispose();
        }
Example #4
0
        public void AddOwners(string cMND, string hoVaTen, DateTime ngaySinh, string bienSoXe)
        {
            WorkerFileEntities db = new WorkerFileEntities();
            ChuXe chuxe           = new ChuXe();

            chuxe.CMND           = cMND;
            chuxe.Name           = hoVaTen;
            chuxe.Birthday       = ngaySinh;
            chuxe.License_Plates = bienSoXe;
            db.ChuXes.Add(chuxe);
            db.SaveChanges();
            db.Dispose();
        }
Example #5
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);
        }
Example #6
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);
             }
         }
     }
 }