private void gridViewSupport_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (e.Column == ColAction) { if (mAccount.IsSuperUser == true) { DialogResult opt = MessageBox.Show("Bạn chắc chắn muốn xóa nội dung này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opt == DialogResult.Yes) { int idcomment = 0; int.TryParse("" + gridViewSupport.GetFocusedRowCellValue("Id"), out idcomment); if (idcomment > 0) { CommentSupport oComment = new CommentSupport { Id = idcomment }; bool isResult = new CommentSupportBll(mAccount).DeleteElement(oComment); if (isResult) { foreach (CommentSupport o in mLisCommentSupport) { if (oComment.Id == o.Id) { mLisCommentSupport.Remove(o); break; } } } RefeshListCommentSupport(sender, e); } } } else { MessageBox.Show("Bạn không có quền xóa dữ liệu này. Vui lòng liên hệ người Quản lý của bạn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
private void btnAdd_Click(object sender, EventArgs e) { msgMessage.Clear(); string Id = "" + mStudentLists.Id; if (btnAdd.Text.Equals("Thêm")) { btnSua.Text = "Hủy Bỏ"; btnSua.Enabled = true; btnSua.Image = eCenterTrainning.Properties.Resources.deleted; btnAdd.Text = "Lưu Lại"; btnAdd.Image = eCenterTrainning.Properties.Resources.save; isAction = true; //TH Thêm dateEditSupport.Enabled = true; richTextBoxContent.ReadOnly = false; richTextBoxContent.Text = ""; dateEditSupport.EditValue = DateTime.Now; gridControlSupport.Enabled = false; lookUpEditCourse.Enabled = true; } else { if (isAction) { //Flag > 0 : Insert & Flag <= 0 : Update CommentSupport oCommentSupport = new CommentSupport { CommentName = lookUpEditCourse.Text, UserId = mAccount.UserId, UserName = mAccount.UserName, Desription = richTextBoxContent.Text, StudentId = mStudentLists.Id, DateCreate = DateTime.Now }; oCommentSupport.DateLastUpdate = DateTime.Now.ToLocalTime(); oCommentSupport.Flag = 1; //Thêm bool isResult = new CommentSupportBll(mAccount).InsertAndUpdateElement(oCommentSupport); if (isResult) { if (mLisCommentSupport == null) { mLisCommentSupport = new List <CommentSupport>(); } mLisCommentSupport.Insert(0, oCommentSupport); } } else { CommentSupport oCommentSupport = null; foreach (CommentSupport oComment in mLisCommentSupport) { if (mCommentSupport.Id == oComment.Id) { oCommentSupport = oComment; mLisCommentSupport.Remove(oComment); break; } } oCommentSupport.Flag = 0; //Cập nhật oCommentSupport.Desription = richTextBoxContent.Text; oCommentSupport.UserId = mAccount.UserId; oCommentSupport.UserName = mAccount.UserName; oCommentSupport.CommentName = lookUpEditCourse.Text; oCommentSupport.Id = mCommentSupport.Id; oCommentSupport.StudentId = mStudentLists.Id; bool isResult = new CommentSupportBll(mAccount).InsertAndUpdateElement(oCommentSupport); if (isResult) { mLisCommentSupport.Insert(0, oCommentSupport); } } RefeshListCommentSupport(sender, e); btnAdd.Text = "Thêm"; btnSua.Text = "Sửa"; btnSua.Enabled = false; gridControlSupport.Enabled = true; btnSua.Image = eCenterTrainning.Properties.Resources.book_edit; btnAdd.Image = eCenterTrainning.Properties.Resources._new; lookUpEditCourse.Enabled = false; dateEditSupport.Enabled = false; richTextBoxContent.ReadOnly = true; } }