示例#1
0
        public int cargar_barra()
        {
            int num = -1;
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return -1;
            }
            else
            {
                sql = "Select count(*) as numero from ClienteBarra cr join Cliente c on c.codCliente = cr.codCliente join Restaurante r on c.codRestaurante = r.codRestaurante where c.estadoFactura = 'Sin pagar' and c.fecha =@fecha and r.codRestaurante=@cod";

                ParamStruct[] parametros = new ParamStruct[2];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, _codRest);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@fecha", SqlDbType.VarChar, _fecha);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener las barras", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return -1;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        num = Convert.ToInt32(ds.Tables[0].Rows[0]["numero"].ToString());

                    }

                }
                return num;
            }
        }
示例#2
0
        public bool actualizar_consecutivo(int id)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener la cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            else
            {

                sql = "Update Consecutivos SET valor=@valor WHERE tipo='Mesas'";

                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@valor", SqlDbType.Int, id);

                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);

                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar el valor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return false;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return true;
                }
            }
        }
示例#3
0
 private static void UnloadParms(List <ParamStruct> parms, SqlCommand cmd)
 {
     if (parms != null)
     {
         for (int i = 0; i <= parms.Count - 1; i++)
         {
             ParamStruct p = parms[i];
             p.Value  = cmd.Parameters[i].Value;
             parms[i] = p;
         }
     }
 }
示例#4
0
文件: DAL.cs 项目: Rimolo/Restaurante
 public static void agregar_datos_estructura_parametros(ref ParamStruct[] parametros, int posicion, string nombre_parametro, SqlDbType tipo_dato_parametro, object valor_parametro)
 {
     parametros[posicion].Nombre_Parametro = nombre_parametro.ToString();
     parametros[posicion].Tipo_Dato = tipo_dato_parametro;
     if (valor_parametro==null)
     {
         parametros[posicion].Valor_Parametro = DBNull.Value;
     }
     else
     {
         parametros[posicion].Valor_Parametro= valor_parametro;
     }
 }
示例#5
0
        public void carga_info_producto(int cod_producto)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
               if (conexion == null)
               {
               MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
               _nombre = "Error";
               }
               else
               {
               sql = "Select Nombre_Producto,Cod_Linea,Cod_Proveedor,Descontinuado" +
                     " from Productos where cod_producto=@cod";
               ParamStruct[] parametros = new ParamStruct[1];
               cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.Int, cod_producto);
               ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
               if (ds == null)
               {
                   MessageBox.Show(mensaje_error, "Error al obtener el producto", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   _nombre = "Error";
               }
               else
               {
                   if (ds.Tables[0].Rows.Count > 0)
                   {
                       _nombre = ds.Tables[0].Rows[0]["Nombre_Producto"].ToString();
                       _linea = Convert.ToInt32(ds.Tables[0].Rows[0]["Cod_Linea"]);
                       _proveedor = Convert.ToInt32(ds.Tables[0].Rows[0]["Cod_Proveedor"]);
                       _descontinuado = Convert.ToBoolean(ds.Tables[0].Rows[0]["Descontinuado"]);
                   }
                   else
                   {
                       _nombre = "Error";
                   }
               }

               }
        }
示例#6
0
        public void carga_info_usuario(string usuario)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {
                sql = "Select nickname,codRest,adminCuentas,adminRestaurante,adminSistema,adminSeguridad,contraseña" +
                      " from Usuario where nickname=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, usuario);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Usuario/clave incorrecta", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _contraseña = ds.Tables[0].Rows[0]["contraseña"].ToString();
                        _codR = ds.Tables[0].Rows[0]["codRest"].ToString();
                        _adminSeguridad = Convert.ToBoolean(ds.Tables[0].Rows[0]["adminSeguridad"].ToString());
                        _adminCuentas = Convert.ToBoolean(ds.Tables[0].Rows[0]["adminCuentas"].ToString());
                        _adminSistema = Convert.ToBoolean(ds.Tables[0].Rows[0]["adminSistema"].ToString());
                        _adminRestaurante = Convert.ToBoolean(Convert.ToBoolean(ds.Tables[0].Rows[0]["adminRestaurante"].ToString()));
                    }

                }

            }
        }
示例#7
0
        public bool eliminar_Licores(string codLic)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            else
            {
                sql = "Delete from Licores where codLicor = @codLicor";

                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codLicor", SqlDbType.VarChar, codLic);
                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al eliminar el licor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return false;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return true;
                }
            }
        }
示例#8
0
 public bool guardar_Heladas(string accion, string Restaurante)
 {
     conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
     string codRest = "";
     if (conexion == null)
     {
         MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
     {
         if (accion.Equals("Insertar"))
         {
             DataSet ds;
             ds = retorna_Cod_Restaurante(Restaurante);
             codRest = Convert.ToString(ds.Tables[0].Rows[0]["codRestaurante"]);
             sql = "Insert into BebidaHelada values(@codBebidaHel, @nombre, @ingredientes, @precio, @codRestaurante, @descripcion, null)";
         }
         else
         {
             sql = "Update BebidaHelada SET" +
                 " nombre=@nombre," +
                 " descripcion=@descripcion," +
                 " precio=@precio," +
                 " ingredientes=@ingredientes," +
                 " imagen=null" +
                 " where codBebidaHel=@codBebidaHel";
         }
         ParamStruct[] parametros = new ParamStruct[6];
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codBebidaHel", SqlDbType.VarChar, _codBebidaHel);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@nombre", SqlDbType.VarChar, _nombre);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@ingredientes", SqlDbType.VarChar, _ingredientes);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@precio", SqlDbType.Money, _precio);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@codRestaurante", SqlDbType.VarChar, codRest);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@descripcion", SqlDbType.VarChar, _descripcion);
         cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
         cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
         if (numero_error != 0)
         {
             MessageBox.Show(mensaje_error, "Error al guardar el producto", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return false;
         }
         else
         {
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return true;
         }
     }
 }
示例#9
0
        public bool guardar_rest(string accion)
        {
            //Eliminar cuando ya se tenga la parte de clientes lista
            _cantC = 0;
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            else
            {
                if (accion.Equals("Insertar"))
                {
                    sql = "Insert into Restaurante values(@cod,@nombre,@especialidad,@direccion,@cant,@tel,@activo)";
                }
                else
                {
                    sql = "Update Restaurante SET" +
                        " nombre=@nombre," +
                        " direccion=@direccion," +
                        " especialidad=@especialidad," +
                        " cantClientes=@cant," +
                        " activo=@activo," +
                        " telefono=@tel" +
                        " where codRestaurante=@cod";
                }
                ParamStruct[] parametros = new ParamStruct[7];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@nombre", SqlDbType.VarChar, _nombre);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@direccion", SqlDbType.VarChar, _direccion);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@especialidad", SqlDbType.VarChar, _especialidad);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@cant", SqlDbType.Int, _cantC);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@tel", SqlDbType.Int, _tel);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@activo", SqlDbType.Bit, _activo);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 6, "@cod", SqlDbType.VarChar, _codigo);

                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar el Usuario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return false;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return true;
                }
            }
        }
示例#10
0
        public void carga_info_Mesa(string codMesa)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select Me.codigoMesa, Me.nombre, Me.numero, Me.cantidadSillas, R.nombre as nomrest" +
                      " from Mesas Me INNER JOIN Restaurante R ON Me.codRestaurante = R.codRestaurante where codigoMesa = @codMesa";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codMesa", SqlDbType.VarChar, codMesa);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener las Mesas", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _cantSillas = Convert.ToInt32(ds.Tables[0].Rows[0]["cantidadSillas"]);
                        _numero = Convert.ToInt32(ds.Tables[0].Rows[0]["numero"]);
                        _codRestaurante= ds.Tables[0].Rows[0]["nomrest"].ToString();

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#11
0
        public bool guardar_cliente(string accion)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            else
            {
                if (accion.Equals("Insertar"))
                {
                    sql = "Insert into Cliente values(@cod,@nombre,convert(datetime,@fecha,103),@monto,0,1,@codR,@horaE,null,null,'Sin pagar',null)";

                }
                else if (accion.Equals("Editar"))
                {
                    sql = "Update Cliente SET" +
                        " duracion=@duracion" +
                        " where codCliente=@cod";
                }
                else
                {
                    sql = "Update Cliente SET" +
                        " estadoFactura='Pagado'," +
                        " horaSalida=@horaS," +
                        " duracion=@duracion" +
                        " where codCliente=@cod";
                }

                ParamStruct[] parametros = new ParamStruct[8];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@nombre", SqlDbType.VarChar, _nombre);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@fecha", SqlDbType.VarChar, _fechaE);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@monto", SqlDbType.Money, _monto);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@codR", SqlDbType.VarChar, _codR);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@horaE", SqlDbType.VarChar, _horaE);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@horaS", SqlDbType.VarChar, _horaS);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 6, "@duracion", SqlDbType.VarChar, _duracion);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 7, "@cod", SqlDbType.VarChar, _codigo);

                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar el Cliente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return false;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    if (!accion.Equals("Pagar"))
                    {
                        guardar_pedidos(accion);

                    }
                    return true;
                }

            }
        }
示例#12
0
        public int cargar_num_mesa(string cod)
        {
            int num = -1;
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return -1;
            }
            else
            {
                sql = "Select numero from Mesas where codigoMesa=@cod and codRestaurante=@codRest";
                ParamStruct[] parametros = new ParamStruct[2];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, cod);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@codRest", SqlDbType.VarChar, codR);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el pais", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return -1;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        num = Convert.ToInt32(ds.Tables[0].Rows[0]["numero"].ToString());

                    }

                }
                return num;
            }
        }
示例#13
0
        public string cargar_nombre_mesa(int num)
        {
            string nombreMesa = "";
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            else
            {
                sql = "Select nombre from Mesas where numero=@num and codRestaurante=@codRest";
                ParamStruct[] parametros = new ParamStruct[2];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@num", SqlDbType.Int, num);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@codRest", SqlDbType.VarChar, codR);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener la mesa", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        nombreMesa = ds.Tables[0].Rows[0]["nombre"].ToString();

                    }

                }

            }
            return nombreMesa;
        }
示例#14
0
        public string cargar_cod_mesa2()
        {
            string cod = "";
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            else
            {
                sql = "Select codMesa from ClienteReserva where codCliente=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, _codigo);

                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener la mesa", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        cod = ds.Tables[0].Rows[0]["codMesa"].ToString();

                    }

                }
                return cod;
            }
        }
示例#15
0
        public void carga_info_pais(string cod_pais)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select nombre,bandera" +
                      " from Pais where codigoPais=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, cod_pais);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el pais", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["bandera"].ToString()))
                        {
                            _bandera = (byte[])(ds.Tables[0].Rows[0]["bandera"]);
                        }
                        else {
                            _bandera = null;
                        }

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#16
0
        public void carga_info_cliente(string codC)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select c.nombre,c.fecha,c.montoPagado,c.codRestaurante,c.horaEntrada,c.duracion,cb.numSilla,cb.detalleProducto " +
                    "from Cliente c join ClienteBarra cb on c.codCliente = cb.codCliente where c.codCliente = @cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, codC);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el cliente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _fechaE = ds.Tables[0].Rows[0]["fecha"].ToString();
                        _monto = Convert.ToDouble(ds.Tables[0].Rows[0]["montoPagado"].ToString());
                        _duracion = ds.Tables[0].Rows[0]["duracion"].ToString();
                        _codR = ds.Tables[0].Rows[0]["codRestaurante"].ToString();
                        _horaE = ds.Tables[0].Rows[0]["horaEntrada"].ToString();
                        _listaPedidos = ds.Tables[0].Rows[0]["detalleProducto"].ToString();
                        _numeroSilla = Convert.ToInt32(ds.Tables[0].Rows[0]["numSilla"].ToString());

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#17
0
        public void carga_info_cliente(string codC)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select c.nombre,c.fecha,c.montoPagado,c.reserva,c.barra,c.codRestaurante,c.horaEntrada,c.fechaReserva,cr.codMesa,cr.pedidoS1,cr.pedidoS2,cr.pedidoS3,cr.pedidoS4,cr.buffetS1,cr.buffetS2,cr.buffetS3,cr.buffetS4 " +
                    "from Cliente c join ClienteReserva cr on c.codCliente = cr.codCliente where c.codCliente = @cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, codC);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el cliente", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _fechaE = ds.Tables[0].Rows[0]["fecha"].ToString();
                        _monto = Convert.ToDouble(ds.Tables[0].Rows[0]["montoPagado"].ToString());
                        _reservo = Convert.ToBoolean(ds.Tables[0].Rows[0]["reserva"].ToString());
                        _barra = Convert.ToBoolean(ds.Tables[0].Rows[0]["barra"].ToString());
                        _codR = ds.Tables[0].Rows[0]["codRestaurante"].ToString();
                        _horaE = ds.Tables[0].Rows[0]["horaEntrada"].ToString();
                        _fechaR = ds.Tables[0].Rows[0]["fechaReserva"].ToString();
                        _codMesa = ds.Tables[0].Rows[0]["codMesa"].ToString();
                        _pedidos1 = ds.Tables[0].Rows[0]["pedidoS1"].ToString();
                        _pedidos2 = ds.Tables[0].Rows[0]["pedidoS2"].ToString();
                        _pedidos3 = ds.Tables[0].Rows[0]["pedidoS3"].ToString();
                        _pedidos4 = ds.Tables[0].Rows[0]["pedidoS4"].ToString();
                        _listabs1 = ds.Tables[0].Rows[0]["buffetS1"].ToString();
                        _listabs2 = ds.Tables[0].Rows[0]["buffetS2"].ToString();
                        _listabs3 = ds.Tables[0].Rows[0]["buffetS3"].ToString();
                        _listabs4 = ds.Tables[0].Rows[0]["buffetS4"].ToString();

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#18
0
        public void guardar_pedidos(string _accion)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (_accion == "Insertar")
                {
                    sql = "Insert into ClienteBarra values(@cod,@pedido,@numSilla)";
                }
                else
                {
                    sql = "Update ClienteBarra SET" +
                        " detalleProducto=@pedido" +
                        " where codCliente=@cod";
                }
                ParamStruct[] parametros = new ParamStruct[3];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@pedido", SqlDbType.VarChar, _listaPedidos);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@numSilla", SqlDbType.VarChar, _numeroSilla);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@cod", SqlDbType.VarChar, _codigo);

                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar los pedidos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return;
                }
            }
        }
示例#19
0
        public void guardar_pedidos()
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                sql = "Insert into ClienteReserva values(@codM,@cod,@ps1,@ps2,@ps3,@ps4,@ls1,@ls2,@ls3,@ls4)";

                ParamStruct[] parametros = new ParamStruct[10];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codM", SqlDbType.VarChar, _codMesa);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@ps1", SqlDbType.VarChar, _pedidos1);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@ps2", SqlDbType.VarChar, _pedidos2);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@ps3", SqlDbType.VarChar, _pedidos3);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@ps4", SqlDbType.VarChar, _pedidos4);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@cod", SqlDbType.VarChar, _codigo);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 6, "@ls1", SqlDbType.VarChar, _listabs1);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 7, "@ls2", SqlDbType.VarChar, _listabs2);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 8, "@ls3", SqlDbType.VarChar, _listabs3);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 9, "@ls4", SqlDbType.VarChar, _listabs4);

                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar los pedidos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return;
                }
            }
        }
示例#20
0
        public bool guardar_Mesas(string accion)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);

            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            else
            {
                if (accion.Equals("Insertar"))
                {
                  sql = "Insert into Mesas values(@codMesas, @nombre, @numero, @cantSillas, @codRestaurante)";
                }
                else
                {
                    sql = "Update Mesas SET" +
                        " nombre=@nombre," +
                        " numero=@numero," +
                        " cantidadSillas=@cantSillas," +
                        " codRestaurante=@codRestaurante" +
                        " where codigoMesa=@codMesas";
                }
                ParamStruct[] parametros = new ParamStruct[5];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codMesas", SqlDbType.VarChar, _codMesa);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@nombre", SqlDbType.VarChar, _nombre);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@numero", SqlDbType.Int, _numero);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@cantSillas", SqlDbType.Int, _cantSillas);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@codRestaurante", SqlDbType.VarChar, _codRestaurante);
                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (numero_error != 0)
                {
                    MessageBox.Show(mensaje_error, "Error al guardar la mesa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return false;
                }
                else
                {
                    cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
                    return true;
                }
            }
        }
示例#21
0
        public void agregar_productos(string nombre, string nick)
        {
            string codRest = "";
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {
                DataSet ds;
                ds = retorna_codigo_Restaurante(nick);
                codRest = Convert.ToString(ds.Tables[0].Rows[0]["codRest"]);
                sql = "Insert into ProveedorRestaurante values(@codProveedor, @codRestaurante, @nombreProducto)";
                ParamStruct[] parametros = new ParamStruct[14];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codProveedor", SqlDbType.VarChar, _codigo);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@codRestaurante", SqlDbType.VarChar, codRest);
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@nombreProducto", SqlDbType.VarChar, nombre);
                cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
                cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
            }
        }
示例#22
0
        public void carga_info_rest(string codRest)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select nombre,direccion,especialidad,telefono,cantClientes,activo" +
                      " from Restaurante where codRestaurante=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, codRest);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el restaurante", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _direccion = ds.Tables[0].Rows[0]["direccion"].ToString();
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _especialidad = ds.Tables[0].Rows[0]["especialidad"].ToString();
                        _tel = Convert.ToInt32(ds.Tables[0].Rows[0]["telefono"].ToString());
                        _cantC = Convert.ToInt32(ds.Tables[0].Rows[0]["cantClientes"].ToString());
                        _activo = Convert.ToBoolean(ds.Tables[0].Rows[0]["Activo"].ToString());
                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#23
0
        public void carga_info_empleado(string codP)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombreP = "Error";
            }
            else
            {
                sql = "Select nombreProveedor, cedula, fecha, correo, direccionProveedor, telefono, celular, fax, primerApellido, segundoApellido, nombreContacto, direccioContacto, oficina, imagen" +
                      " from Proveedor where codProveedor=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, codP);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el empleado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombreP = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombreP = ds.Tables[0].Rows[0]["nombreProveedor"].ToString();
                        _cedula = ds.Tables[0].Rows[0]["cedula"].ToString();
                        _apellido1 = ds.Tables[0].Rows[0]["primerApellido"].ToString();
                        _fecha = ds.Tables[0].Rows[0]["fechaIngreso"].ToString();
                        _apellido2 = ds.Tables[0].Rows[0]["segundoApellido"].ToString();
                        _telefono = ds.Tables[0].Rows[0]["telefono"].ToString();
                        _celular = ds.Tables[0].Rows[0]["celular"].ToString();
                        _nombreC = ds.Tables[0].Rows[0]["nombreContacto"].ToString();
                        _oficina = ds.Tables[0].Rows[0]["oficina"].ToString();
                        _fax = ds.Tables[0].Rows[0]["fax"].ToString();
                        _correo = ds.Tables[0].Rows[0]["correo"].ToString();
                        _direccionP = ds.Tables[0].Rows[0]["direccionProveedor"].ToString();
                        _direccionC = ds.Tables[0].Rows[0]["direccionContacto"].ToString();
                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["foto"].ToString()))
                        {
                            _foto = (byte[])(ds.Tables[0].Rows[0]["foto"]);
                        }
                        else
                        {
                            _foto = null;
                        }
                    }
                    else
                    {
                        _nombreP = "Error";
                    }
                }

            }
        }
示例#24
0
        public string nombre_rest()
        {
            string nombreRest="";
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {
                sql = "Select nombre" +
                      " from Restaurante where codRestaurante=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, _codR);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Usuario/clave incorrecta", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        nombreRest = ds.Tables[0].Rows[0]["nombre"].ToString();

                    }

                }

            }
            return nombreRest;
        }
示例#25
0
 public bool guardar_Proveedor(string accion)
 {
     conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
     if (conexion == null)
     {
         MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
     {
         if (accion.Equals("Insertar"))
         {
             sql = "Insert into Proveedores values(@cod, @nombreP, @ced, @fecha, @correo, @direccionP, @telefono, @celular, @fax, @apellido1, @apellido2, @nombreC, @direccionC, @oficina, null)";
         }
         else
         {
             sql = "Update Proveedores SET" +
                 " nombreProveedor=@nombreP," +
                 " cedula=@ced," +
                 " fechaIngreso=@fecha," +
                 " correo=@correo," +
                 " direccionProveedor=@direccionP," +
                 " telefono=@telefono," +
                 " celular=@celular," +
                 " fax=@fax," +
                 " primerApellido=@apellido1," +
                 " segundoApellido=@apellido2," +
                 " nombreContacto=@nombreC," +
                 " direccionContacto=@direccionC," +
                 " oficina=@oficina,"+
                 " foto=null" +
                 " where codProveedor=@cod";
         }
         ParamStruct[] parametros = new ParamStruct[14];
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, _codigo);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@nombreP", SqlDbType.VarChar, _nombreP);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@ced", SqlDbType.VarChar, _cedula);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@fecha", SqlDbType.VarChar, _fecha);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@correo", SqlDbType.VarChar, _correo);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@direccionP", SqlDbType.VarChar, _direccionP);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 6, "@telefono", SqlDbType.VarChar, _telefono);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 7, "@celular", SqlDbType.VarChar, _celular);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 8, "@fax", SqlDbType.VarChar, _fax);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 9, "@apellido1", SqlDbType.VarChar, _apellido1);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 10, "@apellido2", SqlDbType.VarChar, _apellido2);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 11, "@nombreC", SqlDbType.VarChar, _nombreC);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 12, "@direccionC", SqlDbType.VarChar, _direccionC);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 13, "@oficina", SqlDbType.VarChar, _oficina);
         cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
         cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
         if (numero_error != 0)
         {
             MessageBox.Show(mensaje_error, "Error al guardar el Proveedor", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return false;
         }
         else
         {
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return true;
         }
     }
 }
示例#26
0
        public void carga_info_Heladas(string codHel)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select Bc.codBebidaHel, Bc.nombre, Bc.ingredientes, Bc.precio, R.nombre as nomrest,  Bc.descripcion,  Bc.imagen" +
                      " from BebidaHelada Bc INNER JOIN Restaurante R ON Bc.codRestaurante = R.codRestaurante where codBebidaHel=@codHel";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codHel", SqlDbType.VarChar, codHel);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener la informacion del producto", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _ingredientes = ds.Tables[0].Rows[0]["ingredientes"].ToString();
                        _precio = Convert.ToDecimal(ds.Tables[0].Rows[0]["precio"]);
                        _descripcion = ds.Tables[0].Rows[0]["descripcion"].ToString();
                        _codRestaurante= ds.Tables[0].Rows[0]["nomrest"].ToString();
                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["imagen"].ToString()))
                        {
                            _imagen = (byte[])(ds.Tables[0].Rows[0]["imagen"]);
                        }
                        else
                        {
                            _imagen = null;
                        }

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#27
0
        public void carga_info_Especiales(string codEsp)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select codEspeciales, nombre, ingredientes, detalle, precio, imagen" +
                      " from Especiales where codEspeciales = @codEsp";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codEsp", SqlDbType.VarChar, codEsp);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener la informacion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _ingredientes = ds.Tables[0].Rows[0]["ingredientes"].ToString();
                        _precio = Convert.ToDecimal(ds.Tables[0].Rows[0]["precio"]);
                        _detalle = ds.Tables[0].Rows[0]["detalle"].ToString();
                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["imagen"].ToString()))
                        {
                            _imagen = (byte[])(ds.Tables[0].Rows[0]["imagen"]);
                        }
                        else
                        {
                            _imagen = null;
                        }

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#28
0
        public void carga_info_Licores(string codLic)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select L.nombre,  M.nombre as nomMarca, P.nombre as nomPais, L.precioUnitario, L.precioBotella, R.nombre as nomRest,  L.cantidad, L.descripcion, L.imagen" +
                      " from Licores L INNER JOIN Restaurante R ON L.codRestaurante = R.codRestaurante INNER JOIN Pais P ON L.codPais = P.codigoPais INNER JOIN Marcas M ON L.codMarca = M.codMarca where codLicor=@codLic";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codLic", SqlDbType.VarChar, codLic);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener la informacion del producto", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _codMarca = ds.Tables[0].Rows[0]["nomMarca"].ToString();
                        _codPais = ds.Tables[0].Rows[0]["nomPais"].ToString();
                        _precioU = Convert.ToDecimal(ds.Tables[0].Rows[0]["precioUnitario"]);
                        _precioB = Convert.ToDecimal(ds.Tables[0].Rows[0]["precioBotella"]);
                        _codRestaurante = ds.Tables[0].Rows[0]["nomrest"].ToString();
                        _cantidad = Convert.ToInt32(ds.Tables[0].Rows[0]["cantidad"]);
                        _descripcion = ds.Tables[0].Rows[0]["descripcion"].ToString();
                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["imagen"].ToString()))
                        {
                            _imagen = (byte[])(ds.Tables[0].Rows[0]["imagen"]);
                        }
                        else
                        {
                            _imagen = null;
                        }

                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#29
0
        public void carga_info_Puesto(string codPuesto)
        {
            conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
            if (conexion == null)
            {
                MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _nombre = "Error";
            }
            else
            {
                sql = "Select nombre,internoRestaurante,externoRestaurante" +
                      " from Puestos where codPuesto=@cod";
                ParamStruct[] parametros = new ParamStruct[1];
                cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@cod", SqlDbType.VarChar, codPuesto);
                ds = cls_DAL.ejecuta_dataset(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
                if (ds == null)
                {
                    MessageBox.Show(mensaje_error, "Error al obtener el rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _nombre = "Error";
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        _nombre = ds.Tables[0].Rows[0]["nombre"].ToString();
                        _interno = Convert.ToBoolean(ds.Tables[0].Rows[0]["internoRestaurante"]);
                        _externo = Convert.ToBoolean(ds.Tables[0].Rows[0]["externoRestaurante"]);
                    }
                    else
                    {
                        _nombre = "Error";
                    }
                }

            }
        }
示例#30
0
 public bool guardar_Licores(string accion, string Restaurante)
 {
     conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
     string codRest = "";
     if (conexion == null)
     {
         MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
     {
         if (accion.Equals("Insertar"))
         {
             DataSet ds;
             ds = retorna_Cod_Restaurante(Restaurante);
             codRest = Convert.ToString(ds.Tables[0].Rows[0]["codRestaurante"]);
             sql = "Insert into Licores values(@codLicor, @nombre, @codMarca, @codPais, @precioU, @precioB, @codRestaurante, @cantidad, @descripcion, null)";
         }
         else
         {
             sql = "Update Licores SET" +
                 " nombre=@nombre," +
                 " codMarca=@codMarca," +
                 " codPais=@codPais," +
                 " precioUnitario=@precioU,"+
                 " precioBotella=@precioB," +
                 " cantidad=@cantidad," +
                 " descripcion=@descripcion," +
                 " imagen=null" +
                 " where codLicor=@codLicor";
         }
         ParamStruct[] parametros = new ParamStruct[9];
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@codLicor", SqlDbType.VarChar, _codLicor);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@nombre", SqlDbType.VarChar, _nombre);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@codMarca", SqlDbType.VarChar, _codMarca);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@codPais", SqlDbType.VarChar, _codPais);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@precioU", SqlDbType.Money, _precioU);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 5, "@precioB", SqlDbType.Money, _precioB);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 6, "@codRestaurante", SqlDbType.VarChar, codRest);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 7, "@cantidad", SqlDbType.Int, _cantidad);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 8, "@descripcion", SqlDbType.VarChar, _descripcion);
         cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
         cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
         if (numero_error != 0)
         {
             MessageBox.Show(mensaje_error, "Error al guardar el producto", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return false;
         }
         else
         {
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return true;
         }
     }
 }
示例#31
0
 public bool guardar_puesto(string accion)
 {
     conexion = cls_DAL.trae_conexion("Progra4", ref mensaje_error, ref numero_error);
     if (conexion == null)
     {
         MessageBox.Show(mensaje_error, "Error al obtener cadena de conexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
     {
         if (accion.Equals("Insertar"))
         {
             sql = "Insert into Puestos values(@cod,@nombre,@interno,@externo,@rol)";
         }
         else
         {
             sql = "Update Puestos SET" +
                 " nombre=@nombre," +
                 " internoRestaurante=@interno," +
                 " externoRestaurante=@externo," +
                 " codRol=@rol" +
                 " where codPuesto=@cod";
         }
         ParamStruct[] parametros = new ParamStruct[5];
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 0, "@nombre", SqlDbType.VarChar, _nombre);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 1, "@interno", SqlDbType.Bit, _interno);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 2, "@externo", SqlDbType.Bit, _externo);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 3, "@rol", SqlDbType.VarChar, _rol);
         cls_DAL.agregar_datos_estructura_parametros(ref parametros, 4, "@cod", SqlDbType.VarChar, _codigo);
         cls_DAL.conectar(conexion, ref mensaje_error, ref numero_error);
         cls_DAL.ejecuta_sqlcommand(conexion, sql, false, parametros, ref mensaje_error, ref numero_error);
         if (numero_error != 0)
         {
             MessageBox.Show(mensaje_error, "Error al guardar el Puesto", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return false;
         }
         else
         {
             cls_DAL.desconectar(conexion, ref mensaje_error, ref numero_error);
             return true;
         }
     }
 }