private void btnCancelConfirm_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có chắc muốn hủy xác nhận các chứng từ đã chọn này là đã trả?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } foreach (int i in grvDebt.GetSelectedRows()) { int iD = TextUtils.ToInt(grvDebt.GetRowCellValue(i, colDebtID)); if (iD == 0) { continue; } CaseVoucherDebtModel model = (CaseVoucherDebtModel)CaseVoucherDebtBO.Instance.FindByPK(iD); model.CompletedDate = null; CaseVoucherDebtBO.Instance.Update(model); } updateCompleted(); loadDebt(); }
private void hủyĐãTrảToolStripMenuItem_Click(object sender, EventArgs e) { if (grvData.SelectedRowsCount < 0) { return; } DialogResult result = MessageBox.Show("Bạn có chắc muốn hủy xác nhận những chứng từ này đã trả", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } foreach (int i in grvData.GetSelectedRows()) { int caseVoucherDebtID = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); if (caseVoucherDebtID == 0) { return; } CaseVoucherDebtModel cModel = (CaseVoucherDebtModel)CaseVoucherDebtBO.Instance.FindByPK(caseVoucherDebtID); cModel.CompletedDate = null; CaseVoucherDebtBO.Instance.Update(cModel); } loadData(); }
private void btnSaveHistory_Click(object sender, EventArgs e) { int caseVoucherDebtID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (caseVoucherDebtID == 0) { return; } string completedDate = TextUtils.ToString(grvData.GetFocusedRowCellDisplayText(colCompletedDate)); if (completedDate != "") { return; } if (dtpDateOut.EditValue == null) { MessageBox.Show("Bạn phải chọn ngày trả dự kiến.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (txtReason.Text.Trim() == "") { MessageBox.Show("Bạn phải nhập nguyên nhân gia hạn.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } CaseVoucherDebtHistoryModel model = new CaseVoucherDebtHistoryModel(); model.CaseVoucherDebtID = caseVoucherDebtID; model.DateOut = (DateTime?)dtpDateOut.EditValue; model.Reason = txtReason.Text.Trim(); CaseVoucherDebtHistoryBO.Instance.Insert(model); CaseVoucherDebtModel cModel = (CaseVoucherDebtModel)CaseVoucherDebtBO.Instance.FindByPK(caseVoucherDebtID); cModel.CompletedDateDK = model.DateOut; cModel.Reason = model.Reason; CaseVoucherDebtBO.Instance.Update(cModel); MessageBox.Show("Gia hạn thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); dtpDateOut.EditValue = null; txtReason.Text = ""; grvData.SetFocusedRowCellValue(colReason, model.Reason); grvData.SetFocusedRowCellValue(colCompletedDateDK, model.DateOut); hideControl(true); //_rownIndex = grvData.FocusedRowHandle; //loadData(); }
protected CaseVoucherDebtFacade(CaseVoucherDebtModel model) : base(model) { }
void save(bool close) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } grvDebt.FocusedRowHandle = -1; #region Vụ việc Case.Name = txtName.Text.Trim().ToUpper(); Case.Code = txtCode.Text.Trim().ToUpper(); Case.Content = txtContent.Text.Trim(); Case.UserId = TextUtils.ToString(cboNguoiPhuTrach.EditValue); Case.Target = txtTarget.Text.Trim(); Case.IsLocked = false; Case.Note = txtNote.Text.Trim(); if (Case.ID == 0) { Case.CreatedBy = Global.AppUserName; Case.ID = (int)pt.Insert(Case); } else { Case.UpdatedBy = Global.AppUserName; pt.Update(Case); } #endregion #region Chứng từ vụ việc for (int i = 0; i < grvDebt.RowCount; i++) { int id = TextUtils.ToInt(grvDebt.GetRowCellValue(i, colDebtID)); CaseVoucherDebtModel link = new CaseVoucherDebtModel(); if (id > 0) { link = (CaseVoucherDebtModel)CaseVoucherDebtBO.Instance.FindByPK(id); } link.PayVoucherID = TextUtils.ToInt(grvDebt.GetRowCellValue(i, colDebtVoucherID)); link.CaseID = Case.ID; link.CompletedDateDK = TextUtils.ToDate2(grvDebt.GetRowCellValue(i, colDebtCompletedDateDK)); link.CompletedDate = null; if (id > 0) { pt.Update(link); } else { pt.Insert(link); } } #endregion pt.CommitTransaction(); loadDebt(); _isSaved = true; if (close) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } if (_isSaved) { if (this.LoadDataChange != null) { this.LoadDataChange(null, null); } } }