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)); UserGroup1Model dModel = (UserGroup1Model)UserGroup1BO.Instance.FindByPK(ID); txtName.Text = dModel.Name; txtCode.Text = dModel.Code; cboDepartment.SelectedValue = dModel.DepartmentId; cboLeader.EditValue = dModel.UserId; }
private void btnSave_Click(object sender, EventArgs e) { try { if (checkValid()) { UserGroup1Model dModel; if (isAdd) { dModel = new UserGroup1Model(); } else { int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); dModel = (UserGroup1Model)UserGroup1BO.Instance.FindByPK(ID); } dModel.Code = txtCode.Text; dModel.Name = txtName.Text; dModel.DepartmentId = TextUtils.ToString(cboDepartment.SelectedValue); dModel.UserId = TextUtils.ToString(cboLeader.EditValue); if (isAdd) { UserGroup1BO.Instance.Insert(dModel); } else { UserGroup1BO.Instance.Update(dModel); } loadData(); SetInterface(false); ClearInterface(); } } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected UserGroup1Facade(UserGroup1Model model) : base(model) { }