private void btnSave2_Click(object sender, EventArgs e)
        {
            DateTime dt =
                DateTime.ParseExact(this.textBox1.Text.ToString(), "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture);

            le.Name            = this.textboxName.Text;
            le.Time            = dt;
            le.Place           = this.textBoxPlace.Text;
            le.Description     = this.textBoxDes.Text;
            db.Entry(le).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            this.Close();
            MessageBox.Show("Edit successfully");
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt =
                DateTime.ParseExact(this.textBoxDate2.Text, "dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture);

            TimeKeeperEntities db = new TimeKeeperEntities();
            List_Event         ls = new List_Event();

            ls.Name = this.textBoxName.Text;
            ls.Time = dt;

            ls.Place       = this.textBoxPlace.Text;
            ls.Description = this.textBoxDes.Text;
            db.List_Event.Add(ls);
            db.SaveChanges();
            this.Close();
            MessageBox.Show("Add successfully");
        }
Beispiel #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dataList.SelectedRows.Count == 1)
     {
         var row  = dataList.SelectedRows[0];
         var cell = row.Cells["Id"];
         int id   = (int)cell.Value;
         TimeKeeperEntities db = new TimeKeeperEntities();
         List_Event         ls = db.List_Event.Single(le => le.Id == id);
         db.List_Event.Remove(ls);
         db.SaveChanges();
         MessageBox.Show("Delete sucessfully");
         Load_Event();
     }
     else
     {
         MessageBox.Show("You should a row");
     }
 }