Ejemplo n.º 1
0
        public int Update(FestiveML festive, String ConnectionString)
        {
            try
            {
                int           id    = 0;
                StringBuilder Query = new StringBuilder();
                Query.AppendFormat("UPDATE {0} ", TableName);
                Query.AppendLine(" SET ");
                Query.AppendFormat("date = '{0}'", festive.Date);
                Query.AppendFormat("name = '{0}'", festive.Name);
                Query.AppendFormat("typeJob = '{0}'", festive.TypeJob);
                Query.AppendFormat("idUserUpdate = {0}", festive.IdUserUpdate);
                Query.AppendLine("dateUpdate = GETDATE()");
                Query.AppendFormat("WHERE id={0}", festive.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));
            }
        }
Ejemplo n.º 2
0
        public int Save(FestiveML festive, String ConnectionString)
        {
            try
            {
                int           id    = 0;
                StringBuilder Query = new StringBuilder();
                Query.AppendFormat("INSERT INTO {0}", TableName);
                Query.AppendLine("( date,name,typeJob,_registry,idUserInsert,dateInsert)");
                Query.AppendFormat(" VALUES('{0}','{1}','{2}',1,{3},GETDATE())", festive.Date, festive.Name, festive.TypeJob, festive.IdUserInsert);
                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));
            }
        }
Ejemplo n.º 3
0
 public int Delete(FestiveML festive)
 {
     try
     {
         return(FestiveDAL.Delete(festive, ConnectionStrings));
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Ejemplo n.º 4
0
 public int Save(FestiveML festive)
 {
     try
     {
         if (festive.Id == 0)
         {
             return(FestiveDAL.Save(festive, ConnectionStrings));
         }
         else
         {
             return(FestiveDAL.Update(festive, ConnectionStrings));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }