protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) { switch (e.Item.Value) { case "Save": if (txtDenNgay.SelectedDate == null || txtTuNgay.SelectedDate <= txtDenNgay.SelectedDate) { if (iDNghi == null) { Nghi ng = new Nghi(); ng.IDNhanVien = userid; ng.IDLoaiNghi = Convert.ToInt32(cboLoaiNghi.SelectedValue); ng.TuNgay = txtTuNgay.SelectedDate; ng.DenNgay = txtDenNgay.SelectedDate; if (lbSoNgayXinNghi.Text != "") { ng.SoNgayDaNghi = Convert.ToInt32(lbSoNgayXinNghi.Text); } ng.LyDoNghi = txtLyDo.Text; ng.DuocNghi = null; if (cboNhanVienBanGiao.SelectedValue == "") { ng.IDNhanVienBanGiao = null; } else { ng.IDNhanVienBanGiao = Convert.ToInt32(cboNhanVienBanGiao.SelectedValue); } ng.NguoiTao = ng.NguoiCapNhat = userid; ng.NgayTao = ng.NgayCapNhat = DateTime.Now; _entities.AddToNghis(ng); _entities.SaveChanges(); grvNghi.Rebind(); RadWindowManager1.RadAlert("Thêm thông tin thành công", 285, 100, "Thông báo", null); } else { Nghi ng = _entities.Nghis.Where(d => d.IDNghiPhep == iDNghi).First(); if (ng.DuocNghi == null) { ng.IDLoaiNghi = Convert.ToInt32(cboLoaiNghi.SelectedValue); ng.TuNgay = txtTuNgay.SelectedDate; ng.DenNgay = txtDenNgay.SelectedDate; if (lbSoNgayXinNghi.Text != "") { ng.SoNgayDaNghi = Convert.ToInt32(lbSoNgayXinNghi.Text); } ng.LyDoNghi = txtLyDo.Text; if (cboNhanVienBanGiao.SelectedValue == "") { ng.IDNhanVienBanGiao = null; } else { ng.IDNhanVienBanGiao = Convert.ToInt32(cboNhanVienBanGiao.SelectedValue); } ng.NguoiCapNhat = userid; ng.NgayCapNhat = DateTime.Now; _entities.SaveChanges(); grvNghi.Rebind(); RadWindowManager1.RadAlert("Sửa thông tin thành công", 285, 100, "Thông báo", null); } } } else { lbSoNgayXinNghi.Text = "Lỗi: thời gian xin nghỉ không hợp lý"; } break; case "Reset": cboLoaiNghi.SelectedIndex = -1; cboNhanVienBanGiao.SelectedIndex = -1; txtTuNgay.Clear(); txtDenNgay.Clear(); lbSoNgayXinNghi.Text = ""; txtLyDo.Text = ""; lbSoNgayXinNghi.Text = ""; iDNghi = null; ToogleControl(null); break; case "Report": RadWindowManager1.RadAlert("Chức năng chưa hoàn thiện", 285, 100, "Lỗi", ""); break; } }