public void Updating(int ID_staff, int ID_project, int ID_RangeTimesOT, double SoGioOT, DateTime DateDangKy)
        {
            NHANVIEN_OT temp = data.NHANVIEN_OT.SingleOrDefault(id => id.ID == ID_staff);

            if (temp != null)
            {
                temp.ID_Project        = ID_project;
                temp.ID_Range_Hours_OT = ID_RangeTimesOT;
                temp.SoGioOT           = SoGioOT;
                temp.DateDangKy        = DateDangKy;
                data.SaveChanges();
            }
        }
Esempio n. 2
0
 //btn Add OT
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (this.txtOTHours.Text == null)
     {
         MessageBox.Show("Cần nhập số giờ OT");
     }
     else
     {
         DialogResult confirm = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButtons.YesNoCancel);
         if (confirm == DialogResult.Yes)
         {
             NHANVIEN_OT OTOfStaff = new NHANVIEN_OT();
             OTOfStaff.ID_NhanVien       = Convert.ToInt32(this.cbNameOfStaff.SelectedValue);
             OTOfStaff.DateDangKy        = this.DateCreateOT.Value;
             OTOfStaff.SoGioOT           = Convert.ToDouble(this.txtOTHours.Text);
             OTOfStaff.ID_Range_Hours_OT = Convert.ToInt32(this.cbRangeHoursOT.SelectedValue);
             data.NHANVIEN_OT.Add(OTOfStaff);
             int resultCreate = data.SaveChanges();
             if (resultCreate < 1)
             {
                 MessageBox.Show("Thêm thất bại !!!");
             }
             else
             {
                 MessageBox.Show("Thêm thành công");
                 this.lbUserName.Text = "";
                 this.cbRangeHoursOT.SelectedValue = -1;
                 this.cbNameOfStaff.SelectedValue  = -1;
                 this.txtOTHours.Text = "";
                 if (addDataSuccess != null)
                 {
                     addDataSuccess(this, null);
                 }
             }
         }
     }
 }