コード例 #1
0
        private int CalculDayOFFNoTakeLeave()
        {
            int resultOFFDayNoTakeLeave = 0;
            List <fnDisplayOFFDayFollowCondition_Result> tmpLstOFFDayOf = data.fnDisplayOFFDayFollowCondition(
                new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1),
                new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1).AddMonths(1).AddDays(-1),
                data.NHANSUs.Find(this.ID).HoVaTen).ToList();

            //Tinh toan hien thi so ngay nghi co phep trong thang
            foreach (var tmp in tmpLstOFFDayOf)
            {
                if (tmp.ID_LoaiNgayNghi != 1 && tmp.ID_LoaiNgayNghi != 2)
                {
                    DateTime tmpStart = (tmp.NgayBatDau.Value < new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1) ? new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1) : tmp.NgayBatDau.Value);
                    DateTime tmpEnd   = (tmp.NgayKetThuc.Value > new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1).AddMonths(1).AddDays(-1) ? new DateTime(this.ThangNam.Year, this.ThangNam.Month, 1).AddMonths(1).AddDays(-1) : tmp.NgayKetThuc.Value);
                    resultOFFDayNoTakeLeave = resultOFFDayNoTakeLeave + Weekdays(tmpStart, tmpEnd);
                }
            }
            return(resultOFFDayNoTakeLeave);
        }
コード例 #2
0
 public void LoadData()
 {
     if (this.txtSearchName.Text == "họ và tên ....")
     {
         this.listOFFStaff = data.fnDisplayOFFDayFollowCondition(this.txtNgayBatDau.Value, this.txtNgayKetThuc.Value, "").ToList();
     }
     else
     {
         this.listOFFStaff = data.fnDisplayOFFDayFollowCondition(this.txtNgayBatDau.Value, this.txtNgayKetThuc.Value, this.txtSearchName.Text).ToList();
     }
     this.bunifuCustomDataGrid1.Rows.Clear();
     for (int i = 0; i < this.listOFFStaff.Count; i++)
     {
         this.bunifuCustomDataGrid1.Rows.Add(i + 1,
                                             this.listOFFStaff[i].UserName,
                                             this.listOFFStaff[i].HoVaTen,
                                             this.listOFFStaff[i].NgayBatDau.Value.Minute == 00 && this.listOFFStaff[i].NgayBatDau.Value.Hour == 00 ?
                                             this.listOFFStaff[i].NgayBatDau.Value.ToString("dd/MM/yyyy") : this.listOFFStaff[i].NgayBatDau.Value.ToString("dd/MM/yyyy - [HH:mm]"),
                                             this.listOFFStaff[i].NgayKetThuc.Value.Minute == 00 && this.listOFFStaff[i].NgayKetThuc.Value.Hour == 00 ?
                                             this.listOFFStaff[i].NgayKetThuc.Value.ToString("dd/MM/yyyy ") : this.listOFFStaff[i].NgayKetThuc.Value.ToString("dd/MM/yyyy - [HH:mm]"),
                                             this.listOFFStaff[i].LyDo);
     }
 }
コード例 #3
0
            private int CalculateTotalOFFDayInWeekdays(int ID, DateTime start, DateTime end)
            {
                int result = 0;
                List <fnDisplayOFFDayFollowCondition_Result> tmp = data.fnDisplayOFFDayFollowCondition(start, end, data.NHANSUs.Find(ID).HoVaTen).ToList();

                foreach (var item in tmp)
                {
                    if (item.ID_LoaiNgayNghi != 1 && item.ID_LoaiNgayNghi != 2)
                    {
                        DateTime startDay = (item.NgayBatDau.Value < start ? start : item.NgayBatDau.Value);
                        DateTime endDay   = (item.NgayKetThuc.Value > end ? end : item.NgayKetThuc.Value);
                        result = result + Weekdays(startDay, endDay);
                    }
                }
                return(result);
            }