예제 #1
0
        public List <MedicamentoxSucursal> GetAllMedicamentoxSucursal()
        {
            System.Data.SqlClient.SqlConnection conn;
            SqlCommand    command;
            SqlDataReader read;

            conn = new SqlConnection("Data Source=(local);Initial Catalog=Proyecto1;Integrated Security=True");
            conn.Open();
            command = new SqlCommand("SELECT * from MedicamentoxSucursal where LogicDelete = 0", conn);
            read    = command.ExecuteReader();
            List <MedicamentoxSucursal> ListMedicamentoxSucursal = new List <MedicamentoxSucursal>();

            while (read.Read())
            {
                MedicamentoxSucursal mxs = new MedicamentoxSucursal();
                mxs.IdSucursal     = Convert.ToInt32(read["IdSucursal"]);
                mxs.IdMedicamento  = Convert.ToInt32(read["IdMedicamento"]);
                mxs.PrecioSucursal = Convert.ToInt32(read["PrecioSucursal"]);
                mxs.Cantidad       = Convert.ToInt32(read["Cantidad"]);
                mxs.Logicdelete    = Convert.ToBoolean(read["LogicDelete"]);

                ListMedicamentoxSucursal.Add(mxs);
            }
            return(ListMedicamentoxSucursal);
        }
예제 #2
0
        public void UpdateMedicamentoxSucursal([FromBody] MedicamentoxSucursal medicamento)
        {
            System.Data.SqlClient.SqlConnection conn;
            SqlCommand command;

            conn = new SqlConnection("Data Source=(local);Initial Catalog=Proyecto1;Integrated Security=True");
            conn.Open();
            String comm = "Update MedicamentoxSucursal SET PrecioSucursal=" + medicamento.PrecioSucursal + ", Cantidad= " + medicamento.Cantidad + "WHERE IdSucursal=" + medicamento.IdSucursal + "and IdMedicamento=" + medicamento.IdMedicamento;


            command = new SqlCommand(comm, conn);

            command.ExecuteNonQuery();
            conn.Close();
        }
예제 #3
0
        public void PostMedicamentoxSucursal([FromBody] MedicamentoxSucursal mxs)
        {
            System.Data.SqlClient.SqlConnection conn;
            SqlCommand command;

            conn = new SqlConnection("Data Source=(local);Initial Catalog=Proyecto1;Integrated Security=True");
            conn.Open();

            SqlParameter IdSucursal = new SqlParameter("@IdSucursal", System.Data.SqlDbType.Int);

            IdSucursal.Value = mxs.IdSucursal;

            SqlParameter IdMedicamento = new SqlParameter("@IdMedicamento", System.Data.SqlDbType.Int);

            IdMedicamento.Value = mxs.IdMedicamento;

            SqlParameter PrecioSucursal = new SqlParameter("@PrecioSucursal", System.Data.SqlDbType.Int);

            PrecioSucursal.Value = mxs.PrecioSucursal;

            SqlParameter Cantidad = new SqlParameter("@Cantidad", System.Data.SqlDbType.Int);

            Cantidad.Value = mxs.Cantidad;



            command = new SqlCommand("insert into MedicamentoxSucursal(IdSucursal,IdMedicamento,PrecioSucursal, Cantidad) VALUES (@IdSucursal,@IdMedicamento,@PrecioSucursal,@Cantidad)", conn);

            command.Parameters.Add(IdSucursal);
            command.Parameters.Add(IdMedicamento);
            command.Parameters.Add(PrecioSucursal);
            command.Parameters.Add(Cantidad);

            command.ExecuteNonQuery();

            conn.Close();
        }
예제 #4
0
        public void UpdateMedicamentoxSucursal([FromBody] MedicamentoxSucursal mxs)
        {
            MedicamentoxSucursalService con = new MedicamentoxSucursalService();

            con.UpdateMedicamentoxSucursal(mxs);
        }
예제 #5
0
        public void PostMedicamento([FromBody] MedicamentoxSucursal mxs)
        {
            MedicamentoxSucursalService con = new MedicamentoxSucursalService();

            con.PostMedicamentoxSucursal(mxs);
        }