public int Delete(RoleML role) { try { int id = 0; StringBuilder Query = new StringBuilder(); Query.AppendFormat("UPDATE {0} ", TableName); Query.AppendLine(" SET "); Query.AppendLine("_registry = 2"); Query.AppendFormat("idUserDelete = {0}", role.IdUserDelete); Query.AppendLine("dateDelete = GETDATE()"); Query.AppendFormat("WHERE id={0}", role.Id); SqlConnection Conexion = new SqlConnection(); Conexion.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}.delete: {1}", core, ex)); } }
public int Delete(RoleML Role) { try { return(RoleDAL.Delete(Role)); } catch (Exception ex) { throw new Exception(String.Format("{0}.Delete: {1}", core, ex)); } }
public int Save(RoleML Role) { try { if (Role.Id == 0) { return(RoleDAL.Save(Role)); } else { return(RoleDAL.Update(Role)); } } catch (Exception ex) { throw new Exception(String.Format("{0}.Save: {1}", core, ex)); } }
public RoleML GetEntity(DataRow row) { try { if (row != null) { RoleML roleML = new RoleML() { Name = (row[RoleML.DataBase.Name] != DBNull.Value) ? row[RoleML.DataBase.Name].ToString() : string.Empty, Description = (row[RoleML.DataBase.Description] != DBNull.Value) ? row[RoleML.DataBase.Description].ToString() : string.Empty, _regitry = (row[RoleML.DataBase._registry] != DBNull.Value) ? int.Parse(row[RoleML.DataBase._registry].ToString()) : 0 }; return(roleML); } return(null); } catch (Exception ex) { throw new Exception(String.Format("{0}.GetEntity : {1}", core, ex)); } }
public int Save(RoleML role) { try { int id = 0; StringBuilder Query = new StringBuilder(); Query.AppendFormat("INSERT INTO {0}", TableName); Query.AppendLine("( name,description,_registry,idUserInsert,dateInsert)"); Query.AppendFormat(" VALUES('{0}','{1}',1,{2},GETDATE())", role.Name, role.Description, role.IdUserInsert); SqlConnection Conexion = new SqlConnection(); Conexion.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)); } }