public int Update(PermissionML permission, String ConnectionString) { try { int id = 0; StringBuilder Query = new StringBuilder(); Query.AppendFormat("UPDATE {0} ", TableName); Query.AppendLine(" SET "); Query.AppendFormat("Name = '{0}'", permission.Name); Query.AppendFormat("type = {0}", permission.Type); Query.AppendFormat("idUserUpdate = {0}", permission.IdUserUpdate); Query.AppendLine("dateUpdate = GETDATE()"); Query.AppendFormat("WHERE id={0}", permission.Id); SqlConnection Conexion = new SqlConnection { ConnectionString = ConnectionString }; Conexion.Open(); SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion); id = cmd2.ExecuteNonQuery(); Conexion.Close(); return(id); } catch (Exception ex) { throw new Exception(String.Format("{0}.update: {1}", core, ex)); } }
public int Save(PermissionML permission, String ConnectionString) { try { int id = 0; StringBuilder Query = new StringBuilder(); Query.AppendFormat("INSERT INTO {0}", TableName); Query.AppendLine("(name,type,_registry,idUserInsert,dateInsert)"); Query.AppendFormat(" VALUES('{0}',{1},1,{2},GETDATE())", permission.Name, permission.Type); SqlConnection Conexion = new SqlConnection { ConnectionString = ConnectionString }; Conexion.Open(); SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion); id = cmd2.ExecuteNonQuery(); Conexion.Close(); return(id); } catch (Exception ex) { throw new Exception(String.Format("{0}.save : {1}", core, ex)); } }
public int Delete(PermissionML Permission) { try { return(PermissionDAL.Delete(Permission, ConnectionStrings)); } catch (Exception ex) { throw new Exception(String.Format("{0}.Delete: {1}", core, ex)); } }
public int Save(PermissionML Permission) { try { if (Permission.Id == 0) { return(PermissionDAL.Save(Permission, ConnectionStrings)); } else { return(PermissionDAL.Update(Permission, ConnectionStrings)); } } catch (Exception ex) { throw new Exception(String.Format("{0}.Save: {1}", core, ex)); } }