/// <summary> /// Initializes a new instance of the <see cref="CommentViewModel"/> class. /// </summary> /// <param name="thread">The thread that the comment is a part of.</param> /// <param name="currentUser">The current user.</param> /// <param name="commentId">The GraphQL ID of the comment.</param> /// <param name="body">The comment body.</param> /// <param name="state">The comment edit state.</param> /// <param name="author">The author of the comment.</param> /// <param name="updatedAt">The modified date of the comment.</param> protected CommentViewModel( ICommentThreadViewModel thread, IActorViewModel currentUser, string commentId, string body, CommentEditState state, IActorViewModel author, DateTimeOffset updatedAt, Uri webUrl) { Guard.ArgumentNotNull(thread, nameof(thread)); Guard.ArgumentNotNull(currentUser, nameof(currentUser)); Guard.ArgumentNotNull(author, nameof(author)); Thread = thread; CurrentUser = currentUser; Id = commentId; Body = body; EditState = state; Author = author; UpdatedAt = updatedAt; WebUrl = webUrl; var canDeleteObservable = this.WhenAnyValue( x => x.EditState, x => x == CommentEditState.None && author.Login == currentUser.Login); canDelete = canDeleteObservable.ToProperty(this, x => x.CanDelete); Delete = ReactiveCommand.CreateAsyncTask(canDeleteObservable, DoDelete); var canEdit = this.WhenAnyValue( x => x.EditState, x => x == CommentEditState.Placeholder || (x == CommentEditState.None && author.Login == currentUser.Login)); BeginEdit = ReactiveCommand.Create(canEdit); BeginEdit.Subscribe(DoBeginEdit); AddErrorHandler(BeginEdit); CommitEdit = ReactiveCommand.CreateAsyncTask( Observable.CombineLatest( this.WhenAnyValue(x => x.IsReadOnly), this.WhenAnyValue(x => x.Body, x => !string.IsNullOrWhiteSpace(x)), this.WhenAnyObservable(x => x.Thread.PostComment.CanExecuteObservable), (readOnly, hasBody, canPost) => !readOnly && hasBody && canPost), DoCommitEdit); AddErrorHandler(CommitEdit); CancelEdit = ReactiveCommand.Create(CommitEdit.IsExecuting.Select(x => !x)); CancelEdit.Subscribe(DoCancelEdit); AddErrorHandler(CancelEdit); OpenOnGitHub = ReactiveCommand.Create(this.WhenAnyValue(x => x.Id).Select(x => x != null)); }
/// <summary> /// Initializes a new instance of the <see cref="CommentViewModel"/> class. /// </summary> /// <param name="thread">The thread that the comment is a part of.</param> /// <param name="currentUser">The current user.</param> /// <param name="commentId">The ID of the comment.</param> /// <param name="commentNodeId">The GraphQL ID of the comment.</param> /// <param name="body">The comment body.</param> /// <param name="state">The comment edit state.</param> /// <param name="user">The author of the comment.</param> /// <param name="updatedAt">The modified date of the comment.</param> protected CommentViewModel( ICommentThreadViewModel thread, IAccount currentUser, int commentId, string commentNodeId, string body, CommentEditState state, IAccount user, DateTimeOffset updatedAt) { Guard.ArgumentNotNull(thread, nameof(thread)); Guard.ArgumentNotNull(currentUser, nameof(currentUser)); Guard.ArgumentNotNull(body, nameof(body)); Guard.ArgumentNotNull(user, nameof(user)); Thread = thread; CurrentUser = currentUser; Id = commentId; NodeId = commentNodeId; Body = body; EditState = state; User = user; UpdatedAt = updatedAt; var canEdit = this.WhenAnyValue( x => x.EditState, x => x == CommentEditState.Placeholder || (x == CommentEditState.None && user.Equals(currentUser))); BeginEdit = ReactiveCommand.Create(canEdit); BeginEdit.Subscribe(DoBeginEdit); AddErrorHandler(BeginEdit); CommitEdit = ReactiveCommand.CreateAsyncTask( Observable.CombineLatest( this.WhenAnyValue(x => x.IsReadOnly), this.WhenAnyValue(x => x.Body, x => !string.IsNullOrWhiteSpace(x)), this.WhenAnyObservable(x => x.Thread.PostComment.CanExecuteObservable), (readOnly, hasBody, canPost) => !readOnly && hasBody && canPost), DoCommitEdit); AddErrorHandler(CommitEdit); CancelEdit = ReactiveCommand.Create(CommitEdit.IsExecuting.Select(x => !x)); CancelEdit.Subscribe(DoCancelEdit); AddErrorHandler(CancelEdit); OpenOnGitHub = ReactiveCommand.Create(this.WhenAnyValue(x => x.Id, x => x != 0)); }
// Button hủy sửa private void CancelEdit_Click(object sender, EventArgs e) { SaveAddBt.Hide(); CancelAddBt.Hide(); SaveEditButton.Hide(); CancelEdit.Hide(); AddBt.Show(); EditButton.Show(); DeleteButton.Show(); textBox6.Enabled = false; textBox9.Enabled = false; textBox8.Enabled = false; textBox7.Enabled = false; radioButton5.Enabled = false; radioButton6.Enabled = false; dateTimePicker4.Enabled = false; dateTimePicker5.Enabled = false; dateTimePicker6.Enabled = false; }
public DocGia() { InitializeComponent(); panel2.Hide(); SaveAddBt.Hide(); CancelAddBt.Hide(); SaveEditButton.Hide(); CancelEdit.Hide(); textBox4.TextChanged += TextBox4_TextChanged; textBox1.TextChanged += TextBox1_TextChanged; textBox2.TextChanged += TextBox2_TextChanged; textBox3.TextChanged += TextBox3_TextChanged; textBox6.TextChanged += TextBox6_TextChanged; textBox9.TextChanged += TextBox9_TextChanged; textBox8.TextChanged += TextBox8_TextChanged; textBox7.TextChanged += TextBox7_TextChanged; }
// Lưu chỉnh sửa độc giả private void SaveEditButton_Click(object sender, EventArgs e) { DocGiaDTO DgDTO = new DocGiaDTO(); if (radioButton5.Checked == true) { DgDTO.Madocgia = textBox6.Text; DgDTO.Hoten = textBox9.Text; DgDTO.Ngaysinh = dateTimePicker4.Value; DgDTO.Diachi = textBox8.Text; DgDTO.Email = textBox7.Text; DgDTO.Loaidocgia = radioButton5.Text; DgDTO.Ngaylapthe = dateTimePicker5.Value; DgDTO.Cogiatri = dateTimePicker3.Value; } else { DgDTO.Madocgia = textBox6.Text; DgDTO.Hoten = textBox9.Text; DgDTO.Ngaysinh = dateTimePicker4.Value; DgDTO.Diachi = textBox8.Text; DgDTO.Email = textBox7.Text; DgDTO.Loaidocgia = radioButton6.Text; DgDTO.Ngaylapthe = dateTimePicker5.Value; DgDTO.Cogiatri = dateTimePicker3.Value; } bool kq = DgBUS.Sua(DgDTO); if (kq == false) { MessageBox.Show("Sửa độc giả thất bại. Vui lòng kiểm tra lại dũ liệu"); Con.Close(); } else { MessageBox.Show("Sửa độc giả thành công"); Con.Open(); string DocgiaDgv = "select * from DocGia"; SqlCommand commandDocGia = new SqlCommand(DocgiaDgv, Con); SqlDataAdapter adapterDocGia = new SqlDataAdapter(commandDocGia); DataTable table = new DataTable(); adapterDocGia.Fill(table); dataGridView1.DataSource = table; Con.Close(); } SaveEditButton.Hide(); CancelEdit.Hide(); AddBt.Show(); EditButton.Show(); DeleteButton.Show(); textBox6.Enabled = false; textBox9.Enabled = false; textBox8.Enabled = false; textBox7.Enabled = false; radioButton5.Enabled = false; radioButton6.Enabled = false; dateTimePicker4.Enabled = false; dateTimePicker5.Enabled = false; dateTimePicker6.Enabled = false; }
private void ButtonCancel_Click(object sender, RoutedEventArgs e) { CancelEdit?.Invoke(this, EventArgs.Empty); }
public void handleCancel() { CancelEdit?.Invoke(this, Base); }
/// <summary> /// Triggers the <see cref="CancelEdit"/> event. /// </summary> /// <param name="e">Cell event arguments</param> protected virtual void OnCancelEdit(CellEventArgs e) => CancelEdit?.Invoke(this, e);
/// <summary> /// Raises the CancelEdit event. /// </summary> protected void OnCancel() { CancelEdit?.Invoke(this, new EventArgs()); }