예제 #1
0
        public static int AgregarHistorial(MySqlConnection conexion, Historial pHistoria)
        {
            int          retorno = 0;
            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `salonbelleza`.`historial` (`Cliente_idCliente`, `Empleado_idEmpleado`, `Fecha`) VALUES ('{0}', '{1}', '{2}');", pHistoria.IdCliente, pHistoria.IdEmpleado, pHistoria.Fecha), conexion);

            retorno = comando.ExecuteNonQuery();
            return(retorno);
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Validar())
            {
                try
                {
                    if (conexion.abrirConexion() == true)
                    {
                        Clases.Factura pFactura = new Clases.Factura();
                        pFactura.FechaFactura = txtFecha.Text;
                        pFactura.IdCliente    = Convert.ToInt32(lookCliente.Text);
                        pFactura.IdServicio   = Convert.ToInt32(lookServicio.Text);
                        pFactura.IdEmpleado   = Convert.ToInt32(lookEmpleado.Text);
                        pFactura.TipoPago     = cmbTipoPago.Text;
                        pFactura.subtotal     = Convert.ToDecimal(txtSubTotal.Text);
                        pFactura.impuesto     = Convert.ToDecimal(txtImpuesto.Text);
                        pFactura.total        = Convert.ToDecimal(txtTotal.Text);

                        Clases.Historial pHistorial = new Clases.Historial();
                        pHistorial.Fecha      = txtFecha.Text;
                        pHistorial.IdCliente  = Convert.ToInt32(lookCliente.Text);
                        pHistorial.IdEmpleado = Convert.ToInt32(lookEmpleado.Text);

                        int resultado, resulatdo2;
                        resulatdo2 = Clases.Historial.AgregarHistorial(conexion.conexion, pHistorial);
                        resultado  = Clases.Factura.AgregarFactura(conexion.conexion, pFactura);
                        if (resultado > 0 && resulatdo2 > 0)
                        {
                            txtSubTotal.Clear();
                            txtImpuesto.Clear();
                            txtTotal.Clear();
                            sqlDataSource4.Fill();
                        }
                        conexion.cerrarConexion();
                    }
                    else
                    {
                        MessageBox.Show("No se Conecto!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #3
0
        public static IList <Historial> Buscar(MySqlConnection con, int idCliente)
        {
            List <Historial> lista   = new List <Historial>();
            MySqlCommand     comando = new MySqlCommand(string.Format("SELECT Cliente_idCliente, Empleado_idEmpleado, Fecha FROM salonbelleza.historial where Cliente_idCliente = {0};", idCliente), con);
            MySqlDataReader  reader  = comando.ExecuteReader();

            while (reader.Read())
            {
                Historial historial = new Historial();
                historial.IdCliente  = reader.GetInt16(0);
                historial.IdEmpleado = reader.GetInt16(1);
                historial.Fecha      = reader.GetString(2);

                lista.Add(historial);
            }
            return(lista);
        }