Example #1
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="Item">model</param>
 /// <returns></returns>
 public static bool Insert(D_UserRole Item)
 {
     DataBase db = new DataBase();
     DataBaseVisitor visitor = new RoleDAL();
     bool Flag = false, ReFlag = false,RolePowerFlag=false;
     int N = 0;
     SqlParameter[] prams ={
         db.MakeInParam("@Id", SqlDbType.BigInt,0,PublicFun.PublicFun.MaxId("D_UserRole")),
         db.MakeInParam("@Code", SqlDbType.VarChar,50, Item.Code),
         db.MakeInParam("@Name", SqlDbType.VarChar,50, Item.Name),
         db.MakeInParam("@ParentCode", SqlDbType.VarChar,50, Item.ParentCode)
     };
     try
     {
         ReFlag = db.TransactSql(visitor, "Insert", prams, out N);
         RolePowerFlag=AddRolePower(Item.Code, Item.RolePower);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         db.Dispose();
     }
     if (ReFlag && N > 0 && RolePowerFlag)
     {
         Flag = true;
     }
     return Flag;
 }
Example #2
0
 //保存
 private void Btn_Save_Click(object sender, EventArgs e)
 {
     D_UserRole RoleItem = new D_UserRole();
     RoleItem.Code = this.Tb_Code.Text.Trim();
     RoleItem.Name = this.Tb_Name.Text.Trim();
     RoleItem.RolePower = this.Tv_Power.SelectValues;
     if (RoleItem.Code == "" || RoleItem.Name == "")
     {
         Function.MessageWarning("请把数据填写完整!");
         return;
     }
     if (Id == 0)
     {
         if (Function.CheckKey("D_UserRole", "Code", RoleItem.Code, 0))
         {
             Function.MessageWarning("该编号已存在!");
             return;
         }
         RoleItem.ParentCode = ParentCode;
         if (RoleBLL.Insert(RoleItem))
         {
             Function.Message("添加成功!");
             ResetData();
             TreeViewBind("");
         }
     }
     else
     {
         RoleItem.Id = Id;
         if (RoleBLL.Update(RoleItem))
         {
             Function.Message("修改成功!");
         }
     }
 }