Example #1
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     if (txt_RoleName.Text.Trim() == "")
     {
         errorProvider1.SetError(txt_RoleName, "请输入角色名称!");
         return;
     }
     errorProvider1.Clear();
     List<RoleModel> roleModel_List = manager.GetModelList(" RoleName='" + txt_RoleName.Text.Trim() + "' and RoleId <> " + roleid + "");
     if (roleModel_List.Count > 0)
     {
         errorProvider1.SetError(txt_RoleName, "角色名称已存在,请更换!");
         return;
     }
     DialogResult result = MessageBox.Show("您确认要修改吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
     if (result == DialogResult.OK)
     {
         RoleModel model = new RoleModel();
         model.RoleId = roleid;
         model.RoleName = txt_RoleName.Text.Trim();
         model.RoleSynopsis = txt_Desc.Text.Trim();
         model.DataTime = CommTools.GetDateFormatStrot2(DateTime.Now);
         bool isUpdate = manager.Update(model);
         MessageBox.Show("角色:" + txt_RoleName.Text.Trim() + " 修改" + (isUpdate == true ? "成功!" : "失败!"));
         CommTools.AddSystemLog("修改", "角色:" + txt_RoleName.Text.Trim() + " 修改" + (isUpdate == true ? "成功!" : "失败!"));
         MainForm mf = (MainForm)this.Owner;
         mf.GetRoleManagerList();
         this.Close();
     }
 }
Example #2
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     if (txt_RoleName.Text.Trim() == "")
     {
         errorProvider1.SetError(txt_RoleName, "请输入角色名称!");
         return;
     }
     errorProvider1.Clear();
     List<RoleModel> roleModel_List=roleManager.GetModelList(" RoleName='"+txt_RoleName.Text.Trim()+"'");
     if(roleModel_List.Count>0)
     {
         errorProvider1.SetError(txt_RoleName, "角色名称已存在,请更换!");
         return;
     }
     RoleModel model = new RoleModel();
     model.RoleId = roleManager.GetMaxId();
     model.RoleName = txt_RoleName.Text.Trim();
     model.RoleSynopsis = txt_Desc.Text.Trim();
     model.DataTime = CommTools.GetDateFormatStrot2(DateTime.Now);
     bool isAdd=roleManager.Add(model);
     MessageBox.Show("角色:" + txt_RoleName.Text.Trim() + " 添加" + (isAdd == true ? "成功!" : "失败!"));
     CommTools.AddSystemLog("添加","角色:" + txt_RoleName.Text.Trim() + " 添加" + (isAdd == true ? "成功!" : "失败!"));
     MainForm mf = (MainForm)this.Owner;
     mf.GetRoleManagerList();
     this.Close();
 }