private bool IsLookLichHoc(GridView view, int row)
        {
            bool result = false;

            try
            {
                GridColumn col           = view.Columns["XepLichHocId"];
                int        _XepLichHocId = O2S_Common.TypeConvert.Parse.ToInt32(view.GetRowCellValue(row, col).ToString());
                //kiem tra trong DB xem da khoa hay khong
                XEPLICHHOC _lichhoc = XepLichHocLogic.SelectSingle(_XepLichHocId);
                if (_lichhoc != null && _lichhoc.IsLock == true)
                {
                    result = true;
                }
                foreach (var item in this.lstLichHoc)
                {
                    if (item.XepLichHocId == _XepLichHocId && item.IsEdit == true)
                    {
                        result = false;
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
            return(result);
        }
 private void btnKhoaLichHoc_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn sẵn sàng lên lịch học?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             List <XEPLICHHOC> _lstLichHoc = XepLichHocLogic.SelectTheoLopHoc(this.LopHocId_Select);
             if (XepLichHocLogic.UpdateKhoaLichHoc(_lstLichHoc))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                 frmthongbao.Show();
                 btnTimKiem_Click(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(O2S_Common.Utilities.ThongBao.WaitForm_Wait));
            try
            {
                DataGridView_ResetLaiCot();

                int _KhoaHocId = O2S_Common.TypeConvert.Parse.ToInt32(cboKhoaHoc.SelectedValue.ToString());
                int _LopHocId  = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString());

                if (_KhoaHocId != 0 && _LopHocId != 0)
                {
                    XepLichHocFilter _filter = new XepLichHocFilter();
                    _filter.LopHocId = _LopHocId;
                    List <XepLichHoc_PlusDTO> _lstNgayHoc = XepLichHocLogic.SelectGroupTheoNgayHoc(_filter);
                    if (_lstNgayHoc != null && _lstNgayHoc.Count > 0)
                    {
                        foreach (var item in _lstNgayHoc)
                        {
                            item.ThoiGianHoc_Long = item.ThoiGianHoc.ToString("yyyyMMdd");
                        }
                        TaoCot_DataGridView(_lstNgayHoc);
                        LayDuLieuLenGridView(_lstNgayHoc, _LopHocId, _KhoaHocId);
                    }
                }
                else
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN);
                    frmthongbao.Show();
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
            SplashScreenManager.CloseForm();
        }
        //
        private void LoadLichHocCuaLopHoc(int _lophocId)
        {
            try
            {
                //Kiem tra xem co lich hoc chua
                //-Neu co hien thi len
                //--neu chua insert 1 dong new
                XepLichHocFilter _filter = new XepLichHocFilter();
                _filter.LopHocId = _lophocId;
                this.lstLichHoc  = XepLichHocLogic.Select(_filter);
                if (this.lstLichHoc != null && this.lstLichHoc.Count > 0)
                {
                    for (int i = 0; i < this.lstLichHoc.Count; i++)
                    {
                        this.lstLichHoc[i].Stt = i + 1;
                    }
                }
                else
                {
                    XepLichHoc_PlusDTO _lichhoc = new XepLichHoc_PlusDTO()
                    {
                        Stt       = 1,
                        CoSoId    = GlobalSettings.CoSoId,
                        LopHocId  = _lophocId,
                        TenLopHoc = cboLopHoc.Text,
                    };
                    this.lstLichHoc = new List <XepLichHoc_PlusDTO>();
                    this.lstLichHoc.Add(_lichhoc);
                }

                gridControlLichHoc.DataSource = this.lstLichHoc;
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 private void gridViewLichHoc_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
 {
     try
     {
         if (e.MenuType == GridMenuType.Row)
         {
             e.Menu.Items.Clear();
             var        rowHandle     = gridViewLichHoc.FocusedRowHandle;
             int        _XepLichHocId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewLichHoc.GetRowCellValue(rowHandle, "XepLichHocId").ToString());
             XEPLICHHOC _lichhoc      = XepLichHocLogic.SelectSingle(_XepLichHocId);
             if (_lichhoc != null && _lichhoc.IsLock == true)
             {
                 DXMenuItem item_sualich = new DXMenuItem("Sửa lịch học");
                 item_sualich.Image  = imMenu.Images[0];
                 item_sualich.Click += new EventHandler(repositoryItemButton_SuaLichHoc_Click);
                 e.Menu.Items.Add(item_sualich);
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.LopHocId_Select != 0)
                {
                    //Xoa di het roi insert lai
                    if (XepLichHocLogic.DeleteTheoLopHoc(this.LopHocId_Select))
                    {
                        List <XEPLICHHOC> _lstInsert = new List <XEPLICHHOC>();
                        foreach (var item in this.lstLichHoc)
                        {
                            var culture       = new System.Globalization.CultureInfo("vi-VN");
                            var day_tiengViet = culture.DateTimeFormat.GetDayName(item.ThoiGianHoc.DayOfWeek);

                            ValidateLuu(item);
                            CAHOC      _cahoc       = CaHocLogic.SelectSingle(item.CaHocId ?? 0);
                            PHONGHOC   _phonghoc    = PhongHocLogic.SelectSingle(item.PhongHocId ?? 0);
                            GIANGVIEN  _gv_chinh    = GiangVienLogic.SelectSigleTheoKhoaKhoa(item.GiaoVien_ChinhId ?? 0);
                            GIANGVIEN  _gv_trogiang = GiangVienLogic.SelectSigleTheoKhoaKhoa(item.GiaoVien_TroGiangId ?? 0);
                            XEPLICHHOC _xeplich     = new XEPLICHHOC()
                            {
                                CoSoId                = GlobalSettings.CoSoId,
                                KhoaHocId             = this.KhoaHocId_Select,
                                LopHocId              = this.LopHocId_Select,
                                TenLopHoc             = cboLopHoc.Text,
                                ThoiGianHoc           = item.ThoiGianHoc,
                                ThoiGianHoc_Full      = day_tiengViet + " - " + item.ThoiGianHoc.ToString("dd/MM/yyyy"),
                                CaHocId               = item.CaHocId,
                                TenCaHocFull          = _cahoc != null ? _cahoc.TenCaHocFull : "",
                                PhongHocId            = item.PhongHocId,
                                TenPhongHoc           = _phonghoc != null ? _phonghoc.TenPhongHoc : "",
                                GiaoVien_ChinhId      = item.GiaoVien_ChinhId,
                                TenGiaoVien_Chinh     = _gv_chinh != null ? _gv_chinh.TenGiangVien : "",
                                TienGiaoVien_Chinh    = item.TienGiaoVien_Chinh,
                                GiaoVien_TroGiangId   = item.GiaoVien_TroGiangId,
                                TenGiaoVien_TroGiang  = _gv_trogiang != null ? _gv_trogiang.TenGiangVien : "",
                                TienGiaoVien_TroGiang = item.TienGiaoVien_TroGiang,
                                GhiChu                = item.GhiChu,
                                IsLock                = item.IsLock,
                            };
                            _lstInsert.Add(_xeplich);
                        }
                        if (XepLichHocLogic.InsertMultiRow(_lstInsert))
                        {
                            //Thread.Sleep(2500);
                            O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                            frmthongbao.Show();
                            LoadLichHocCuaLopHoc(this.LopHocId_Select);
                        }
                        else
                        {
                            O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                            frmthongbao.Show();
                        }
                    }
                    else
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                        frmthongbao.Show();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }