コード例 #1
0
 private static void TestUpdateCommand(Empleado emp, Operations.Operations dal)
 {
     Console.WriteLine("Testing Update Command");
     emp              = new Empleado();
     emp.Nombre       = "Anne";
     emp.Pri_apellido = "Brown";
     emp.Cedula       = 1110;
     emp.Seg_apellido = "HR";
     dal.UpdateEmpleado(emp);
     PrintEmployeeInformation(emp);
 }
コード例 #2
0
ファイル: ShellServerHook.cs プロジェクト: elkawee/UShell
 public RESP_Base Multiplex(REQ_Base request)
 {
     if (request is AC_Req)
     {
         return(OPS.AC((AC_Req)request, TMP_dumping_ground.GetAST_ptokBase));
     }
     else if (request is EVAL_Req)
     {
         return(OPS.EVAL_stateless((EVAL_Req)request, analyz0r: use_analyz0r));
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #3
0
        private static void TestInsertCommand(Empleado emp, Operations.Operations dal)
        {
            Console.WriteLine("Testing Insert Command");
            emp                  = new Empleado();
            emp.Nombre           = "Eva";
            emp.Pri_apellido     = "Brown";
            emp.Cedula           = 1110;
            emp.Seg_apellido     = "Architect";
            emp.Fecha_inicio     = "01/01/0101";
            emp.Fecha_nacimiento = "10/10/1010";
            emp.Salario_por_hora = 15000.02;
            emp.Sucursal         = "SJ45";
            dal.AddEmpleado(emp);
            Empleado newEmp = new Empleado();

            newEmp = dal.GetEmpleado(1110);
            PrintEmployeeInformation(newEmp);
        }
コード例 #4
0
 private static void TestDeleteCommand(Empleado emp, Operations.Operations dal)
 {
     Console.WriteLine("Testing Delete Command");
     dal.DeleteEmpleado(1110);
 }
コード例 #5
0
 private static void TestSelectCommand(Sucursal emp, Operations.Operations dal)
 {
     Console.WriteLine("Testing Select command");
     emp = dal.GetSucursal("SJ45");
     Console.WriteLine(emp.Nombre);
 }
コード例 #6
0
        static void Main(string[] args)
        {
            Empleado emp           = new Empleado();
            Sucursal suc           = new Sucursal();
            string   strConnString = "Data Source=LAPTOP-2E6BHQDP\\SQLEXPRESS;Initial Catalog=L3MDB;Integrated Security=True";

            Operations.Operations dal = new Operations.Operations(strConnString);



            using (SqlConnection conn = new SqlConnection(strConnString))
            {
                string sucursaltemp = "SJ45";
                string cajerotemp   = "115930941";

                //////////////////////////////

                string numerotarjeta       = "5";
                string codigoseguridad     = "430";
                string fechaexpiraciontemp = "2027-05-22";

                SqlCommand command = new SqlCommand();
                command.Connection = conn;
                command.Connection.Open();


                SqlParameter Codigo_sucursalparam = new SqlParameter("@codigo_sucursal", sucursaltemp);
                SqlParameter Cedula_cajeroparam   = new SqlParameter("@cedula_cajero", int.Parse(cajerotemp));

                command.Parameters.AddRange(new SqlParameter[] { Codigo_sucursalparam, Cedula_cajeroparam });


                string   listaproductosconcoma  = "123456789";
                string   listaCantidadesComa    = "5";
                string[] listaProductosSep      = listaproductosconcoma.Split(',');
                string[] listaCantidadesComaSep = listaCantidadesComa.Split(',');
                double   preciodemomento        = 0;
                for (int i = 0; i < listaProductosSep.Length; i++)
                {
                    string sqlGetPrecio = "SELECT Precio_venta, Cantidad FROM Producto WHERE Codigo_barras=" + listaProductosSep[i] + " AND Codigo_sucursal=@codigo_sucursal ";
                    command.CommandText = sqlGetPrecio;
                    SqlDataReader reader = command.ExecuteReader();
                    reader.Read();
                    string precioString             = reader[0].ToString();
                    string cantidadDisponibleString = reader[1].ToString();
                    reader.Close();
                    double precioProducto     = double.Parse(precioString);
                    int    cantidadDisponible = int.Parse(cantidadDisponibleString);
                    preciodemomento = preciodemomento + (precioProducto * int.Parse(listaCantidadesComaSep[i]));
                }
                double VentaTotalSinDesc = preciodemomento;
                string sqlgetDescuento   = "SELECT Descuento, Impuesto FROM Producto WHERE Codigo_sucursal=@codigo_sucursal";
                command.CommandText = sqlgetDescuento;
                SqlDataReader reader1 = command.ExecuteReader();
                reader1.Read();
                string descuentoString = reader1[0].ToString();
                string impuestoString  = reader1[1].ToString();
                reader1.Close();
                int    Porcentajedescuento          = int.Parse(descuentoString);
                double PorcentajedescuentoDecimales = Porcentajedescuento / 100.0;
                int    Porcentajeimpuesto           = int.Parse(impuestoString);
                double descuentoMoneda   = VentaTotalSinDesc * (Porcentajedescuento / 100.0);
                double VentaTotalconDesc = VentaTotalSinDesc - descuentoMoneda;
                double impuestoMoneda    = VentaTotalconDesc * (Porcentajeimpuesto / 100.0);
                double Ventatotal        = VentaTotalconDesc + impuestoMoneda;
                var    request           = (HttpWebRequest)WebRequest.Create("http://localhost/BancaTec/l3m?numerotarjeta=" +
                                                                             numerotarjeta + "&numeroseguridad=" +
                                                                             codigoseguridad + "&fechaexpiracion=" +
                                                                             fechaexpiraciontemp + "&monto=" +
                                                                             Ventatotal.ToString() + "&comercio=" +
                                                                             sucursaltemp);

                var response = (HttpWebResponse)request.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);
                XmlNode node = doc.DocumentElement.SelectSingleNode("/respuesta");
                string  text = node.OuterXml.Substring(20).Split('"')[0];

                //////////////////////////////
                if (text.Equals("ok"))
                {
                    SqlCommand command1 = new SqlCommand();
                    command1.Connection = conn;
                    command1.Connection.Open();


                    SqlParameter Codigo_sucursalparam1 = new SqlParameter("@codigo_sucursal", sucursaltemp);
                    SqlParameter Cedula_cajeroparam1   = new SqlParameter("@cedula_cajero", int.Parse(cajerotemp));

                    command1.Parameters.AddRange(new SqlParameter[] { Codigo_sucursalparam1, Cedula_cajeroparam1 });

                    string sqlAddVenta = "INSERT INTO Venta (Codigo_sucursal, Cedula_cajero) VALUES (@codigo_sucursal, @cedula_cajero)";
                    command1.CommandText = sqlAddVenta;
                    command1.ExecuteNonQuery();
                    string sqlgetVentaID = "SELECT MAX(Codigo) FROM Venta ";
                    command1.CommandText = sqlgetVentaID;
                    int VentaID = (Int32)command1.ExecuteScalar();

                    string   listaproductosconcoma1  = "123456789";
                    string   listaCantidadesComa1    = "5";
                    string[] listaProductosSep1      = listaproductosconcoma1.Split(',');
                    string[] listaCantidadesComaSep1 = listaCantidadesComa1.Split(',');
                    for (int i = 0; i < listaProductosSep1.Length; i++)
                    {
                        string sqlGetPrecio = "SELECT Precio_venta, Cantidad FROM Producto WHERE Codigo_barras=" + listaProductosSep1[i] + " AND Codigo_sucursal=@codigo_sucursal ";
                        command1.CommandText = sqlGetPrecio;
                        SqlDataReader reader = command1.ExecuteReader();
                        reader.Read();
                        string precioString             = reader[0].ToString();
                        string cantidadDisponibleString = reader[1].ToString();
                        reader.Close();
                        double precioProducto       = double.Parse(precioString);
                        string nuevoProductoenVenta = "INSERT INTO Productos_en_venta (Codigo_producto, Precio_individual, Cantidad, Codigo_venta, Precio_total) VALUES (" + listaProductosSep1[i] + ", " + precioProducto.ToString() + ", " + listaCantidadesComaSep1[i] + ", " + VentaID.ToString() + ", " + (int.Parse(listaCantidadesComaSep1[i]) * precioProducto).ToString() + " ) ";
                        command1.CommandText = nuevoProductoenVenta;
                        command1.ExecuteNonQuery();
                        int    cantidadDisponible        = int.Parse(cantidadDisponibleString);
                        string sqlReduceCantidadProducto = "UPDATE Producto SET Cantidad=" + (cantidadDisponible - int.Parse(listaCantidadesComaSep1[i])).ToString() + " WHERE Codigo_barras=" + listaProductosSep1[i] + " AND Codigo_sucursal=@codigo_sucursal ";
                        command1.CommandText = sqlReduceCantidadProducto;
                        command1.ExecuteNonQuery();
                    }
                    string sqlgetVentaTotal = "SELECT SUM(Precio_total) FROM Productos_en_venta WHERE Codigo_venta=" + VentaID.ToString() + " ";
                    command1.CommandText = sqlgetVentaTotal;
                    SqlDataReader reader2 = command1.ExecuteReader();
                    reader2.Read();
                    string obtenerSuma = reader2[0].ToString();
                    reader2.Close();
                    double VentaTotalSinDesc1 = double.Parse(obtenerSuma);
                    string sqlgetDescuento1   = "SELECT Descuento, Impuesto FROM Producto WHERE Codigo_sucursal=@codigo_sucursal";
                    command1.CommandText = sqlgetDescuento1;
                    SqlDataReader reader11 = command1.ExecuteReader();
                    reader11.Read();
                    string descuentoString1 = reader11[0].ToString();
                    string impuestoString1  = reader11[1].ToString();
                    reader11.Close();
                    int    Porcentajedescuento1          = int.Parse(descuentoString1);
                    double PorcentajedescuentoDecimales1 = Porcentajedescuento1 / 100.0;
                    int    Porcentajeimpuesto1           = int.Parse(impuestoString1);
                    double descuentoMoneda1   = VentaTotalSinDesc1 * (Porcentajedescuento1 / 100.0);
                    double VentaTotalconDesc1 = VentaTotalSinDesc1 - descuentoMoneda1;
                    double impuestoMoneda1    = VentaTotalconDesc1 * (Porcentajeimpuesto1 / 100.0);
                    double Ventatotal1        = VentaTotalconDesc1 + impuestoMoneda1;
                    string sqlUpdateVenta     = "UPDATE Venta SET Descuento=" + descuentoMoneda1.ToString() + ", Precio_total=" + Ventatotal1.ToString() + ", Impuesto=" + impuestoMoneda1.ToString() + " WHERE Codigo=" + VentaID.ToString() + " ";
                    command1.CommandText = sqlUpdateVenta;
                    command1.ExecuteNonQuery();
                    command1.Connection.Close();
                    string mesanje = "ok";
                }
            }



            #region "Test database Functionalities"

            //dal.DeleteEmpleado(1110);
            //dal.GetSucursal("SJ45");
            //Categoria newcat = new Categoria();
            //newcat.ID = 0;
            //newcat.Codigo_producto = 123456;
            //newcat.Descripcion = "Comida para perro";
            //dal.AddCategoria(newcat);
            //dal.GetVentas
            double descuento = 13 / 100.0;
            Console.WriteLine(descuento);
            //dal.GetHoras("17-14", 115250560);
            //TestSelectCommand(suc, dal);
            //TestInsertCommand(emp, dal);
            //TestUpdateCommand(emp, dal);
            //TestDeleteCommand(emp, dal);
            //TestXMLSerialization();

            #endregion

            #region Test HTTP Methods
            //GenerateGetRequest();
            //GeneratePOSTRequest();
            //GeneratePUTRequest();
            //GenerateDELETERequest();
            #endregion

            Console.ReadLine();
        }