private void btnEdit_Click(object sender, EventArgs e) { if (!grvData.IsDataRow(grvData.FocusedRowHandle)) { return; } setInterface(true); _isAdd = false; int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); ModuleTemModel dModel = (ModuleTemModel)ModuleTemBO.Instance.FindByPK(ID); txtCode.Text = dModel.Code; txtTime.Text = dModel.LastTimeChange.ToString(); deUpdatedDate.EditValue = dModel.LastDateChange; }
private void txtTime_EditValueChanged(object sender, EventArgs e) { try { if (!_isAdd) { int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); ModuleTemModel dModel = (ModuleTemModel)ModuleTemBO.Instance.FindByPK(ID); if (dModel.LastTimeChange != TextUtils.ToInt(txtTime.Text.Trim())) { txtReason.Enabled = true; } } } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (checkValid()) { ModuleTemModel dModel; if (_isAdd) { dModel = new ModuleTemModel(); } else { int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); dModel = (ModuleTemModel)ModuleTemBO.Instance.FindByPK(ID); } dModel.Code = txtCode.Text.ToUpper().Trim(); dModel.LastDateChange = TextUtils.ToDate(deUpdatedDate.EditValue.ToString()); dModel.LastTimeChange = TextUtils.ToInt(txtTime.Text.Trim()); dModel.ModuleID = ModuleID; if (_isAdd) { pt.Insert(dModel); } else { pt.Update(dModel); if (txtReason.Enabled) { ModuleTemHistoryModel hModel = new ModuleTemHistoryModel(); hModel.ModuleTemID = dModel.ID; hModel.LastTimeChange = dModel.LastTimeChange; hModel.LastDateChange = dModel.LastDateChange; hModel.Reason = txtReason.Text.Trim(); hModel.UpdatedDate = TextUtils.GetSystemDate(); hModel.UpdatedBy = Global.AppUserName; hModel.Code = dModel.Code; pt.Insert(hModel); } } pt.CommitTransaction(); LoadData(); setInterface(false); clearInterface(); } } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
protected ModuleTemFacade(ModuleTemModel model) : base(model) { }