Ejemplo n.º 1
0
        public void UpdateSyncTicket(DBTicketModel ticket)
        {
            string        sql     = "[dbo].[MTL_HBP_Tickets_Sync]";
            SqlCommand    command = new SqlCommand(sql, cnn);
            SqlDataReader rdr     = null;

            try
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@company", SqlDbType.Char).Value       = ticket.Company;
                command.Parameters.Add("@rfc", SqlDbType.Char).Value           = ticket.RFC;
                command.Parameters.Add("@numoperacion", SqlDbType.Int).Value   = ticket.NumeroOperacion;
                command.Parameters.Add("@tipoactividad", SqlDbType.Char).Value = ticket.TipoActividad;
                command.Parameters.Add("@ticketid", SqlDbType.BigInt).Value    = ticket.TicketId;

                rdr = command.ExecuteReader();
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }
        }
Ejemplo n.º 2
0
        public IList <DBTicketModel> GetTickets()
        {
            string                sql        = "SELECT * FROM dbo.HBP_Tickets where TicketId is null";
            SqlCommand            sqlCommand = new SqlCommand(sql, cnn);
            SqlDataReader         dataReader = null;
            IList <DBTicketModel> tickets    = new List <DBTicketModel>();

            try
            {
                sqlCommand.CommandType = CommandType.Text;
                dataReader             = sqlCommand.ExecuteReader();
                if (dataReader.HasRows)
                {
                    DataTable dataTable = new DataTable();
                    dataTable.Load(dataReader);
                    foreach (DataRow row in dataTable.Rows)
                    {
                        DBTicketModel ticketModel = new DBTicketModel
                        {
                            Company         = row.Field <string>("Company"),
                            RFC             = row.Field <string>("RFC"),
                            Monto           = row.Field <decimal?>("Monto"),
                            FechaAlta       = row.Field <DateTime>("FechaAlta"),
                            NumeroOperacion = row.Field <int>("NumOperacion"),
                            Descripcion     = row.Field <string>("Descripcion"),
                            SyncDate        = row.Field <DateTime?>("sync_date"),
                            TicketId        = row.Field <long?>("TicketId"),
                            TipoActividad   = row.Field <string>("TipoActividad")
                        };
                        tickets.Add(ticketModel);
                    }
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
            return(tickets);
        }