private void btnSave_Click(object sender, EventArgs e) { string strReturnMsg = CheckInput(); if (strReturnMsg != string.Empty) { MessageBox.Show(strReturnMsg); return; } //新增 if (m_Sys_Roles == null) { Sys_Roles model = EntityOperateManager.AddEntity <Sys_Roles>(this.tabPage); int intReturn = m_Sys_RolesDAL.Add(model); if (intReturn > 0) { MessageBox.Show(@"添加成功"); model.KeyId = intReturn; m_lstSys_Roles.Add(model); ListSys_Roles = m_lstSys_Roles; this.DialogResult = DialogResult.OK; } else { MessageBox.Show(@"添加失败"); } } //修改 else { m_Sys_Roles = EntityOperateManager.EditEntity(this.tabPage, m_Sys_Roles); bool blnReturn = m_Sys_RolesDAL.Update(m_Sys_Roles); if (blnReturn) { MessageBox.Show(@"修改成功"); ListSys_Roles = m_lstSys_Roles; this.DialogResult = DialogResult.OK; } else { MessageBox.Show(@"修改失败"); } } }
/// <summary>删除/作废 /// /// </summary> /// <param name="strOperation">操作类型</param> private void DoDeleteOrCancel(string strOperation) { string strMsg = CheckSelect(strOperation); if (strMsg != string.Empty) { MessageBox.Show(strMsg); return; } string strIds = DataGridViewHelper.GetColumnValuesBySelectRows(grdData.SelectedRows, gridmrzKeyId.Name); var blnReturn = strOperation == "删除" ? m_Sys_RolesDAL.DeleteByCond("KeyId in (" + strIds + ")") : m_Sys_RolesDAL.Update("isDefault =1", "KeyId in (" + strIds + ")"); if (blnReturn) { MessageBox.Show(string.Format("{0}成功", strOperation)); DoQueryData(); } else { MessageBox.Show(string.Format("{0}失败", strOperation)); } }