private void btnIsCompleted_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có chắc muốn hoàn thành những hành động phương án này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { foreach (int i in grvData.GetSelectedRows()) { int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); if (id == 0) { continue; } ProposalProblemActionModel model = (ProposalProblemActionModel)ProposalProblemActionBO.Instance.FindByPK(id); model.IsCompleted = true; ProposalProblemActionBO.Instance.Update(model); } loadGrid(); } }
private void btnIsCompleted_Click(object sender, EventArgs e) { //colProposalProblemID int proposalProblemID = TextUtils.ToInt(grvYCMVT.GetFocusedRowCellValue(colProposalProblemID)); if (proposalProblemID == 0) { return; } if (MessageBox.Show("Bạn có chắc muốn hoàn thành những hành động phương án này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { foreach (int i in grvData.GetSelectedRows()) { int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); if (id == 0) { continue; } ProposalProblemActionModel model = (ProposalProblemActionModel)ProposalProblemActionBO.Instance.FindByPK(id); model.IsCompleted = true; ProposalProblemActionBO.Instance.Update(model); } DataTable dt = (DataTable)grvData.DataSource; DataRow[] drs = dt.Select("IsCompleted = 0 or IsCompleted is null"); if (drs.Length == 0) { ProposalProblemModel proposalProblem = (ProposalProblemModel)ProposalProblemBO.Instance.FindByPK(proposalProblemID); proposalProblem.IsCompleted = 1; ProposalProblemBO.Instance.Update(proposalProblem); } loadGrid(); } }
protected ProposalProblemActionFacade(ProposalProblemActionModel model) : base(model) { }
void save() { if (Global.AppUserName != ProposalProblem.UpdatedBy && ProposalProblem.ID > 0) { MessageBox.Show("Bạn không có quyền sửa vấn đề này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } grvData.FocusedRowHandle = -1; ProposalProblem.ProposalId = Proposal.ProposalId; ProposalProblem.Reason = txtReason.Text.Trim(); ProposalProblem.Solution = txtSolution.Text.Trim(); ProposalProblem.IsCompleted = 0; ProposalProblem.UpdatedDate = DateTime.Now; ProposalProblem.UpdatedBy = Global.AppUserName; if (ProposalProblem.ID <= 0) { ProposalProblem.CreatedDate = DateTime.Now; ProposalProblem.CreatedBy = Global.AppUserName; ProposalProblem.ID = (int)pt.Insert(ProposalProblem); } else { pt.Update(ProposalProblem); } for (int i = 0; i < grvData.RowCount; i++) { ProposalProblemActionModel action = new ProposalProblemActionModel(); int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); if (id > 0) { action = (ProposalProblemActionModel)ProposalProblemActionBO.Instance.FindByPK(id); } action.Action = TextUtils.ToString(grvData.GetRowCellValue(i, colAction)); action.ProposalProblemID = ProposalProblem.ID; action.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colUserId)); action.Deadline = TextUtils.ToDate2(grvData.GetRowCellValue(i, colDeadline)); action.IsCompleted = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCompleted)); if (id > 0) { ProposalProblemActionBO.Instance.Update(action); } else { ProposalProblemActionBO.Instance.Insert(action); } } pt.CommitTransaction(); loadGrid(); _isSaved = true; MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } if (_isSaved) { if (this.LoadDataChange != null) { this.LoadDataChange(null, null); } } else { return; } }