Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
 public int Delete(RoleML Role)
 {
     try
     {
         return(RoleDAL.Delete(Role));
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Beispiel #3
0
 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));
     }
 }
Beispiel #4
0
        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));
            }
        }
Beispiel #5
0
        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));
            }
        }