コード例 #1
0
        public List <DanhSachCa> DanhSachCa()
        {
            List <DanhSachCa> _listDanhSachCa = new List <DanhSachCa>();

            string _sQuery = "SELECT * FROM DANHSACHCA";

            DataTable _dt = SelectData.Select.ExcuteQuery(_sQuery);

            foreach (DataRow _dr in _dt.Rows)
            {
                DanhSachCa _dsc = new DanhSachCa();

                _dsc.ID         = _dr["ID"].ToString();
                _dsc.Thu        = _dr["THU"].ToString();
                _dsc.GioLam     = _dr["GIOLAM"].ToString();
                _dsc.GioKetThuc = _dr["GIOKETTHUC"].ToString();
                _dsc.CheckCa    = (bool)_dr["CHECKCA"];
                _dsc.IDNhanVien = _dr["IDNHANVIEN"].ToString();

                _listDanhSachCa.Add(_dsc);

                _dsc = null;
            }

            return(_listDanhSachCa);
        }
コード例 #2
0
        public int RemoveNhanVien(string _sId, NgayNghi _nn, DanhSachCa _dsc, CaNghi _cn, LuongTam _lt)
        {
            int _i = 0;

            string _sQuery = "DELETE NHANVIEN WHERE ID = @ID";

            string _sQuery1 = "DELETE NGAYNGHI WHERE IDNHANVIEN = @IDNHANVIEN";

            string _sQuery2 = "DELETE DANHSACHCA WHERE IDNHANVIEN = @IDNHANVIEN";

            string _sQuery3 = "DELETE CANGHI WHERE IDNHANVIEN = @IDNHANVIEN";

            string _sQuery4 = "DELETE LUONGTAM WHERE IDNHANVIEN = @IDNHANVIEN";

            if (_nn != null)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery1, new object[] { _nn.IDNhanVien });
            }

            if (_dsc != null)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery2, new object[] { _dsc.IDNhanVien });
            }

            if (_cn != null)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery3, new object[] { _cn.IDNhanVien });
            }

            _i += SelectData.Select.ExcuteNonQuery(_sQuery4, new object[] { _lt.IDNhanVien });

            return(SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _sId }) + _i);
        }
コード例 #3
0
        public int ChuyenCaThanhNgay(CaNghi _cn, NgayNghi _nn, DanhSachCa _dsc)
        {
            int _i = 0;

            string _sQuery = "INSERT INTO NGAYNGHI VALUES ( @NGAYNGHI , @IDNHANVIEN )";

            string _sQuery1 = "DELETE CANGHI WHERE IDNHANVIEN = @IDNHANVIEN AND NGAYNGHICA = @NGAYNGHICA";

            string _sQuery2 = "UPDATE DANHSACHCA SET CHECKCA = @CHECKCA WHERE ID = @ID AND IDNHANVIEN = @IDNHANVIEN";

            _i += SelectData.Select.ExcuteNonQuery(_sQuery2, new object[] { _dsc.CheckCa, _dsc.ID, _dsc.IDNhanVien });

            _i += SelectData.Select.ExcuteNonQuery(_sQuery1, new object[] { _cn.IDNhanVien, _cn.NgayNghi });

            _i += SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _nn.Ngay, _nn.IDNhanVien });

            return(_i);
        }
コード例 #4
0
        public int RefeshChuyenNgayThanhCa(DanhSachCa _dsc, NgayNghi _nn, List <CaNghi> _listCaNghi)
        {
            int _i = 0;

            string _sQuery = "UPDATE DANHSACHCA SET CHECKCA = @CHECKCA WHERE ID = @ID AND IDNHANVIEN = @IDNHANVIEN";

            string _sQuery1 = "DELETE NGAYNGHI WHERE NGAYNGHI = @NGAYNGHI AND IDNHANVIEN = @IDNHANVIEN";

            string _sQuery2 = "INSERT INTO CANGHI VALUES ( @NGAYNGHICA , @GIOLAM , @IDNHANVIEN )";

            _i += SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _dsc.CheckCa, _dsc.ID, _dsc.IDNhanVien });

            _i += SelectData.Select.ExcuteNonQuery(_sQuery1, new object[] { _nn.Ngay, _nn.IDNhanVien });

            foreach (CaNghi _cn in _listCaNghi)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery2, new object[] { _cn.NgayNghi, _cn.GioLam, _cn.IDNhanVien });
            }

            return(_i);
        }
コード例 #5
0
        public int DiemDanhCa(DanhSachCa _dsc, CaNghi _cn, bool _bCheckCa)
        {
            string _sQuery = "INSERT INTO CANGHI VALUES ( @NGAYNGHICA , @GIOLAM , @IDNHANVIEN )";

            string _sQuery1 = "DELETE CANGHI WHERE NGAYNGHICA = @NGAYNGHICA AND GIOLAM = @GIOLAM AND IDNHANVIEN = @IDNHANVIEN";

            string _sQuery2 = "UPDATE DANHSACHCA SET CHECKCA = @CHECKCA WHERE IDNHANVIEN = @IDNHANVIEN AND ID = @ID";

            int _i = 0;

            _i += SelectData.Select.ExcuteNonQuery(_sQuery2, new object[] { _dsc.CheckCa, _dsc.IDNhanVien, _dsc.ID });

            if (_bCheckCa == false)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _cn.NgayNghi, _cn.GioLam, _cn.IDNhanVien });
            }

            if (_bCheckCa == true)
            {
                _i += SelectData.Select.ExcuteNonQuery(_sQuery1, new object[] { _cn.NgayNghi, _cn.GioLam, _cn.IDNhanVien });
            }

            return(_i);
        }
コード例 #6
0
        public int DiemDanhNgay(DanhSachCa _dsc, NgayNghi _nn, bool _bCheckCa)
        {
            int _i = 0;

            string _sQuery = "UPDATE DANHSACHCA SET CHECKCA = @CHECKCA WHERE ID = @ID AND IDNHANVIEN = @IDNHANVIEN";

            _i += SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _dsc.CheckCa, _dsc.ID, _dsc.IDNhanVien });

            if (_bCheckCa == false)
            {
                string _sQuery1 = "INSERT INTO NGAYNGHI VALUES ( @NGAYNGHI , @IDNHANVIEN )";

                _i += SelectData.Select.ExcuteNonQuery(_sQuery1, new object[] { _nn.Ngay, _nn.IDNhanVien });
            }

            if (_bCheckCa == true)
            {
                string _sQuery2 = "DELETE NGAYNGHI WHERE IDNHANVIEN = @IDNHANVIEN";

                _i += SelectData.Select.ExcuteNonQuery(_sQuery2, new object[] { _nn.IDNhanVien });
            }

            return(_i);
        }
コード例 #7
0
    /// <summary>
    /// Hàm tính toán tổng hợp công
    /// </summary>
    /// <param name="lists">Danh sách thông tin chấm công cần tính</param>
    /// <param name="isNew"><b>true</b> nếu tổng hợp mới, <b>false</b> nếu cập nhật lại</param>
    private string TinhToanThongTinCong(List <TongHopCongTheoThangInfo> lists, bool isNew)
    {
        try
        {
            TimeController timeController = new TimeController();
            string         error          = "";
            #region lấy các cấu hình cho tổng hợp công
            // lấy các ngày cuối tuần trong tháng
            List <string> listWeekend = timeController.GetWeekKend(Session["MaDonVi"].ToString());

            // lấy danh sách chấm công đặc biệt
            Dictionary <string, int> dicSpecialEmployee = new Dictionary <string, int>();

            List <DAL.DanhSachNhanVienChamCongDacBiet> listEmployees = new DieuKienChamCongDacBietController().GetByAll();
            foreach (var item in listEmployees)
            {
                dicSpecialEmployee.Add(item.MaCB, item.SoLanChitTay);
            }
            // lấy ngày công chuẩn
            //double ngayCongChuan = timeController.GetNumberDayOfWork();
            #endregion

            // lấy tháng
            DAL.DanhSachBangTongHopCong thcong = new DanhSachBangTongHopCongController().GetById(int.Parse(hdfIdBangTongHopCong.Text));
            //int maxDays = 31;//DateTime.DaysInMonth(thcong.Nam, thcong.Thang);
            int tong = 0;

            foreach (var item in lists)
            {
                try
                {
                    tong++;
                    #region các tham biến
                    double tongGioCongDinhMuc = 0, tongGioCongThucTe = 0;
                    int    tongPhutDiTre = 0, tongPhutVeSom = 0, tongSoPhutLamThuaGio = 0;
                    int    tongSoPhutLamThemNgayThuong = 0, tongSoPhutLamThemNgayNghi = 0, tongSoPhutLamThemNgayLe = 0;
                    double nghiLe = 0, nghiPhep = 0, nghiCheDo = 0, nghiBu = 0, nghiKhongLuong = 0;
                    int    tongSoLamQuenQuetThe = 0, tongSoLanDiMuon = 0, tongSoLanVeSom = 0;
                    string ngayLe = "", thongKeCaLamViec = "";
                    float  tongCaLamViecNgayThuong = 0, tongCaLamViecNgayNghi = 0, tongCaLamViecNgayLe = 0, tongThoiGianRaNgoaiBiTruGio = 0, tongCaNghi = 0;
                    bool   isFail = false;
                    int    soLanChitTayBatBuoc = -1;

                    if (dicSpecialEmployee.ContainsKey(item.MA_CB))
                    {
                        soLanChitTayBatBuoc = dicSpecialEmployee[item.MA_CB];
                    }

                    // thống kê ca làm việc định dạng MaCa1=a,MaCa2=b
                    Dictionary <string, int> dicThongKeCaLamViec = new Dictionary <string, int>();
                    #endregion

                    // tính toán các ngày nghỉ
                    //if (soLanChitTayBatBuoc == -1)
                    new TongHopCongController().GetNgayNghi(item.MA_CB, thcong.FromDate, thcong.ToDate, ref ngayLe, ref nghiLe, ref nghiPhep,
                                                            ref nghiCheDo, ref nghiBu, ref nghiKhongLuong, Session["MaDonVi"].ToString());

                    DateTime day = thcong.FromDate;
                    while (day <= thcong.ToDate)
                    {
                        #region tổng hợp thông tin trong một ngày
                        try
                        {
                            #region các biến cục bộ
                            double gioCongDinhMuc = 0, gioCongThucTe = 0;
                            int    soPhutDiTre = 0, soPhutVeSom = 0, soPhutDiSom = 0, soPhutVeMuon = 0;
                            int    soPhutLamThemNgayThuong = 0, soPhutLamThemNgayNghi = 0, soPhutLamThemNgayLe = 0, soPhutLamThuaGio = 0;
                            int    soLanQuenQuetThe = 0, soLanDiMuon = 0, soLanVeSom = 0;
                            float  soCaLamViecNgayThuong = 0, soCaLamViecNgayNghi = 0, soCaLamViecNgayLe = 0, thoiGianRaNgoaiBiTruGio = 0, soCaNghi = 0;
                            string thoiGianDiFirst = "", thoiGianVeLast = "";

                            DAL.DanhSachCa ca = new DanhSachCa();
                            #endregion

                            try
                            {
                                // lấy ca làm việc của cán bộ
                                ca = new DanhSachCaController().GetByMaChamCong(item.MaChamCong, day, Session["MaDonVi"].ToString());

                                #region cập nhật thống kê ca làm việc
                                if (ca == null)
                                {
                                    continue;
                                }
                                #endregion

                                // tính các tham số liên quan
                                if (soLanChitTayBatBuoc == -1)
                                {
                                    new TongHopCongController().GetCaLamViecTrongNgay(ngayLe.Split(','), listWeekend, item.MaChamCong, day, ca, ref dicThongKeCaLamViec,
                                                                                      ref gioCongDinhMuc, ref gioCongThucTe, ref soPhutDiTre, ref soPhutVeSom, ref soPhutDiSom, ref soPhutVeMuon,
                                                                                      ref soPhutLamThemNgayThuong, ref soPhutLamThemNgayNghi, ref soPhutLamThemNgayLe,
                                                                                      ref soLanQuenQuetThe, ref soLanDiMuon, ref soLanVeSom, ref soPhutLamThuaGio,
                                                                                      ref soCaLamViecNgayThuong, ref soCaLamViecNgayNghi, ref soCaLamViecNgayLe, ref thoiGianRaNgoaiBiTruGio, ref soCaNghi,
                                                                                      ref thoiGianDiFirst, ref thoiGianVeLast);

                                    //new TongHopCongController().GetCaLamViecTrongNgay1(ngayLe.Split(','), listWeekend, item.MaChamCong, day, ca, ref gioCongDinhMuc,
                                    //    ref gioCongThucTe, ref soPhutDiTre, ref soPhutVeSom, ref thoiGianDiFirst, ref thoiGianVeLast, ref thoiGianRaNgoaiBiTruGio,
                                    //    ref soLanDiMuon, ref soLanVeSom);
                                }
                                else
                                {
                                    List <DAL.VaoRaCa> dsVaoRaCa = new VaoRaCaController().GetByMaChamCongAndDay(item.MaChamCong, day);

                                    if (dsVaoRaCa.Count >= soLanChitTayBatBuoc)
                                    {
                                        //gioCongDinhMuc += ca.TongGio != null ? ca.TongGio.Value : 0;
                                        //gioCongThucTe += (ca.TongGio != null ? ca.TongGio.Value : 0) * 60;
                                        if (ca.NghiGiuaCa != "" && ca.VaoGiuaCa != "")
                                        {
                                            gioCongThucTe         += 1;
                                            soCaLamViecNgayThuong += 1;
                                        }
                                        else
                                        {
                                            gioCongThucTe         += 0.5;
                                            soCaLamViecNgayThuong += (float)0.5;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                isFail = true;
                                error += ex.Message + "<br />";
                            }

                            #region tính các thời gian liên quan
                            DAL.TongHopCongTheoNgay theoNgay = new TongHopCongTheoNgay();
                            theoNgay.MaCa       = ca.MaCa;
                            theoNgay.MaChamCong = item.MaChamCong;
                            theoNgay.NgayThang  = day;
                            //theoNgay.SoLanDiMuon = soLanDiMuon;
                            //theoNgay.SoLanVeSom = soLanVeSom;
                            //theoNgay.SoNgayCong = Math.Round((gioCongThucTe / ca.TongGio == 0 ? 1 : ca.TongGio), 1);
                            theoNgay.SoPhutDiMuon = soPhutDiTre;
                            //theoNgay.SoPhutDiSom = soPhutVeSom;
                            //theoNgay.SoPhutLamThemNgayLe = soPhutLamThemNgayLe;
                            //theoNgay.SoPhutLamThemNgayNghi = soPhutLamThemNgayNghi;
                            //theoNgay.SoPhutLamThemNgayThuong = soPhutLamThemNgayThuong;
                            //theoNgay.SoPhutLamThuaGio = soPhutLamThuaGio;
                            //theoNgay.SoPhutLamViec = gioCongThucTe;
                            //theoNgay.SoPhutRaNgoai =
                            //tongGioCongDinhMuc += gioCongDinhMuc;
                            //tongGioCongThucTe += gioCongThucTe;
                            //tongPhutDiTre += soPhutDiTre;
                            //tongPhutVeSom += soPhutVeSom;
                            //tongSoPhutLamThemNgayThuong += soPhutLamThemNgayThuong;
                            //tongSoPhutLamThemNgayNghi += soPhutLamThemNgayNghi;
                            //tongSoPhutLamThemNgayLe += soPhutLamThemNgayLe;
                            //tongSoLamQuenQuetThe += soLanQuenQuetThe;
                            //tongSoLanDiMuon += soLanDiMuon;
                            //tongSoLanVeSom += soLanVeSom;
                            //tongSoPhutLamThuaGio += soPhutLamThuaGio;

                            //tongCaLamViecNgayThuong += soCaLamViecNgayThuong;
                            //tongCaLamViecNgayNghi += soCaLamViecNgayNghi;
                            //tongCaLamViecNgayLe += soCaLamViecNgayLe;
                            //tongThoiGianRaNgoaiBiTruGio += thoiGianRaNgoaiBiTruGio;
                            //tongCaNghi += soCaNghi;
                            #endregion

                            day.AddDays(1);
                        }
                        catch (Exception ex)
                        {
                            error += ex.Message + "<br />";
                        }
                        #endregion
                    }

                    // thống kê số ca làm việc của từng cán bộ
                    if (soLanChitTayBatBuoc == -1)
                    {
                        thongKeCaLamViec = new TongHopCongController().GetThongKeCaLamViec(dicThongKeCaLamViec);
                    }

                    #region Cập nhật vào bảng tổng hợp công
                    //DAL.TongHopCong cong = new TongHopCong()
                    //{
                    //    MA_CB = item.MA_CB,
                    //    IdDanhSachBangTongHopCong = int.Parse(hdfIdBangTongHopCong.Text),
                    //    SoPhutDiTre = tongPhutDiTre,
                    //    SoPhutLamThemNgayLe = tongSoPhutLamThemNgayLe,
                    //    SoPhutLamThemNgayNghi = tongSoPhutLamThemNgayNghi,
                    //    SoPhutLamThemNgayThuong = tongSoPhutLamThemNgayThuong,
                    //    GioCongThucTe = tongGioCongThucTe,  // tính theo phút
                    //    GioCongDinhMuc = tongGioCongDinhMuc,
                    //    SoPhutVeSom = tongPhutVeSom,
                    //    NghiBu = nghiBu,
                    //    NghiKhongLuong = nghiKhongLuong,
                    //    NghiCheDo = nghiCheDo,
                    //    NghiLe = nghiLe,
                    //    NghiPhep = nghiPhep,
                    //    TinhToanSai = isFail,
                    //    SoLanQuenQuetThe = tongSoLamQuenQuetThe,
                    //    SoLanDiTre = tongSoLanDiMuon,
                    //    SoLanVeSom = tongSoLanVeSom,
                    //    TongThoiGianLamThuaGio = tongSoPhutLamThuaGio,
                    //    ThongKeCaLamViec = thongKeCaLamViec,
                    //    TongCaLamViecNgayThuong = tongCaLamViecNgayThuong,
                    //    TongCaLamViecNgayNghi = tongCaLamViecNgayNghi,
                    //    TongCaLamViecNgayLe = tongCaLamViecNgayLe,
                    //    ThoiGianRaNgoaiBiTru = tongThoiGianRaNgoaiBiTruGio,
                    //    TongCaNghi = tongCaNghi,
                    //};
                    //if (isNew == true)
                    //{
                    //    new TongHopCongController().Insert(cong);
                    //}
                    //else
                    //{
                    //    cong.ID = item.ID;
                    //    new TongHopCongController().Update(cong);
                    //}
                    #endregion
                }
                catch (Exception ex)
                {
                    error += ex.Message + "<br />";
                }
            }
            X.Msg.Alert("", error).Show();
            return("");
        }
        catch (Exception ex)
        {
            X.Msg.Alert("Thông báo từ hệ thống", ex.Message).Show();
            return(ex.Message);
        }
    }
コード例 #8
0
        public int EditCa(DanhSachCa _dsc)
        {
            string _sQuery = "UPDATE DANHSACHCA SET GIOLAM = @GIOLAM , GIOKETTHUC = @GIOKETTHUC , CHECKCA = @CHECKCA , IDNHANVIEN = @IDNHANVIEN WHERE ID = @ID";

            return(SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _dsc.GioLam, _dsc.GioKetThuc, _dsc.CheckCa, _dsc.IDNhanVien, _dsc.ID, }));
        }
コード例 #9
0
        public int RemoveCa(DanhSachCa _dsc)
        {
            string _sQuery = "DELETE DANHSACHCA WHERE ID = @ID AND IDNHANVIEN = @IDNHANVIEN";

            return(SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _dsc.ID, _dsc.IDNhanVien }));
        }
コード例 #10
0
        public int ThemCa(DanhSachCa _dsc)
        {
            string _sQuery = "INSERT INTO DANHSACHCA VALUES ( dbo.FCTHEMCA() , @THU , @GIOLAM , @GIOKETTHUC , @CHECKCA , @IDNHANVIEN )";

            return(SelectData.Select.ExcuteNonQuery(_sQuery, new object[] { _dsc.Thu, _dsc.GioLam, _dsc.GioKetThuc, _dsc.CheckCa, _dsc.IDNhanVien }));
        }