public void Creates_SQL_Server_connection_string()
 {
     using (var connection = new SqlServerConnection(CreateConfiguration(), new ConnectionStringResolver(null)))
     {
         Assert.IsType<SqlConnection>(connection.DbConnection);
     }
 }
 public void Creates_SQL_Server_connection_string()
 {
     using (var connection = new SqlServerConnection(CreateOptions(), new LoggerFactory()))
     {
         Assert.IsType<SqlConnection>(connection.DbConnection);
     }
 }
 public void Can_create_master_connection_string()
 {
     using (var connection = new SqlServerConnection(CreateConfiguration(), new ConnectionStringResolver(null)))
     {
         using (var master = connection.CreateMasterConnection())
         {
             Assert.Equal(@"Data Source=""(localdb)11.0"";Initial Catalog=master;Integrated Security=True", master.ConnectionString);
         }
     }
 }
 public void Can_create_master_connection_string()
 {
     using (var connection = new SqlServerConnection(CreateOptions(), new LoggerFactory()))
     {
         using (var master = connection.CreateMasterConnection())
         {
             Assert.Equal(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True", master.ConnectionString);
         }
     }
 }
Пример #5
0
        public void Dispose_DisposesTheConnection_IfOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, IsolationLevel.Serializable, _providers);

                connection.Dispose();

                Assert.Equal(ConnectionState.Closed, sqlConnection.State);
            }
        }
Пример #6
0
        public void Dispose_DoesNotDisposeTheConnection_IfNotOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, IsolationLevel.Serializable, _providers, ownsConnection: false);

                connection.Dispose();

                Assert.Equal(ConnectionState.Open, sqlConnection.State);
            }
        }
Пример #7
0
        public int CheckIfFacilityExists(Facility facility)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT COUNT(*) FROM Facilities WHERE fc_idnt<>" + facility.Id + " AND (fc_prefix LIKE '" + facility.Prefix + "' OR fc_name LIKE '" + facility.Name + "')");

            if (dr.Read())
            {
                return(Convert.ToInt32(dr[0]));
            }

            return(0);
        }
Пример #8
0
        public int CheckIfUserExists(Users user)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT COUNT(*) FROM Login WHERE log_user<>" + user.Id + " AND log_username='******'");

            if (dr.Read())
            {
                return(Convert.ToInt32(dr[0]));
            }

            return(0);
        }
Пример #9
0
        public string GetPatientUuid(Patient patient)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT pt_uuid FROM Patient WHERE pt_idnt=" + patient.Id);

            if (dr.Read())
            {
                return(dr[0].ToString());
            }

            return("");
        }
        public void Master_connection_string_none_default_command_timeout()
        {
            var options = new DbContextOptionsBuilder()
                          .UseSqlServer(
                @"Server=(localdb)\MSSQLLocalDB;Database=SqlServerConnectionTest",
                b => b.CommandTimeout(55))
                          .Options;

            using var connection = new SqlServerConnection(CreateDependencies(options));
            using var master     = connection.CreateMasterConnection();
            Assert.Equal(55, master.CommandTimeout);
        }
Пример #11
0
        public Triage SaveTriage(Triage triage)
        {
            SqlServerConnection conn = new SqlServerConnection();

            triage.Id = conn.SqlServerUpdate("DECLARE @idnt INT=" + triage.Id + ", @queue INT=" + triage.Queue.Id + ", @visit INT=" + triage.Visit.Id + ", @temp NVARCHAR(10)='" + triage.Temparature.Value + "', @systolic NVARCHAR(10)='" + triage.BpSystolic.Value + "', @diastolic NVARCHAR(10)='" + triage.BpDiastolic.Value + "', @resp NVARCHAR(10)='" + triage.RespiratoryRate.Value + "', @pulse NVARCHAR(10)='" + triage.PulseRate.Value + "', @oxygen NVARCHAR(10)='" + triage.OxygenSaturation.Value + "', @weight NVARCHAR(10)='" + triage.Weight.Value + "', @height NVARCHAR(10)='" + triage.Height.Value + "', @muac NVARCHAR(10)='" + triage.MUAC.Value + "', @chest NVARCHAR(10)='" + triage.Chest.Value + "', @abdominal NVARCHAR(10)='" + triage.Abdominal.Value + "', @mobility NVARCHAR(10)='" + triage.Mobility.Value + "', @trauma NVARCHAR(10)='" + triage.Trauma.Value + "', @avpu NVARCHAR(10)='" + triage.AVPU.Value + "', @pain NVARCHAR(10)='" + triage.PainScale.Value + "', @situation NVARCHAR(MAX)='" + triage.Situation.Value + "', @background NVARCHAR(MAX)='" + triage.Background.Value + "', @assessment NVARCHAR(MAX)='" + triage.Assessment.Value + "', @recommendation NVARCHAR(MAX)='" + triage.Recommendation.Value + "', @notes NVARCHAR(MAX)='" + triage.Notes + "', @user INT=" + triage.CreatedBy.Id + "; " +
                                             "IF NOT EXISTS (SELECT tg_idnt FROM Triage WHERE tg_idnt=@idnt) " +
                                             "BEGIN INSERT INTO Triage (tg_queue, tg_visit, tg_temp, tg_systolic_bp, tg_diastolic_bp, tg_respiratory_rate, tg_pulse_rate, tg_oxygen_saturation, tg_weight, th_height, tg_muac, tg_chest, tg_abdominal, tg_mobility, tg_trauma, tg_avpu, tg_pain, tg_situation, tg_background, tg_assessment, tg_recommendation, tg_created_by, tg_notes) output INSERTED.tg_idnt VALUES (@queue, @visit, @temp, @systolic, @diastolic, @resp, @pulse, @oxygen, @weight, @height, @muac, @chest, @abdominal, @mobility, @trauma, @avpu, @pain, @situation, @background, @assessment, @recommendation, @user, @notes) END " +
                                             "ELSE " +
                                             "BEGIN UPDATE Triage SET tg_temp=@temp, tg_systolic_bp=@systolic, tg_diastolic_bp=@diastolic, tg_respiratory_rate=@resp, tg_pulse_rate=@pulse, tg_oxygen_saturation=@oxygen, tg_weight=@weight, th_height=@height, tg_muac=@muac, tg_chest=@chest, tg_abdominal=@abdominal, tg_mobility=@mobility, tg_trauma=@trauma, tg_avpu=@avpu, tg_pain=@pain, tg_situation=@situation, tg_background=@background, tg_assessment=@assessment, tg_recommendation=@recommendation, tg_notes=@notes output INSERTED.tg_idnt WHERE tg_idnt=@idnt END");

            return(triage);
        }
Пример #12
0
        private void InterfaceOrientedProgrammingExample()
        {
            var mongoDb   = new MongoDbConnection();
            var sqlServer = new SqlServerConnection();
            var db        = new Database(mongoDb);

            db.OpenConnection();
            db.CloseConnection();
            db = new Database(sqlServer);
            db.OpenConnection();
            db.CloseConnection();
        }
Пример #13
0
        private void Connect(SqlServerConnection sqlConnection)
        {
            if (connection == null)
            {
                connection = new SqlConnection($"server={sqlConnection.ServerURl};" +
                                               $"database={sqlConnection.Database};" +
                                               $"User={sqlConnection.UserName};password={sqlConnection.Password};MultipleActiveResultSets=True;");
                connection.Open();
            }

            //
        }
        public void Master_connection_string_contains_filename()
        {
            var options = new DbContextOptionsBuilder()
                          .UseSqlServer(
                @"Server=(localdb)\MSSQLLocalDB;Database=SqlServerConnectionTest;AttachDBFilename=C:\Narf.mdf",
                b => b.CommandTimeout(55))
                          .Options;

            using var connection = new SqlServerConnection(CreateDependencies(options));
            using var master     = connection.CreateMasterConnection();
            Assert.Equal(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master", master.ConnectionString);
        }
Пример #15
0
        public Invoice SetInvoiceAutoFlag(Invoice invoice)
        {
            SqlServerConnection conn = new SqlServerConnection();

            invoice.Flag.Id = conn.SqlServerUpdate("DECLARE @idnt INT=" + invoice.Id + ", @flag INT=1; SELECT @flag=CASE WHEN inv_amount=ISNULL(ip_tendered,0) THEN 2 ELSE 1 END FROM vInvoice LEFT OUTER JOIN vInvoicePayment ON inv_idnt=ip_invoice WHERE inv_idnt=@idnt; UPDATE Invoice SET inv_flag=@flag output @flag WHERE inv_idnt=@idnt");

            foreach (var bill in invoice.GetBills())
            {
                bill.SetAutoFlag();
            }

            return(invoice);
        }
 private void UseConnections(Action <SqlConnection, SqlServerConnection> action, bool useBatching = false)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     {
         var storage = new SqlServerStorage(sqlConnection, new SqlServerStorageOptions {
             CommandBatchMaxTimeout = useBatching ? TimeSpan.FromMinutes(1) : (TimeSpan?)null
         });
         using (var connection = new SqlServerConnection(storage))
         {
             action(sqlConnection, connection);
         }
     }
 }
        private void UseConnection(Action <SqlServerConnection> action)
        {
            using (var sql = ConnectionUtils.CreateConnection())
            {
                var storage = new Mock <SqlServerStorage>(sql);
                storage.Setup(x => x.QueueProviders).Returns(_providers);

                using (var connection = new SqlServerConnection(storage.Object))
                {
                    action(connection);
                }
            }
        }
Пример #18
0
        public int deleteMedia(int isbn)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Media where isbn = " + isbn);
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.ExecuteNonQuery();
            con.Close();
            return(isbn);
        }
Пример #19
0
        public Usuario Create(Usuario entity, long codigoCampo)
        {
            connection = new SqlServerConnection();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                var clave      = Encrypt.GetMD5(entity.pass);
                var parametros = new Dictionary <string, object>
                {
                    { "@usuario", entity.usuario },
                    { "@nombre", entity.nombre },
                    { "@apellido", entity.apellido },
                    { "@pass", clave },
                    { "@idRol", entity.idRol },
                    { "@codigoCampo", codigoCampo }
                };
                entity.idUsuario = connection.Execute("spRegistrarUsuario", parametros, System.Data.CommandType.StoredProcedure, transaction);
                if (entity.idUsuario == 0)
                {
                    throw new ArgumentException("Create Usuario Error");
                }
                else if (entity.idUsuario == -1)
                {
                    throw new ArgumentException("El usuario ya existe para este campo");
                }
                var param = new Dictionary <string, object>
                {
                    { "@idUsuario", entity.idUsuario },
                    { "@codigoCampo", codigoCampo }
                };
                var insert = connection.Execute("spRegistrarUsuarioEnCampo", param, System.Data.CommandType.StoredProcedure, transaction);
                if (insert == 0)
                {
                    throw new ArgumentException("Create Usuario por Campo Error");
                }
                connection.Commit(transaction);
                return(entity);
            }
            catch (Exception ex)
            {
                connection.Rollback(transaction);
                throw;
            }
            finally
            {
                connection.Close();
                connection  = null;
                transaction = null;
            }
        }
Пример #20
0
        public void UpdateMedicamento(Medicamento medicamento)
        {
            sqlServerConnection = new SqlServerConnection();
            SqlCommand    cmd        = null;
            SqlConnection connection = sqlServerConnection.Abrir();

            //----------------------------INSERCION DATOS PROPIOS DE USUARIO-----------------------------------------
            string query = "UPDATE Medicamento SET NombreGeneral = @NombreGeneral, FormaFarmaceutica = @FormaFarmaceutica," +
                           "Concentracion = @Concentracion, PricipalIndicacion = @PricipalIndicacion, PrecioUnidad = @PrecioUnidad," +
                           "Activo = @Activo, UnidadesEnvase = @UnidadesEnvase, UnidadMedida = @UnidadMedida " +
                           "WHERE IdMedicamento = @IdMedicamento;";

            cmd = new SqlCommand(query, connection);

            //Se crean los parámetros
            cmd.Parameters.Add("@NombreGeneral", SqlDbType.VarChar);
            cmd.Parameters.Add("@FormaFarmaceutica", SqlDbType.VarChar);
            cmd.Parameters.Add("@Concentracion", SqlDbType.VarChar);
            cmd.Parameters.Add("@PricipalIndicacion", SqlDbType.VarChar);
            cmd.Parameters.Add("@PrecioUnidad", SqlDbType.Int);
            cmd.Parameters.Add("@Activo", SqlDbType.Int);
            cmd.Parameters.Add("@UnidadesEnvase", SqlDbType.Int);
            cmd.Parameters.Add("@UnidadMedida", SqlDbType.VarChar);
            cmd.Parameters.Add("@Categoria", SqlDbType.Int);
            cmd.Parameters.Add("@IdMedicamento", SqlDbType.Int);

            //Inserción de datos a los parámetros
            cmd.Parameters["@NombreGeneral"].Value      = medicamento.NombreGeneral;
            cmd.Parameters["@FormaFarmaceutica"].Value  = medicamento.FormaFarmaceutica;
            cmd.Parameters["@Concentracion"].Value      = medicamento.Concentracion;
            cmd.Parameters["@PricipalIndicacion"].Value = medicamento.PricipalIndicacion;
            cmd.Parameters["@PrecioUnidad"].Value       = medicamento.PrecioUnidad;
            cmd.Parameters["@Activo"].Value             = medicamento.Activo;
            cmd.Parameters["@UnidadesEnvase"].Value     = medicamento.UnidadesEnvase;
            cmd.Parameters["@UnidadMedida"].Value       = medicamento.UnidadMedida;
            cmd.Parameters["@Categoria"].Value          = medicamento.Categoria;
            cmd.Parameters["@IdMedicamento"].Value      = medicamento.IdMedicamento;

            //Verificación de Query
            int res = cmd.ExecuteNonQuery();

            if (res > 0)
            {
                MessageBox.Show("Actualización Exitosa", "Carita Feliz");
            }
            else
            {
                MessageBox.Show("Explotóooo", "BUUUUM");
            }
            sqlServerConnection.Cerrar();
        }
Пример #21
0
        public void ConfigureServices(IServiceCollection services)
        {
            var sql = new SqlServerConnection();

            Configuration.Bind("Infra:Connections:Sql", sql);
            services.Configure <SqlServerConnection>(instance => Configuration.Bind("Infra:Connections:Sql", instance));
            services.AddScoped(x => x.GetRequiredService <IOptionsSnapshot <SqlServerConnection> >().Value);

            // var rabbit = new RabbitMqConnection();
            // Configuration.Bind("Infra:Connections:RabbitMQ", rabbit);
            services.Configure <RabbitMqConnection>(instance =>
            {
                Configuration.Bind("Infra:Connections:RabbitMQ", instance);
            });
            services.AddScoped(x =>
            {
                var z = x.GetRequiredService <IOptionsSnapshot <RabbitMqConnection> >().Value;
                return(z);
            });

            services.TryAddSingleton(KebabCaseEndpointNameFormatter.Instance);
            services.AddMassTransit(cfg =>
            {
                cfg.SetKebabCaseEndpointNameFormatter();

                cfg.AddBus(factory => Bus.Factory.CreateUsingRabbitMq(
                               host =>
                {
                    var rabbit = factory.Container.GetRequiredService <RabbitMqConnection>();

                    host.UseHealthCheck(factory);

                    host.Host(rabbit.Host, rabbit.VirtualHost);
                    host.ConfigureEndpoints(factory);
                })
                           );
            });

            services.AddHostedService <MassTransitHostedService>();
            services.AddHostedService <MessageRelayWorker>();

            services.AddCustomHealthCheck(this.Configuration)
            .AddOptions();

            services.AddWrapperizer()
            .AddMessageRelayServices(
                x =>
            {
                x.UseSqlServer(sql.ConnectionString);
            });
        }
        public List <Norms> GetNorms(Facility facility, Int64 type, Boolean includeZeros = false, Boolean filterServices = false)
        {
            List <Norms> norms = new List <Norms>();

            string AdditionalQuery = " AND NOT (nt_norm=0 AND NULLIF(nr_available,0) IS NULL)";
            string ServicesQuery   = "";

            if (includeZeros)
            {
                AdditionalQuery = "";
            }
            if (filterServices)
            {
                ServicesQuery = "AND nc_idnt IN (SELECT ns_category FROM NormsServices WHERE ns_level=" + facility.Category.Level.Id + ")";
            }

            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT nc_idnt, nc_category, ni_idnt, ni_item, nt_norm, ISNULL(nr_available,0) nt_avail, ISNULL(nr_female,0) nt_female, ISNULL(nr_male,0)_nt_male, ISNULL(nr_disabled,0) nt_disabled FROM NormsTiers INNER JOIN NormsItems ON nt_item=ni_idnt AND ni_type=" + type + " INNER JOIN NormsCategory ON ni_catg=nc_idnt " + ServicesQuery + " LEFT OUTER JOIN Norms ON nt_item=nr_norm AND nr_facility=" + facility.Id + " WHERE nt_tctg=" + facility.Category.Id + AdditionalQuery + " ORDER BY ni_catg, nt_item");

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Norms norm = new Norms();
                    norm.Item.Category.Id   = Convert.ToInt64(dr[0]);
                    norm.Item.Category.Name = dr[1].ToString();
                    norm.Item.Id            = Convert.ToInt64(dr[2]);
                    norm.Item.Name          = dr[3].ToString();

                    norm.Norm  = Convert.ToInt64(dr[4]);
                    norm.Value = Convert.ToInt64(dr[5]);

                    norm.Female   = Convert.ToInt64(dr[6]);
                    norm.Male     = Convert.ToInt64(dr[7]);
                    norm.Disabled = Convert.ToInt64(dr[8]);

                    if (norm.Value > norm.Norm)
                    {
                        norm.Gaps = 0;
                    }
                    else
                    {
                        norm.Gaps = norm.Norm - norm.Value;
                    }

                    norms.Add(norm);
                }
            }

            return(norms);
        }
Пример #23
0
        public string GetPatientIdentifier(Patient patient)
        {
            string prefix = patient.Person.Name.Replace(" ", "").Substring(0, 3).ToUpper() + patient.Person.Gender.Substring(0, 1).ToUpper();

            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT ISNULL(MAX(SUBSTRING(pt_identifier, 5, 100)),0)+1 FROM Patient WHERE pt_identifier LIKE '" + prefix + "%'");

            if (dr.Read())
            {
                return(prefix + dr[0].ToString().PadLeft(7, '0'));
            }

            return(prefix + "0000001");
        }
        public void Master_connection_string_contains_filename()
        {
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=SqlServerConnectionTest;AttachDBFilename=C:\Narf.mdf");

            using (var connection = new SqlServerConnection(optionsBuilder.Options, new Logger <SqlServerConnection>(new LoggerFactory())))
            {
                using (var master = connection.CreateMasterConnection())
                {
                    Assert.Equal(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master", master.ConnectionString);
                }
            }
        }
Пример #25
0
        public string deleteAuthor(string authorId)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Author where AuthorId = @authorid");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("authorid", authorId);
            command.ExecuteNonQuery();
            con.Close();
            return(authorId);
        }
Пример #26
0
        public string deleteCondition(string grade)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Condition where grade = @grade");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("grade", grade);
            command.ExecuteNonQuery();
            con.Close();
            return(grade);
        }
 private void UseConnections(Action<SqlConnection, SqlServerConnection> action)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     {
         var storage = new SqlServerStorage(sqlConnection, new SqlServerStorageOptions
         {
             SqlServer2005Compatibility = true
         });
         using (var connection = new SqlServerConnection(storage))
         {
             action(sqlConnection, connection);
         }
     }
 }
Пример #28
0
        public string deletePolicy(string description)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Policies where description = @description");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("description", description);
            command.ExecuteNonQuery();
            con.Close();
            return(description);
        }
Пример #29
0
        public String deletePatron(string libraryCardNumber)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Patron where libraryCardNumber = @librarycardnumber");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("librarycardnumber", libraryCardNumber);
            command.ExecuteNonQuery();
            con.Close();
            return(libraryCardNumber);
        }
        public List <Purchases> GetPurchases(DateTime date1x, DateTime date2x, string category, Stations station, Suppliers supplier, string filter = "")
        {
            List <Purchases>    purchases = new List <Purchases>();
            SqlServerConnection conn      = new SqlServerConnection();

            string query = conn.GetQueryString(filter, "CAST(PurNum AS NVARCHAR)+'-'+ISNULL(Names,'CASH PURCHASE')+'-'+SuppInv+'-'+Category+'-'+CAST(qty*price AS NVARCHAR)+'-'+Names+'-'+st_name+'-'+st_synonym", "Date BETWEEN '" + date1x.Date + "' AND '" + date2x.Date + "'");

            if (!string.IsNullOrEmpty(category))
            {
                query += " AND Category='" + category + "'";
            }
            if (!(station is null))
            {
                query += " AND st_idnt=" + station.Id;
            }
            if (!(supplier is null))
            {
                query += " AND Suppid=" + supplier.Id;
            }

            SqlDataReader dr = conn.SqlServerConnect("SELECT PurNum, Date, Lpo, SuppInv, MAX(Category)Catg, SUM(qty*price) Amts, Supp, ISNULL(Names,'CASH PURCHASE')Names, st_idnt, st_code, st_name, st_synonym FROM vPurchasesAll INNER JOIN Stations ON Stns=st_idnt LEFT OUTER JOIN vSuppliers ON Suppid=Supp AND Stn=Stns " + query + " GROUP BY PurNum, Date, Lpo, SuppInv, Supp, Names, st_idnt, st_code, st_name, st_order, st_synonym ORDER BY Date, SuppInv, st_order, PurNum");

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    purchases.Add(new Purchases {
                        Id         = Convert.ToInt64(dr[0]),
                        Date       = Convert.ToDateTime(dr[1]),
                        DateString = Convert.ToDateTime(dr[1]).ToString("dd/MM/yyyy"),
                        Lpo        = dr[2].ToString(),
                        Invoice    = dr[3].ToString(),
                        Category   = dr[4].ToString(),
                        Amount     = Convert.ToDouble(dr[5]),
                        Supplier   = new Suppliers {
                            Id   = Convert.ToInt64(dr[6]),
                            Name = dr[7].ToString()
                        },
                        Station = new Stations {
                            Id      = Convert.ToInt64(dr[8]),
                            Code    = dr[9].ToString(),
                            Name    = dr[10].ToString(),
                            Synonym = dr[11].ToString(),
                        }
                    });
                }
            }

            return(purchases);
        }
Пример #31
0
        public string GetFacilityPrefix(Facility facility)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT fc_prefix FROM Facilities WHERE fc_idnt=" + facility.Id);

            if (dr.Read())
            {
                return(dr[0].ToString());
            }
            else
            {
                return("");
            }
        }
Пример #32
0
        public String deleteEmployee(string employeeid)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Employee where EmplID = @employeeid");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("employeeid", employeeid);
            command.ExecuteNonQuery();
            con.Close();
            return(employeeid);
        }
Пример #33
0
        public List <Bills> GetBillingCashierQueue(DateTime start, DateTime stop, BillingFlag flag)
        {
            List <Bills> queue = new List <Bills>();
            string       query = "WHERE CAST(bl_date AS DATE) BETWEEN '" + start + "' AND '" + stop + "'";

            if (flag != null)
            {
                query += " AND bl_flag=" + flag.Id;
            }

            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT bl_idnt, bl_amts, bl_date, bl_flag, bf_flag, pt_idnt, pt_uuid, pt_identifier, ps_idnt, ps_name, ps_gender, ps_dob FROM vBillingCashierQueue " + query + " ORDER BY bl_idnt");

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Bills bill = new Bills {
                        Id        = Convert.ToInt64(dr[0]),
                        Amount    = Convert.ToDouble(dr[1]),
                        Date      = Convert.ToDateTime(dr[2]).ToString("dd/MM/yyyy"),
                        CreatedOn = Convert.ToDateTime(dr[2]),
                        Flag      = new BillingFlag {
                            Id   = Convert.ToInt64(dr[3]),
                            Name = dr[4].ToString(),
                        },
                        Visit = new Visit {
                            Patient = new Patient {
                                Id         = Convert.ToInt64(dr[5]),
                                Uuid       = dr[6].ToString(),
                                Identifier = dr[7].ToString(),
                                Person     = new Person {
                                    Id          = Convert.ToInt64(dr[8]),
                                    Name        = dr[9].ToString(),
                                    Gender      = dr[10].ToString(),
                                    DateOfBirth = Convert.ToDateTime(dr[11])
                                }
                            }
                        }
                    };

                    bill.Visit.Patient.GetAge();

                    queue.Add(bill);
                }
            }

            return(queue);
        }
 public InconsistenciaResolver Create(InconsistenciaResolver entity)
 {
     try
     {
         connection = new SqlServerConnection();
         var parametros = new Dictionary <string, object>();
         if (entity.inseminacionAnterior != null && entity.inseminacionNueva != null && entity.inseminacionResultante != null)
         {
             parametros.Add("@idInseminacionAnterior", entity.inseminacionAnterior.idInseminacion);
             parametros.Add("@idInseminacionConflictiva", entity.inseminacionNueva.idInseminacion);
             parametros.Add("@fechaInseminacion", entity.inseminacionResultante.fechaInseminacion);
             parametros.Add("@tipoInseminacion", entity.inseminacionNueva.idTipoInseminacion);
             var update = connection.Execute("spResolverInseminacionConflictiva", parametros, System.Data.CommandType.StoredProcedure);
             if (entity.inseminacionNueva.idTipoInseminacion == 2)
             {
                 var parametrosToro = new Dictionary <string, object>()
                 {
                     { "@idToro", 0 },
                     { "@idInseminacion", entity.inseminacionAnterior.idInseminacion }
                 };
                 for (int i = 0; i < entity.inseminacionNueva.listaBovinos.Count(); i++)
                 {
                     parametrosToro["@idToro"] = entity.inseminacionNueva.listaBovinos.ElementAt(i).idBovino;
                     update = connection.Execute("spActualizarTorosXInseminacionXConflicto", parametrosToro, System.Data.CommandType.StoredProcedure);
                 }
             }
         }
         else if (entity.tactoAnterior != null && entity.tactoNuevo != null && entity.tactoResultante != null)
         {
             parametros.Add("@idInseminacionAnterior", entity.tactoAnterior.idInseminacion);
             parametros.Add("@idInseminacionConflictiva", entity.tactoNuevo.idInseminacion);
             parametros.Add("@fechaTactoAnterior", entity.tactoAnterior.fechaTacto);
             parametros.Add("@fechaTacto", entity.tactoResultante.fechaTacto);
             parametros.Add("@exitoso", entity.tactoResultante.exitoso);
             parametros.Add("@idTipoTacto", entity.tactoResultante.idTipoTacto);
             var update = connection.Execute("spResolverTactoConflictivo", parametros, System.Data.CommandType.StoredProcedure);
         }
         return(entity);
     }
     catch (Exception ex)
     {
         throw;
     }
     finally
     {
         connection.Close();
         connection = null;
     }
 }
Пример #35
0
        public Policy insertPolicy(PolicyInsertSdi policyInsertSdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Policies values(@description,@value)");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("description", policyInsertSdi.Description);
            command.Parameters.AddWithValue("value", policyInsertSdi.Value);
            command.ExecuteNonQuery();
            con.Close();
            return(this.getPolicyByDescription(policyInsertSdi.Description));
        }
Пример #36
0
        public string deleteStock(string grade, int isbn)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("Delete from Stock where grade = @grade and isbn = @isbn");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("grade", grade);
            command.Parameters.AddWithValue("isbn", isbn);
            command.ExecuteNonQuery();
            con.Close();
            return(grade + isbn.ToString());
        }
 public SqlStoreWithBufferReader(
     StateManager stateManager,
     DbContextService <IModel> model,
     EntityKeyFactorySource entityKeyFactorySource,
     EntityMaterializerSource entityMaterializerSource,
     ClrCollectionAccessorSource collectionAccessorSource,
     ClrPropertySetterSource propertySetterSource,
     SqlServerConnection connection,
     SqlServerCommandBatchPreparer batchPreparer,
     SqlServerBatchExecutor batchExecutor,
     ILoggerFactory loggerFactory)
     : base(stateManager, model, entityKeyFactorySource, entityMaterializerSource,
            collectionAccessorSource, propertySetterSource, connection, batchPreparer, batchExecutor, loggerFactory)
 {
 }
        private void UseConnection(Action<SqlServerConnection> action)
        {
            using (var sql = ConnectionUtils.CreateConnection())
            {
                var storage = new Mock<SqlServerStorage>(sql, new SqlServerStorageOptions
                {
                    SqlServer2005Compatibility = true
                });
                storage.Setup(x => x.QueueProviders).Returns(_providers);

                using (var connection = new SqlServerConnection(storage.Object))
                {
                    action(connection);
                }
            }
        }
Пример #39
0
 private void UseConnections(Action<SqlConnection, SqlServerConnection> action)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     using (var connection = new SqlServerConnection(sqlConnection, _providers, System.Transactions.IsolationLevel.Serializable))
     {
         action(sqlConnection, connection);
     }
 }
Пример #40
0
 private void UseConnection(Action<SqlServerConnection> action)
 {
     using (var connection = new SqlServerConnection( 
         ConnectionUtils.CreateConnection(),
         IsolationLevel.Serializable,
         _providers))
     {
         action(connection);
     }
 }
Пример #41
0
 private void UseConnections(Action<SqlConnection, SqlServerConnection> action)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     {
         var storage = new SqlServerStorage(sqlConnection);
         using (var connection = new SqlServerConnection(storage))
         {
             action(sqlConnection, connection);
         }
     }
 }
Пример #42
0
 private void UseConnection(Action<SqlServerConnection> action)
 {
     using (var connection = new SqlServerConnection( 
         ConnectionUtils.CreateConnection(),
         _providers))
     {
         action(connection);
     }
 }
Пример #43
0
 private void UseConnections(Action<SqlConnection, SqlServerConnection> action)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     using (var connection = new SqlServerConnection(sqlConnection, _providers))
     {
         action(sqlConnection, connection);
     }
 }
Пример #44
0
 private void UseConnection(Action<SqlServerConnection> action)
 {
     using (var connection = new SqlServerConnection(
         _storage.Object, ConnectionUtils.CreateConnection()))
     {
         action(connection);
     }
 }
Пример #45
0
 private void UseConnections(Action<SqlConnection, SqlServerConnection> action)
 {
     using (var sqlConnection = ConnectionUtils.CreateConnection())
     using (var connection = new SqlServerConnection(_storage.Object, sqlConnection))
     {
         action(sqlConnection, connection);
     }
 }