Exemple #1
0
        public int Update(DaysML days, String ConnectionString)
        {
            try
            {
                int           id    = 0;
                StringBuilder Query = new StringBuilder();
                Query.AppendFormat("UPDATE {0} ", TableName);
                Query.AppendLine(" SET ");
                Query.AppendFormat("name = '{0}'", days.Name);
                Query.AppendFormat("idUserUpdate = {0}", days.IdUserUpdate);
                Query.AppendLine("dateUpdate = GETDATE()");
                Query.AppendFormat("WHERE id={0}", days.Id);

                SqlConnection Conexion = new SqlConnection
                {
                    ConnectionString = ConnectionString
                };
                Conexion.Open();
                SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion);
                id = cmd2.ExecuteNonQuery();
                return(id);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("{0}.update: {1}", core, ex));
            }
        }
Exemple #2
0
 public int Delete(DaysML days)
 {
     try
     {
         return(DaysDAL.Delete(days, ConnectionStrings));
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Exemple #3
0
 public int Save(DaysML days)
 {
     try
     {
         if (days.Id == 0)
         {
             return(DaysDAL.Save(days, ConnectionStrings));
         }
         else
         {
             return(DaysDAL.Update(days, ConnectionStrings));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }
Exemple #4
0
 public int Save(DaysML days, String ConnectionString)
 {
     try
     {
         int           id    = 0;
         StringBuilder Query = new StringBuilder();
         Query.AppendFormat("INSERT INTO {0}", TableName);
         Query.AppendLine("( name,_registry,idUserInsert,dateInsert)");
         Query.AppendFormat(" VALUES('{0}',1,{2},GETDATE())", days.Name, days.IdUserInsert);
         SqlConnection Conexion = new SqlConnection
         {
             ConnectionString = ConnectionString
         };
         Conexion.Open();
         SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion);
         id = cmd2.ExecuteNonQuery();
         return(id);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.save : {1}", core, ex));
     }
 }