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