public static bool Update(XEPLICHHOC _hocVien, TAIKHOAN taiKhoan = null)
        {
            try
            {
                var hocVienCu = SelectSingle(_hocVien.XepLichHocId);

                hocVienCu.ThoiGianHoc           = _hocVien.ThoiGianHoc;
                hocVienCu.CaHocId               = _hocVien.CaHocId;
                hocVienCu.TenCaHocFull          = _hocVien.TenCaHocFull;
                hocVienCu.GiaoVien_ChinhId      = _hocVien.GiaoVien_ChinhId;
                hocVienCu.TenGiaoVien_Chinh     = _hocVien.TenGiaoVien_Chinh;
                hocVienCu.TienGiaoVien_Chinh    = _hocVien.TienGiaoVien_Chinh;
                hocVienCu.GiaoVien_TroGiangId   = _hocVien.GiaoVien_TroGiangId;
                hocVienCu.TenGiaoVien_TroGiang  = _hocVien.TenGiaoVien_TroGiang;
                hocVienCu.TienGiaoVien_TroGiang = _hocVien.TienGiaoVien_TroGiang;
                hocVienCu.GhiChu       = _hocVien.GhiChu;
                hocVienCu.IsRemove     = _hocVien.IsRemove;
                hocVienCu.ModifiedDate = DateTime.Now;
                hocVienCu.ModifiedBy   = GlobalSettings.UserCode;
                hocVienCu.ModifiedLog  = GlobalSettings.SessionMyIP;
                Database.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        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);
        }
        public static bool Insert(XEPLICHHOC _xeplichhoc, ref int _xeplichhocId)
        {
            try
            {
                _xeplichhoc.CreatedDate = DateTime.Now;
                _xeplichhoc.CreatedBy   = GlobalSettings.UserCode;
                _xeplichhoc.CreatedLog  = GlobalSettings.SessionMyIP;
                _xeplichhoc.IsRemove    = 0;
                Database.XEPLICHHOCs.InsertOnSubmit(_xeplichhoc);
                Database.SubmitChanges();
                _xeplichhocId = _xeplichhoc.XepLichHocId;
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);

                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);
            }
        }