/// <summary> /// thiet lap lich lam viec cho nhung nhan vien duoc chon /// </summary> private void SetWorkingTime() { int DeparmentID = (int)departmentTreeView.SelectedNode.Tag; int employeeID = 0; try { // dsWorkingTime = workingTimeDO.GetWorkingTimeByMonthNew(1, CurrentMonth, CurrentYear); dsEmployee = employeeDO.GetEmployeeByDepartment(DeparmentID); WorkingTimeDataRows = dsEmployee.Tables[0].Select(dataFilter, dataSort); // hien thi form thong bao trang thai hoan thanh frmStatusMessage message = new frmStatusMessage(); string strStatus = WorkingContext.LangManager.GetString("frmStatus_thongbao"); //message.Show("Đang sinh dữ liệu bảng chấm công, xin chờ trong giây lát..."); message.Show("Đang cập nhật lịch làm thêm cho nhân viên ..."); message.ProgressBar.Value = 0; // int totalEmployees = dataRows.Length; Cursor = Cursors.WaitCursor; int percentToComplete = 0; int percentProcessing = 0; for (int i = 0; i < lvwListEmployee.SelectedIndicies.Length; i++) { ++percentProcessing; // AddWorkingTimeByEmployee(dsWorkingTime,1); // chỉ số hàng được chọn int rowIndex = (int)lvwListEmployee.SelectedItems[i].Tag; DataRow dr = dsEmployee.Tables[0].Rows[rowIndex]; employeeID = int.Parse(dr["EmployeeID"].ToString()); //dsWorkingTime = workingTimeDO.GetWorkingTimeByMonth(employeeID, CurrentMonth, CurrentYear); //if (dsWorkingTime.Tables[0].Rows.Count > 0) //{ // UpdateWorkingTimeByEmployee(dsWorkingTime, employeeID); //} //else //{ shiftDO = new ShiftDO(); shiftDO.DeleteOverTimeInMonth(CurrentMonth, CurrentYear); AddWorkingTimeByEmployee(employeeID); //} percentToComplete = (percentProcessing * 100) / lvwListEmployee.SelectedIndicies.Length; message.ProgressBar.Value = percentToComplete; } message.Close(); Cursor = Cursors.Default; string str = WorkingContext.LangManager.GetString("frmRegWork_Up_Messa"); string str1 = WorkingContext.LangManager.GetString("frmRegWork_Up_Title"); //MessageBox.Show("Đăng ký thời gian làm việc thành công", "Đăng ký thời gian làm việc", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { string str = WorkingContext.LangManager.GetString("frmLunch_SetLunch_ThongBao"); string str1 = WorkingContext.LangManager.GetString("frmLunch_SetLunch_Title"); //MessageBox.Show("Có lỗi xảy ra khi cập nhật dữ liệu ăn trưa", "Thiết lập ăn trưa", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (selectedDates != null) { RemoveOldDateInfo(); if (!deleteOverTime.Checked) { SetOverTime(); } else { shiftDO = new ShiftDO(); shiftDO.DeleteOverTimeInMonth(CurrentMonth, CurrentYear); } } if (monthCalendar1.Dates.Count > 0) { SetWorkingTime(); } }