Exemplo n.º 1
0
        public DataTable spmostrar_detalle_ingresoCodigo(CD_DetalleIngreso Producto)
        {
            DataTable DtResultado = new DataTable("Tbl_Producto");

            /// SqlConnection SqlCon = new SqlConnection();
            try
            {
                SqlConnection cn     = ConexionBD.Instancia.Conectar();
                SqlCommand    SqlCmd = new SqlCommand();
                SqlCmd.Connection  = cn;
                SqlCmd.CommandText = "spmostrar_detalle_ingresoCodigo";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParTextoBuscar = new SqlParameter();
                ParTextoBuscar.ParameterName = "@textobuscar";
                ParTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                ParTextoBuscar.Size          = 50;
                ParTextoBuscar.Value         = Producto.TextoBuscar;
                SqlCmd.Parameters.Add(ParTextoBuscar);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception ex)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
Exemplo n.º 2
0
        //Método Insertar
        public string Insertar(CD_DetalleIngreso Detalle_Ingreso, ref SqlConnection SqlCon, ref SqlTransaction SqlTra)
        {
            string rpta = "";

            try
            {
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.Transaction = SqlTra;
                SqlCmd.CommandText = "spinsertar_detalle_ingreso";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIddetalle_ingreso = new SqlParameter();
                ParIddetalle_ingreso.ParameterName = "@iddetalle_ingreso";
                ParIddetalle_ingreso.SqlDbType     = SqlDbType.Int;
                ParIddetalle_ingreso.Direction     = ParameterDirection.Output;
                SqlCmd.Parameters.Add(ParIddetalle_ingreso);

                SqlParameter ParIdingreso = new SqlParameter();
                ParIdingreso.ParameterName = "@idingreso";
                ParIdingreso.SqlDbType     = SqlDbType.Int;
                ParIdingreso.Value         = Detalle_Ingreso.Idingreso;
                SqlCmd.Parameters.Add(ParIdingreso);

                SqlParameter ParIdarticulo = new SqlParameter();
                ParIdarticulo.ParameterName = "@Id_Prod";
                ParIdarticulo.SqlDbType     = SqlDbType.Int;
                ParIdarticulo.Value         = Detalle_Ingreso.Id_Prod;
                SqlCmd.Parameters.Add(ParIdarticulo);

                SqlParameter ParPrecio_Compra = new SqlParameter();
                ParPrecio_Compra.ParameterName = "@precio_compra";
                ParPrecio_Compra.SqlDbType     = SqlDbType.Decimal;
                //ParPrecio_Compra.Precision = 10;
                //ParPrecio_Compra.Scale = 2;
                ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra;
                SqlCmd.Parameters.Add(ParPrecio_Compra);

                SqlParameter ParPrecio_Venta = new SqlParameter();
                ParPrecio_Venta.ParameterName = "@precio_venta";
                ParPrecio_Venta.SqlDbType     = SqlDbType.Decimal;
                //ParPrecio_Venta.Precision = 10;
                //ParPrecio_Venta.Scale = 2;
                ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta;
                SqlCmd.Parameters.Add(ParPrecio_Venta);

                SqlParameter ParStock_Inicial = new SqlParameter();
                ParStock_Inicial.ParameterName = "@stock_inicial";
                ParStock_Inicial.SqlDbType     = SqlDbType.Int;
                ParStock_Inicial.Value         = Detalle_Ingreso.Stock_Inicial;
                SqlCmd.Parameters.Add(ParStock_Inicial);

                SqlParameter ParStock_Actual = new SqlParameter();
                ParStock_Actual.ParameterName = "@stock_actual";
                ParStock_Actual.SqlDbType     = SqlDbType.Int;
                ParStock_Actual.Value         = Detalle_Ingreso.Stock_Actual;
                SqlCmd.Parameters.Add(ParStock_Actual);

                SqlParameter ParFecha_Produccion = new SqlParameter();
                ParFecha_Produccion.ParameterName = "@fecha_produccion";
                ParFecha_Produccion.SqlDbType     = SqlDbType.DateTime;
                ParFecha_Produccion.Value         = Detalle_Ingreso.Fecha_Produccion;
                SqlCmd.Parameters.Add(ParFecha_Produccion);

                SqlParameter ParFecha_Vencimiento = new SqlParameter();
                ParFecha_Vencimiento.ParameterName = "@fecha_vencimiento";
                ParFecha_Vencimiento.SqlDbType     = SqlDbType.DateTime;
                ParFecha_Vencimiento.Value         = Detalle_Ingreso.Fecha_Vencimiento;
                SqlCmd.Parameters.Add(ParFecha_Vencimiento);


                //Ejecutamos nuestro comando
                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }

            return(rpta);
        }