Beispiel #1
0
 //保存
 private void Btn_Save_Click(object sender, EventArgs e)
 {
     bool Flag = true;
     C_Alias AliasItem;
     DataGridViewRowCollection dgr = this.Gv_Alias.Rows;
     DataGridViewCellCollection Dgc;
     this.Gv_Alias.EndEdit();
     for (int i = 0; i < dgr.Count; i++)
     {
         AliasItem = new C_Alias();
         Dgc = this.Gv_Alias.Rows[i].Cells;
         AliasItem.Id = Convert.ToInt64(Dgc["Col_Id"].Value);
         AliasItem.Name =Dgc["Col_Name"].FormattedValue.ToString().Trim();
         AliasItem.State=(bool)Dgc["Col_State"].Value;
         if (AliasItem.Name == "")
         {
             Function.MessageWarning("名称不允许为空!");
             return;
         }
         if (!AliasBLL.Update(AliasItem)) { Flag = false; return; }
     }
     if (Flag)
     {
         Function.Message("修改成功!");
         DataBind();
     }
 }
Beispiel #2
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="Item">model</param>
 /// <returns></returns>
 public static bool Update(C_Alias Item)
 {
     DataBase db = new DataBase();
     DataBaseVisitor visitor = new AliasDAL();
     bool Flag = false, ReFlag = false;
     int N = 0;
     SqlParameter[] prams ={
         db.MakeInParam("@Name", SqlDbType.VarChar,50, Item.Name),
         db.MakeInParam("@State", SqlDbType.Bit,0, Item.State),
         db.MakeInParam("@Id", SqlDbType.BigInt,0,Item.Id)
     };
     try
     {
         ReFlag = db.TransactSql(visitor, "Update", prams, out N);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         db.Dispose();
     }
     if (ReFlag && N > 0)
     {
         Flag = true;
     }
     return Flag;
 }