private void ThucHienXoaGioXuongCSDL(ref List <cUserInfo> DSNVReload, ref List <DataRow> listSelectedRow, bool checkXoaVao, bool checkXoaRaa) { foreach (DataRow dataRow in listSelectedRow) { cCheckInOut currentCIO = (cCheckInOut)dataRow["cCheckInOut"]; cUserInfo currentNhanVien = (cUserInfo)dataRow["cUserInfo"]; if (DSNVReload.Any(item => item.MaCC == currentNhanVien.MaCC) == false) { DSNVReload.Add(currentNhanVien); } int UEN = (int)dataRow["UserEnrollNumber"]; if (currentCIO == null || currentNhanVien == null) { continue; } if (checkXoaVao) { this.XoaGio(currentCIO, UEN); } if (checkXoaRaa) { this.XoaGio(currentCIO, UEN); } } //tbd thông báo lỗi các trường hợp không thể thêm giờ }
private void TinhCong(cCheckInOut CIO, cCa Ca) { TinhCong(CIO.Tre, CIO.Som, CIO.ChoPhepTre, CIO.ChoPhepSom, CIO.VaoTuDo, CIO.RaaTuDo, CIO.LamTrongGio, CIO.LamNgoaiGio, Ca.WorkingTimeTS, Ca.Workingday, out CIO.TruCongTre, out CIO.TruCongSom, out CIO.TrongGio, out CIO.NgoaiGio, out CIO.DinhMuc, out CIO.Tong); }
private void XoaGio(cCheckInOut CIO, int UEN) { DateTime timeStringOld; int machineNoOld; if (CIO.HaveINOUT == -1) { timeStringOld = CIO.Vao.Time; machineNoOld = CIO.Vao.MachineNo; } else if (CIO.HaveINOUT == -2) { timeStringOld = CIO.Raa.Time; machineNoOld = CIO.Raa.MachineNo; } else { return; } #region int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName.CheckInOut_Delete.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@TimeStr", timeStringOld), new SqlParameter("@MachineNo", machineNoOld)); #endregion }
public static void XacNhanCa(cUserInfo nv, cCheckInOut CIO, cCa currShift, bool bDuyetCPTre, bool bDuyetCPSom, int soPhutLamThem, bool choPhepTinhPc50, string lydo, string ghichu, bool bVaoTreLaCV, bool bRaaSomLaCV, TS NightTime)//ver 4.0.0.4 //if (CIO.Vao.Time <= XL2.NgayCuoiThangKetCong) return; { if (currShift.TachCaDem) { if (CIO.DaXN) { XacNhan_CIO_V_CoTachCa(nv, CIO, currShift, bDuyetCPTre, bDuyetCPSom, soPhutLamThem, choPhepTinhPc50, lydo, ghichu, bVaoTreLaCV, bRaaSomLaCV, NightTime); //ver 4.0.0.4 } else { XacNhan_CIO_A_CoTachCa(nv, CIO, currShift, bDuyetCPTre, bDuyetCPSom, soPhutLamThem, choPhepTinhPc50, lydo, ghichu, bVaoTreLaCV, bRaaSomLaCV, NightTime); //ver 4.0.0.4 } } else { if (CIO.DaXN) { XacNhan_CIO_V(nv, CIO, currShift, bDuyetCPTre, bDuyetCPSom, soPhutLamThem, choPhepTinhPc50, lydo, ghichu, bVaoTreLaCV, bRaaSomLaCV, NightTime); //ver 4.0.0.4 } else { XacNhan_CIO_A(nv, CIO, currShift, bDuyetCPTre, bDuyetCPSom, soPhutLamThem, choPhepTinhPc50, lydo, ghichu, bVaoTreLaCV, bRaaSomLaCV, NightTime); //ver 4.0.0.4 } } }
private void test_cell_merging_datagrid_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'wiseEyeV5ExpressDataSet.NhatKyThaoTac' table. You can move, or remove it, as needed. this.nhatKyThaoTacTableAdapter.Fill(this.wiseEyeV5ExpressDataSet.NhatKyThaoTac); DataTable table = new DataTable(); cCheckInOut a = new cCheckInOut(); //gridControl1.DataSource }
public void TinhTGLV_Cong(cCheckInOut CIO) { if (CIO.CheckVT == TrangThaiCheck.ThieuVao || CIO.CheckVT == TrangThaiCheck.ThieuRa) { return; //todo test } TinhTG_LV_LVCa3_LamThem1Ca(CIO, CIO.ThuocCa, CIO.ThuocCa.NightTime); TinhCong(CIO, CIO.ThuocCa); }
public int ValidateCIO(DataRow row, cCa CaDuocChon, bool CheckVaoTreTinhCV, bool CheckRaaSomTinhCV, bool CheckChoPhepTre, bool CheckChoPhepSom, TimeSpan soPhutLamThemDaXN) { /* -1 : Làm thêm > Ở lại*/ int kq = 0; cCheckInOut cio = (cCheckInOut)row["cCheckInOut"]; if (soPhutLamThemDaXN > cio.TG5.OLai) { return(-1); // } TS TOD_Duty, gioiHanChoPhepTreSom; DateTime td_batdau_lv, td_ketthuc_lv; TimeSpan tre, som; if (CaDuocChon.ID < 0) //ca tự do { TOD_Duty.Onn = new TimeSpan(cio.Vao.Time.TimeOfDay.Hours, cio.Vao.Time.TimeOfDay.Minutes, 0); TOD_Duty.Off = TOD_Duty.Onn.Add(CaDuocChon.WorkingTimeTS); XL.Vao(cio.Vao.Time, cio.ThuocNgayCong.Add(TOD_Duty.Onn), CaDuocChon.ThoiDiemTre(cio.ThuocNgayCong.Date), out td_batdau_lv, out tre); XL.Raa(cio.Raa.Time, cio.ThuocNgayCong.Add(TOD_Duty.Off), CaDuocChon.ThoiDiemSom(cio.ThuocNgayCong.Date), out td_ketthuc_lv, out som); } else //ca chuẩn { } //var temp1 = cio.ShiftID < 0 ? cio.Vao.Time.TimeOfDay cio.ThuocNgayCong.Add(CaDuocChon.TOD_Duty.Onn); var temp2 = cio.ThuocNgayCong.Add(CaDuocChon.TOD_Duty.Off); DateTime TD_BD_LV, TD_KT_LV, TD_KT_LV_TrongCa, TD_BD_LV_Ca3, TD_KT_LV_Ca3; bool QuaDem; TimeSpan TGThucTe, TGGioLamViec, TGVaoTre, TGRaaSom, TGGioLamViecTrongCa, TGOLai, TGLamBanDem; XL.TinhTG_LV_LVCa3_LamThem_1CIO5(cio.ThuocNgayCong, cio.HaveINOUT, true, CheckChoPhepTre, CheckChoPhepSom, cio.Vao.Time, cio.Raa.Time, CaDuocChon.TOD_Duty.Onn, CaDuocChon.TOD_Duty.Off, CaDuocChon.TS_PhutChoTre, CaDuocChon.TS_PhutChoSom, CaDuocChon.TS_PhutAfterOT, CaDuocChon.TS_PhutNghiTrua, soPhutLamThemDaXN, XL2.TOD_NightTime22h, //tbd start NT, endNT out TD_BD_LV, out TD_KT_LV, out TD_KT_LV_TrongCa, out TD_BD_LV_Ca3, out TD_KT_LV_Ca3, out TGThucTe, out TGGioLamViec, out TGVaoTre, out TGRaaSom, out TGGioLamViecTrongCa, out TGOLai, out QuaDem, out TGLamBanDem ); if (TGGioLamViec < XL2._10phut) { return(-2); } float congCaQuyDinh, congTre, congSom, congThucTeTrongCa, congThucTeNgoaiCa, congThucTe, tongCongBu, tongCongTru, dinhMucCong; XL.TinhCong_1_CIO_5(CaDuocChon.Workingday, CaDuocChon.WorkingTimeTS, TGVaoTre, TGRaaSom, CheckVaoTreTinhCV, CheckRaaSomTinhCV, soPhutLamThemDaXN, out congCaQuyDinh, out congTre, out congSom, out congThucTeTrongCa, out congThucTeNgoaiCa, out congThucTe, out tongCongBu, out tongCongTru, out dinhMucCong); if (Math.Abs(congThucTe - 0f) < 0.001f) { return(-2); } return(kq); }
private bool KiemTraThoaDieuKienThemCIO(cCheckInOut cio) { //logic: nếu check đủ vào ra, check ra thì thêm xuống csdl, //nếu check thiếu ra thì kiểm tra trên 22 tiếng mới cho thêm, dưới 22 tiếng thì vẫn có thể là trường hợp đang ở trong nhà máy if (cio.CheckVT == TrangThaiCheck.CheckDayDu || cio.CheckVT == TrangThaiCheck.ThieuVao || ((cio.CheckVT == TrangThaiCheck.ThieuRa) && (((DateTime.Now - cio.TimeDaiDien).Duration() > GlobalVariables._22h00)))) { return(true); } return(false); }
private void LoadGroup_Them(DateTime ngay, cCheckInOut CIO) { MyUtility.EnableDisableControl(true, btnChonCa_Them, btnThem); //vì thêm giờ ko cần xác định giờ cũ, chỉ insert data nên mặc định cho phép enable MyUtility.ClearControlText(tbCa_Them, tbGhichu_Them); tbCa_Them.Tag = (CIO == null || CIO.HaveINOUT < 0) ? null : CIO.ThuocCa; tbCa_Them.Text = (CIO == null || CIO.HaveINOUT < 0) ? string.Empty : CIO.ThuocCa.Code; chkGioVao.Checked = (CIO != null && CIO.HaveINOUT == -2); chkGioRaa.Checked = (CIO != null && CIO.HaveINOUT == -1); dtpVao_Them.Value = new DateTime(ngay.Year, ngay.Month, ngay.Day, 0, 0, 1); dtpRaa_Them.Value = new DateTime(ngay.Year, ngay.Month, ngay.Day, 0, 0, 1); cbLyDo_Them.SelectedIndex = 0; }
private void SuaGio(cCheckInOut CIO, MayCheck LoaiCheck, TimeSpan gioMoi, int UEN) { if (CIO.HaveINOUT == -1 && LoaiCheck.ToString() == MayCheck.O.ToString()) { return; // sửa giờ cùng loại, khác loại bỏ qua } if (CIO.HaveINOUT == -2 && LoaiCheck.ToString() == MayCheck.I.ToString()) { return; // sửa giờ cùng loại, khác loại bỏ qua } DateTime timeStringOld; int machineNoOld; string sourceOld; if (CIO.HaveINOUT == -1) { timeStringOld = CIO.Vao.Time; machineNoOld = CIO.Vao.MachineNo; sourceOld = CIO.Vao.Source; } else if (CIO.HaveINOUT == -2) { timeStringOld = CIO.Raa.Time; machineNoOld = CIO.Raa.MachineNo; sourceOld = CIO.Raa.Source; } else { return; } DateTime ngayGioMoi = timeStringOld.Date.Add(gioMoi); if (CIO.HaveINOUT == -1) { ngayGioMoi = ngayGioMoi.Add(XL2._01giay); // nếu sửa giờ vào thì add thêm 1 giây. } #region int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName.CheckInOut_Update.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@TimeStrOld", timeStringOld), new SqlParameter("@MachineNoOld", machineNoOld), new SqlParameter("@SourceOld", sourceOld), new SqlParameter("@OriginTypeNew", LoaiCheck.ToString()), new SqlParameter("@TimeDateNew", ngayGioMoi.Date), new SqlParameter("@TimeStrNew", ngayGioMoi), new SqlParameter("@MachineNoNew", (int)LoaiCheck), new SqlParameter("@SourceNew", "PC")); #endregion }
public void TinhTG_LV_LVCa3_LamThem1Ca(cCheckInOut CIO, cCa ca, FromToTimeSpan NightTime) { bool tempQuaDem; TinhTG_LV_LVCa3_LamThem1Ca(CIO.ThuocNgayCong, CIO.CheckVT, CIO.Vao.Time, CIO.Raa.Time, ca.Duty.From, ca.Duty.To, ca.ChoPhepTre_TimeOfDay, ca.ChophepSom_TimeOfDay, ca.BatdauOT_TimeOfDay, ca.LunchMin, NightTime, out CIO.VaoLamTron, out CIO.RaaLamTron, out CIO.BD_LV, out CIO.KT_LV_TrongCa, out CIO.KT_LV, out CIO.BD_LV_Ca3, out CIO.KT_LV_Ca3, out CIO.HienDien, out CIO.VaoSauCa, out CIO.RaTruocCa, out CIO.Tre, out CIO.Som, out CIO.OLaiVR, out CIO.LamTrongGio, out CIO.LamDem, out tempQuaDem); CIO.QuaDem = tempQuaDem; // ko cho phép out CIO.QuaDem nên fix tạm bằng cách dùng biến trung gian cục bộ và gán lại }
private void timeEditBoSungVao_Properties_ButtonClick(object sender, ButtonPressedEventArgs e) { /* 1. xác định CIO nào đang chọn để lấy thời gian vào hoặc ra * 2. trường hợp đặc biệt thỏa các điều kiện : * - đang chọn 1 row, chọn ca tự do, chế độ nhập bổ sung thì tự động thêm */ if (e.Button.Kind == ButtonPredefines.Search) { fmDSCa formDSCa = new fmDSCa(); formDSCa.ShowDialog(); if (formDSCa.m_YesNoCancel == YesNoCancel.Yes) { cCa selectedCa = formDSCa.selectedCa; TimeSpan timeVao, timeRaa; this.GetThoigianVaoraCa(selectedCa, out timeVao, out timeRaa); int[] selectingRowHandle = gridView1.GetSelectedRows(); if ((TimeEdit)sender == timeEditBoSungVao || (TimeEdit)sender == timeEditBoSungRaa) { if (selectingRowHandle.Count() == 1 && selectedCa.ID < 0) { cCheckInOut selectingCheckInOut = (gridView1.GetDataRow(selectingRowHandle[0]) != null) ? (cCheckInOut)(gridView1.GetDataRow(selectingRowHandle[0])["cCheckInOut"]) : null; if (selectingCheckInOut == null) { goto point1; } if (selectingCheckInOut.HaveINOUT == -1) { timeVao = TimeSpan.Zero; DateTime dateTimeVao = (selectingCheckInOut.Vao.Time.Add(selectedCa.WorkingTimeTS)); timeRaa = dateTimeVao.TimeOfDay; } else if (selectingCheckInOut.HaveINOUT == -2) { timeRaa = TimeSpan.Zero; DateTime dateTimeRaa = (selectingCheckInOut.Raa.Time.Add(-selectedCa.WorkingTimeTS)); timeVao = dateTimeRaa.TimeOfDay; } } point1: timeEditBoSungVao.Time = DateTime.Today.Date.Add(timeVao); timeEditBoSungRaa.Time = DateTime.Today.Date.Add(timeRaa); } else if ((TimeEdit)sender == timeEditSuaVao || (TimeEdit)sender == timeEditSuaRaa) { timeEditSuaVao.Time = DateTime.Today.Date.Add(timeVao); timeEditSuaRaa.Time = DateTime.Today.Date.Add(timeRaa); } } } }
private void ThucHienDaoGioCCXuongCSDL(ref List <cUserInfo> DSNVReload, ref List <DataRow> listSelectedRow) { foreach (DataRow dataRow in listSelectedRow) { cCheckInOut currentCIO = (cCheckInOut)dataRow["cCheckInOut"]; cUserInfo currentNhanVien = (cUserInfo)dataRow["cUserInfo"]; if (DSNVReload.Any(item => item.MaCC == currentNhanVien.MaCC) == false) { DSNVReload.Add(currentNhanVien); } int UEN = (int)dataRow["UserEnrollNumber"]; if (currentCIO == null || currentNhanVien == null) { continue; } DateTime timeString; int machineNoOld; string sourceOld; MayCheck mayCheckMoi; if (currentCIO.HaveINOUT == -1) { timeString = currentCIO.Vao.Time; machineNoOld = currentCIO.Vao.MachineNo; sourceOld = currentCIO.Vao.Source; mayCheckMoi = MayCheck.O; // đảo vào thành ra } else if (currentCIO.HaveINOUT == -2) { timeString = currentCIO.Raa.Time; machineNoOld = currentCIO.Raa.MachineNo; sourceOld = currentCIO.Raa.Source; mayCheckMoi = MayCheck.I; // đảo ra thành vào } else { continue; } int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName.CheckInOut_InvertKieuChamCong.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@TimeStr", timeString), new SqlParameter("@MachineNoOld", machineNoOld), new SqlParameter("@SourceOld", sourceOld), new SqlParameter("@TimeDateNew", timeString.Date), new SqlParameter("@MachineNoNew", (int)mayCheckMoi), new SqlParameter("@SourceNew", "PC")); } //tbd thông báo lỗi các trường hợp không thể thêm giờ }
private DataRow CreateDataRow_CIO_ThieuChamCong(DataTable dataTable, cUserInfo Nhanvien, cNgayCong NgayCong, cCheckInOut CIO) { DataRow kq = dataTable.NewRow(); kq["UserEnrollNumber"] = Nhanvien.MaCC; kq["UserFullName"] = Nhanvien.TenNV; kq["UserFullCode"] = Nhanvien.MaNV; kq["Ngay"] = NgayCong.Ngay; kq["GioVao"] = CIO.Vao != null ? CIO.Vao.Time : (object)DBNull.Value; kq["GioRa"] = CIO.Raa != null ? CIO.Raa.Time : (object)DBNull.Value; kq["DSCa"] = CIO.ExportKyHieuThuocCa1_5(true).XoaKyTuPhanCachDauTien(); kq["cCheckInOut"] = CIO; kq["cUserInfo"] = Nhanvien; kq["cNgayCong"] = NgayCong; return(kq); }
private void LoadGroup_Suaa(cNgayCong ngayCong, cCheckInOut cio, cCheck check) { if (check == null) { MyUtility.ClearControlText(tbGioCu_Suaa, tbCa_Suaa, tbGhiChu_Suaa); tbCa_Suaa.Tag = null; MyUtility.EnableDisableControl(false, btnChonCa_Suaa, btnSuaa); // ko tồn tại giờ cũ nên ko cho sửa, chuyển đổi cbLyDo_Suaa.SelectedIndex = 0; } else { // xem xét check là CIO_V hay CIO_A, CIO_A cho sửa, CIO_V ko cho sửa, trong CIO_A coi có phải là check đệm giữa ca ko tbGioCu_Suaa.Text = ((check.MachineNo % 2 == 1) ? "Vào" : "Ra") + " " + check.Time.ToString("H:mm ddd d/M"); dtpGioMoi_Sua.Value = new DateTime(check.Time.Year, check.Time.Month, check.Time.Day, check.Time.Hour, check.Time.Minute, check.Time.Second); tbCa_Suaa.Tag = (cio == null || cio.HaveINOUT < 0) ? null : cio.ThuocCa; tbCa_Suaa.Text = (cio == null || cio.HaveINOUT < 0) ? string.Empty : cio.ThuocCa.Code; cbLyDo_Suaa.SelectedIndex = 0; tbGhiChu_Suaa.Text = string.Empty; //tồn tại giờ cũ nên cho phép sửa MyUtility.EnableDisableControl(true, btnChonCa_Suaa, btnSuaa); } }
public void XetCa_ListCIO_A3_V6(List <cCheckInOut> ds_CIO_A, List <cCa> DSCa) { try { var i = 0; while (i < ds_CIO_A.Count) { var CIO = ds_CIO_A[i]; #region nếu giờ quên check thì chỉ kiểm tra khoảng hiểu ca if (CIO.CheckVT != TrangThaiCheck.CheckDayDu) { CIO.ThuocNgayCong = ThuocNgayCong(CIO.TimeDaiDien); Tim_DSCa_NhanDienDuoc(CIO.TimeDaiDien, CIO.ThuocNgayCong, CIO.CheckVT, DSCa, out CIO.DSCaNhanDien); i++; continue; } #endregion var ngay = ThuocNgayCong(CIO.TimeDaiDien); CIO.ThuocNgayCong = ngay; bool namTrongDSCa; cCa caNhanDien; KiemtraThuocCa(CIO.Vao.Time, CIO.Raa.Time, CIO.ThuocNgayCong, DSCa, out namTrongDSCa, out caNhanDien); #region nếu thuộc khoảng hiểu ca thì set ca if (namTrongDSCa && caNhanDien.TachCaDem == false) // ko phải ca 3 và 1 { CIO.ThuocCa = caNhanDien; i++; } else if (namTrongDSCa == false) // ko thuộc ca nào -> ca tự do { cCa caTuDo; TaoCaTuDo(int.MinValue, CIO.Vao.Time, out caTuDo); CIO.ThuocCa = caTuDo; i++; } else // trúng ca 3 và 1 thì tách ra 2 ca { #region check inn, check out vao 3 ra 3, vao 1 ra 1 var vaoca3 = CIO.Vao; var raaca3 = new cCheck { Type = "O", MachineNo = 22, Source = "PC", MaCC = CIO.Vao.MaCC, TypeColumn = "O", Time = ngay.Add(GlobalVariables._22h00) }; var vaoca1 = new cCheck { Type = "I", MachineNo = 21, Source = "PC", MaCC = CIO.Raa.MaCC, TypeColumn = "I", Time = ngay.Date.Add(GlobalVariables._6gHomSau).Add(GlobalVariables._01giay), //todo lưu ý ở đây cộng thêm 1 ngày, 1 giây để ko bị trùng check cùng giờ 2 máy }; var raaca1 = CIO.Raa; #endregion bool thuocDSCa3, thuocDSCa1; cCa thuocCa3, thuocCa1, caTuDo3, caTuDo1; ds_CIO_A[i] = new cCheckInOut { Vao = vaoca3, Raa = raaca3, ThuocNgayCong = ngay, TimeDaiDien = vaoca3.Time, }; KiemtraThuocCa(vaoca3.Time, raaca3.Time, ds_CIO_A[i].ThuocNgayCong, DSCa, out thuocDSCa3, out thuocCa3); if (thuocDSCa3) { ds_CIO_A[i].ThuocCa = thuocCa3; } else { TaoCaTuDo(int.MinValue, ds_CIO_A[i].Vao.Time, out caTuDo3); ds_CIO_A[i].ThuocCa = caTuDo3; } var newCIO = new cCheckInOut { Vao = vaoca1, Raa = raaca1, ThuocNgayCong = ngay.AddDays(1d), TimeDaiDien = vaoca1.Time, }; KiemtraThuocCa(vaoca1.Time, raaca1.Time, newCIO.ThuocNgayCong, DSCa, out thuocDSCa1, out thuocCa1); if (thuocDSCa1) { newCIO.ThuocCa = thuocCa1; } else { TaoCaTuDo(int.MinValue, newCIO.Vao.Time, out caTuDo1); newCIO.ThuocCa = caTuDo1; } // vì hàm insert ko cho phép chèn ở vị trí > số lượng phần tử // => nên nếu i là phần tử cuối thì add vào cuối danh sách, ngược lại thì insert vào vị trí i+1 if (i == (ds_CIO_A.Count - 1)) { ds_CIO_A.Add(newCIO); } else { ds_CIO_A.Insert(i + 1, newCIO); } i = i + 2; // +2 vì i là ca3, i+1 là ca 1 } #endregion } } catch (Exception e) { //lg.Error(string.Format("[{0}]_[{1}]\n", "XLChamCong", System.Reflection.MethodBase.GetCurrentMethod().Name), e); } }
private void BoSungGio(cCheckInOut CIO, MayCheck LoaiCheck, TimeSpan gioBoSung, int UEN) { if (CIO.HaveINOUT == -1 && LoaiCheck.ToString() == MayCheck.I.ToString()) { return; // có vào thiếu ra , bổ sung ra thì trùng bỏ qua } if (CIO.HaveINOUT == -2 && LoaiCheck.ToString() == MayCheck.O.ToString()) { return; // có ra thiếu vào, bổ sung vào thì trùng bỏ qua } if (CIO.HaveINOUT == -2) // bổ sung giờ vào cho CIO thiếu vào --> ok { //if (LoaiCheck.ToString() == MayCheck.I.ToString()) /* xác định giờ ra đã có, ngày ra đã có, bỏ phần dư giây giờ bổ sung (vào = 0, ra =1) (hh:mm:00) * tạo NGÀY giờ vào mới để thêm vào CSDL, (nếu vào sau ra thì có qua đêm phải add thêm 1 ngày) */ TimeSpan gioRa = CIO.Raa.Time.TimeOfDay; // xác định giờ ra DateTime ngayGioVaoMoi = CIO.Raa.Time.Date; //ngày gioBoSung = new TimeSpan(gioBoSung.Hours, gioBoSung.Minutes, 0); ngayGioVaoMoi = (gioBoSung >= gioRa) ? ngayGioVaoMoi.AddDays(-1d).Add(gioBoSung).Add(XL2._01giay) // giây = 1 --> hh:mm:01 vào ca sau phải sau ra ca trước : ngayGioVaoMoi.Add(gioBoSung).Add(XL2._01giay); // thêm 1 ngày nếu vào sau ra #region int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName.CheckInOut_Ins.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@TimeDate", ngayGioVaoMoi.Date), new SqlParameter("@TimeStr", ngayGioVaoMoi), new SqlParameter("@OriginType", LoaiCheck.ToString()), new SqlParameter("@MachineNo", (int)LoaiCheck), new SqlParameter("@Source", "PC")); #endregion if (kq == 0) { } } else if (CIO.HaveINOUT == -1) //bổ sung giờ vào cho CIO đã có vào /* xác định giờ vào đã có, ngày ra đã có, bỏ phần dư giây giờ bổ sung (vào = 0, ra =1) (hh:mm:00) * tạo NGÀY giờ vào mới để thêm vào CSDL, () */ { TimeSpan gioVao = CIO.Vao.Time.TimeOfDay; // xác định giờ vào DateTime ngayGioRaaMoi = CIO.Vao.Time.Date; //ngày gioBoSung = new TimeSpan(gioBoSung.Hours, gioBoSung.Minutes, 0); ngayGioRaaMoi = (gioVao >= gioBoSung) ? ngayGioRaaMoi.AddDays(1d).Add(gioBoSung) // giây = 0--> hh:mm:00 ko cần add thêm 1 giây : ngayGioRaaMoi.Add(gioBoSung); // thêm 1 ngày nếu ra trước vào #region int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName.CheckInOut_Ins.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@TimeDate", ngayGioRaaMoi.Date), new SqlParameter("@TimeStr", ngayGioRaaMoi), new SqlParameter("@OriginType", LoaiCheck.ToString()), new SqlParameter("@MachineNo", (int)LoaiCheck), new SqlParameter("@Source", "PC")); #endregion } else { } }
private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) { tbXNGhiChu.Text += string.Format("{0} {1} [action {2}] [controlerRow {3}]", "\n\n", "selection change ", e.Action.ToString(), e.ControllerRow.ToString()); int[] arrayRowHandle = gridView1.GetSelectedRows(); if (arrayRowHandle.Count() == 0) { btnChonCa.Tag = null; btnChonCa.Text = string.Empty; this.m_DaChonCaKhac = false; this.ResetDataOfControl(); } else if (arrayRowHandle.Count() == 1) { if (this.m_DaChonCaKhac == false) // chưa có fill thông tin cũ { DataRow dataRow = gridView1.GetDataRow(arrayRowHandle[0]); cCheckInOut currentCIO = (cCheckInOut)dataRow["cCheckInOut"]; //luôn luôn là CIO đủ vào ra btnChonCa.Tag = currentCIO.ThuocCa; btnChonCa.Text = currentCIO.ThuocCa.Code; lbGioLV.Tag = currentCIO.TG5.TongGioLamViec5; lbGioLV.Text = currentCIO.TG5.TongGioLamViec5.ToString(@"h\:mm"); lbGioCheckVT.Tag = currentCIO.TG5.GioThucTe5; lbGioCheckVT.Text = currentCIO.TG5.GioThucTe5.ToString(@"h\:mm"); lbVaoTre.Tag = currentCIO.TG5.VaoTre; lbVaoTre.Text = currentCIO.TG5.VaoTre.ToString(@"h\:mm"); lbRaaSom.Tag = currentCIO.TG5.RaaSom; lbRaaSom.Text = currentCIO.TG5.RaaSom.ToString(@"h\:mm"); checkChoPhepTre.Checked = currentCIO.DuyetChoPhepVaoTre; checkChoPhepSom.Checked = currentCIO.DuyetChoPhepRaSom; checkVaoTreTinhCV.Checked = currentCIO.VaoTreTinhCV; checkRaaSomTinhCV.Checked = currentCIO.RaaSomTinhCV; lbOLaiChuaXN.Tag = currentCIO.TG5.OLai; lbOLaiChuaXN.Text = currentCIO.TG5.OLai.ToString(@"h\:mm"); if (currentCIO.DaXN && currentCIO.TG5.SoPhutLamThem5 > TimeSpan.Zero) { checkXNLamThem.Checked = true; timeEditXacNhanOT.Tag = currentCIO.TG5.OLai; // giữ object số phút ở lại như là max thời gian làm thêm timeEditXacNhanOT.Time = DateTime.Today.Date.Add(currentCIO.TG5.SoPhutLamThem5); //hiển thị OTMin nếu đã xác nhận, chưa xác nhận thì lấy max ở lại } else { checkXNLamThem.Checked = false; timeEditXacNhanOT.Tag = currentCIO.TG5.OLai; // giữ object số phút ở lại như là max thời gian làm thêm timeEditXacNhanOT.Time = DateTime.Today.Date.Add(currentCIO.TG5.OLai); //hiển thị OTMin nếu đã xác nhận, chưa xác nhận thì lấy max ở lại } tbThongTinKhac.Clear(); //tbd ghi thông khác như công trong ngày..... } else // đã có dùng thông tin ca mới để tính toán { dynamic CaDuocChon = btnChonCa.Tag; float congCaQuyDinh, congTre, congSom, congThucTeTrongCa, congThucTeNgoaiCa, congThucTe, tongCongBu, tongCongTru, dinhMucCong; TimeSpan soPhutLamThemDaXN = (checkXNLamThem.Checked) ? timeEditXacNhanOT.Time.TimeOfDay : TimeSpan.Zero; XL.TinhCong_1_CIO_5(CaDuocChon.Workingday, CaDuocChon.WorkingTime, XL2.TS_Default_PhutChoTre, XL2.TS_Default_PhutChoSom, checkVaoTreTinhCV.Checked, checkRaaSomTinhCV.Checked, soPhutLamThemDaXN, out congCaQuyDinh, out congTre, out congSom, out congThucTeTrongCa, out congThucTeNgoaiCa, out congThucTe, out tongCongBu, out tongCongTru, out dinhMucCong); } } else // chọn multirow, khó tính toán tại chỗ, nên reset hết data và cho phép xem trước trước khi xác nhận { ResetDataOfControl(); if (m_DaChonCaKhac) { return; } else { btnChonCa.Tag = null; btnChonCa.Text = string.Empty; } } }
public static void XacNhan_CIO_A(cUserInfo nv, cCheckInOut CIO, cCa currShift, bool bDuyetCPTre, bool bDuyetCPSom, int soPhutLamThem, bool choPhepTinhPc50, string lydo, string ghichu, bool bVaoTreLaCV, bool bRaaSomLaCV, TS NightTime)//ver 4.0.0.4 { }
private void GhepCIO_A2(List <cCheck> ds_Check_A, List <cCheckInOut> ds_CIO_A) { ds_CIO_A.Clear(); var x = 0; while (x + 1 < ds_Check_A.Count) { var chk_1 = ds_Check_A[x]; var chk_2 = ds_Check_A[x + 1]; if (chk_1.Type == "O") { // đầu ds là checkOut --> ra ko vào var CIO = new cCheckInOut { Vao = null, Raa = chk_1, CheckVT = TrangThaiCheck.ThieuVao, TimeDaiDien = chk_1.Time, }; //tbd bỏ TG = new ThoiGian() xem lại có cần thiết thì giữ lại ds_CIO_A.Add(CIO); x++; } else { //đầu ds là checkInn-> kiểm tra kế nếu cũng là check In thì checkInn trước là vào ko ra if (chk_2.Type == "I") { var CIO = new cCheckInOut { Vao = chk_1, Raa = null, CheckVT = TrangThaiCheck.ThieuRa, TimeDaiDien = chk_1.Time, }; //tbd bỏ TG = new ThoiGian() xem lại có cần thiết thì giữ lại ds_CIO_A.Add(CIO); x++; } else { // kế là checkOut --> kiểm tra nằm trong khoảng >30ph và dưới 21h45 thì ghép, ngược lại thì giờ vào ko ra, ra ko vào var duration = chk_2.Time - chk_1.Time; if (duration > GlobalVariables._22h00) //ver 4.0.0.4 old:(duration > XL2._21h45) { var CIO1 = new cCheckInOut { Vao = chk_1, Raa = null, CheckVT = TrangThaiCheck.ThieuRa, TimeDaiDien = chk_1.Time, }; var CIO2 = new cCheckInOut { Vao = null, Raa = chk_2, CheckVT = TrangThaiCheck.ThieuVao, TimeDaiDien = chk_2.Time, }; ds_CIO_A.Add(CIO1); x++; ds_CIO_A.Add(CIO2); x++; } else { var CIO = new cCheckInOut { Vao = chk_1, Raa = chk_2, CheckVT = TrangThaiCheck.CheckDayDu, TimeDaiDien = chk_1.Time, }; ds_CIO_A.Add(CIO); x++; x++; } } } } // xảy ra 2 TH, 1 là hết ds--> ko làm gì hết, 2 là còn lại 1 pt-> them vào if (x < ds_Check_A.Count) { var chk_1 = ds_Check_A[x]; if (chk_1.Type == "I") { var CIO1 = new cCheckInOut { Vao = chk_1, Raa = null, CheckVT = TrangThaiCheck.ThieuRa, TimeDaiDien = chk_1.Time, }; ds_CIO_A.Add(CIO1); } else { var CIO2 = new cCheckInOut { Vao = null, Raa = chk_1, CheckVT = TrangThaiCheck.ThieuVao, TimeDaiDien = chk_1.Time, }; ds_CIO_A.Add(CIO2); } } }
public static void XetCa_1_CIO_V(cCheckInOut chkInOutV, cShiftSchedule lichtrinh) { }
public static void XetCa_1_CIO_A_KoTachCa(cCheckInOut CIO, cShiftSchedule lichtrinh) { }
public void Insert_CheckInOutData(int UEN, cCheckInOut CIO) { int phut_Vao = 0, phut_Ra = 0, phut_BD_Ca = 0, phut_KT_Ca = 0, phut_BD_LV = 0, phut_KT_LV_TrongCa = 0, phut_KT_LV = 0, phut_BD_LV_Ca3 = 0, phut_KT_LV_Ca3 = 0; int phut_TreVR = 0, phut_SomVR = 0, phut_LamViec = 0, phut_LamDem = 0, phut_OLaiVR = 0, phut_LamTrongGio = 0, phut_LamNgoaiGio = 0, phut_VaoSauCa = 0, phut_RaTruocCa = 0, phut_NghiTrua = 0; float congTrongGio = 0f, congNgoaiGio = 0f, truCongTre = 0f, truCongSom = 0f; bool quaDem = false; string kyHieuCa; if (CIO.CheckVT == TrangThaiCheck.ThieuVao) { kyHieuCa = "KV"; } else if (CIO.CheckVT == TrangThaiCheck.ThieuRa) { kyHieuCa = "KR"; } else { kyHieuCa = CIO.ThuocCa.Code; } if (CIO.CheckVT == TrangThaiCheck.CheckDayDu) { phut_Vao = MyUtility.QuyDoiPhut((CIO.VaoLamTron - CIO.ThuocNgayCong)); phut_Ra = MyUtility.QuyDoiPhut((CIO.RaaLamTron - CIO.ThuocNgayCong)); phut_BD_Ca = MyUtility.QuyDoiPhut(CIO.ThuocCa.Duty.From); phut_KT_Ca = MyUtility.QuyDoiPhut(CIO.ThuocCa.Duty.To); phut_BD_LV = MyUtility.QuyDoiPhut((CIO.BD_LV - CIO.ThuocNgayCong)); phut_KT_LV_TrongCa = MyUtility.QuyDoiPhut((CIO.KT_LV_TrongCa - CIO.ThuocNgayCong)); phut_KT_LV = MyUtility.QuyDoiPhut((CIO.KT_LV - CIO.ThuocNgayCong)); phut_NghiTrua = MyUtility.QuyDoiPhut(CIO.ThuocCa.LunchMin); phut_BD_LV_Ca3 = (CIO.BD_LV_Ca3 == DateTime.MinValue) ? 0 : MyUtility.QuyDoiPhut((CIO.BD_LV_Ca3 - CIO.ThuocNgayCong)); phut_KT_LV_Ca3 = (CIO.KT_LV_Ca3 == DateTime.MinValue) ? 0 : MyUtility.QuyDoiPhut((CIO.KT_LV_Ca3 - CIO.ThuocNgayCong)); phut_TreVR = MyUtility.QuyDoiPhut(CIO.Tre); phut_SomVR = MyUtility.QuyDoiPhut(CIO.Som); phut_VaoSauCa = MyUtility.QuyDoiPhut(CIO.VaoSauCa); phut_RaTruocCa = MyUtility.QuyDoiPhut(CIO.RaTruocCa); congTrongGio = CIO.TrongGio; congNgoaiGio = CIO.NgoaiGio; truCongTre = CIO.TruCongTre; truCongSom = CIO.TruCongSom; quaDem = CIO.QuaDem; } int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName6.CIO_ThemCIOChuaChamCongV6.ToString(), new SqlParameter("@UserEnrollNumber", UEN), new SqlParameter("@NgayCong", CIO.ThuocNgayCong), new SqlParameter("@HaveINOUT", (int)CIO.CheckVT), new SqlParameter("@KyHieuCa", kyHieuCa), //todo thêm ký hiệu ca new SqlParameter("@GioVao", CIO.Vao == null ? (object)DBNull.Value : CIO.Vao.Time), new SqlParameter("@GioRa", CIO.Raa == null ? (object)DBNull.Value : CIO.Raa.Time), new SqlParameter("@Vao", phut_Vao), new SqlParameter("@Ra", phut_Ra), new SqlParameter("@MayVao", CIO.Vao == null ? (object)DBNull.Value : CIO.Vao.MachineNo), new SqlParameter("@MayRa", CIO.Raa == null ? (object)DBNull.Value : CIO.Raa.MachineNo), new SqlParameter("@BDCa", phut_BD_Ca), new SqlParameter("@KTCa", phut_KT_Ca), new SqlParameter("@SoPhutNghiTrua", phut_NghiTrua), new SqlParameter("@BDLV", phut_BD_LV), new SqlParameter("@KTLVTrongCa", phut_KT_LV_TrongCa), new SqlParameter("@KTLV", phut_KT_LV), new SqlParameter("@BDLVCa3", phut_BD_LV_Ca3), new SqlParameter("@KTLVCa3", phut_KT_LV_Ca3), new SqlParameter("@QuaDem", quaDem), new SqlParameter("@Tre", phut_TreVR), new SqlParameter("@Som", phut_SomVR), new SqlParameter("@VaoSauCa", phut_VaoSauCa), new SqlParameter("@RaTruocCa", phut_RaTruocCa), new SqlParameter { ParameterName = "@SoPhutXacNhanNgoaiGio", Value = 0 }, // lần đầu chưa xác nhận nên = 0 new SqlParameter("@ChoPhepTre", CIO.ChoPhepTre), // lần đầu chưa xác nhận nên = false new SqlParameter("@ChoPhepSom", CIO.ChoPhepSom), // lần đầu chưa xác nhận nên = false new SqlParameter("@VaoTuDo", CIO.VaoTuDo), // lần đầu chưa xác nhận nên = false new SqlParameter("@RaTuDo", CIO.RaaTuDo), // lần đầu chưa xác nhận nên = false new SqlParameter { ParameterName = "@TinhCongThuCong", Value = false, }, new SqlParameter { ParameterName = "@ChamCongTay", Value = 0f, }, new SqlParameter("@CongTrongGio", congTrongGio), new SqlParameter("@CongNgoaiGio", congNgoaiGio), new SqlParameter("@TruCongTre", truCongTre), new SqlParameter("@TruCongSom", truCongSom), // new SqlParameter("@DinhMucCong", CIO.DinhMuc), //todo ko lưu // new SqlParameter("@TongCong", CIO.Tong),//todo ko lưu new SqlParameter("@TheoDoiGioGocMayCC", string.Empty)); //todo ghi phần theo dõi// ko có GhiChu, LyDo if (kq == 0) { ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000); } }