Пример #1
0
        public void llenar_datagastos()
        {
            M.Desconectar();
            decimal gastos       = 0;
            decimal pagos        = 0;
            decimal total        = 0;
            int     idcajaActual = 0;

            if (txtBuscarCaja.Text != "")
            {
                idcajaActual = Convert.ToInt32(txtBuscarCaja.Text);
            }

            //variable de tipo Sqlcommand
            SqlCommand comando = new SqlCommand();
            //variable SqlDataReader para leer los datos
            SqlDataReader dr;

            comando.Connection = M.conexion;
            //declaramos el comando para realizar la busqueda
            comando.CommandText = "select G.id,G.monto,G.descripcion,G.fecha from Gastos G inner join Caja C on G.fecha= C.fecha where C.id_caja=" + idcajaActual;
            //especificamos que es de tipo Text
            comando.CommandType = CommandType.Text;
            //se abre la conexion
            M.Conectar();
            //limpiamos los renglones de la datagridview
            dataGridView2.Rows.Clear();
            //a la variable DataReader asignamos  el la variable de tipo SqlCommand
            dr = comando.ExecuteReader();
            while (dr.Read())
            {
                //variable de tipo entero para ir enumerando los la filas del datagridview
                int renglon = dataGridView2.Rows.Add();
                // especificamos en que fila se mostrará cada registro
                // nombredeldatagrid.filas[numerodefila].celdas[nombrdelacelda].valor=\
                dataGridView2.Rows[renglon].Cells["id"].Value          = Convert.ToString(dr.GetInt32(dr.GetOrdinal("id")));
                dataGridView2.Rows[renglon].Cells["descripcion"].Value = dr.GetString(dr.GetOrdinal("descripcion"));
                dataGridView2.Rows[renglon].Cells["montogasto"].Value  = dr.GetDecimal(dr.GetOrdinal("monto")).ToString();

                gastos += Math.Round(Convert.ToDecimal(dr.GetDecimal(dr.GetOrdinal("monto"))), 2);
            }

            lbldeu.Text = gastos.ToString();

            if (lbling.Text != "...")
            {
                pagos = Convert.ToDecimal(lbling.Text);
            }

            if (lbldeu.Text != "...")
            {
                gastos = Convert.ToDecimal(lbldeu.Text);
            }

            total = pagos - gastos;

            lbltotal.Text = total.ToString();

            M.Desconectar();
        }
Пример #2
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            var nuevafecha = DateTime.Today.AddYears(1);

            if (licenciaAnterior == "")
            {
                licenciaAnterior = (new Guid()).ToString();
            }

            if (txtrenovar.Text != "" && txtrenovar.Text != null)
            {
                if (txtrenovar.Text == txtlicencia.Text && licenciaAnterior != txtrenovar.Text)
                {
                    using (SqlCommand cmdup = new SqlCommand("ActualizarLicencia", M.conexion))
                    {
                        cmdup.CommandType = CommandType.StoredProcedure;
                        cmdup.Parameters.Add("@licencia", SqlDbType.NVarChar).Value    = licenciaAnterior;
                        cmdup.Parameters.Add("@licenciaNew", SqlDbType.NVarChar).Value = txtlicencia.Text;
                        cmdup.Parameters.Add("@Fecha", SqlDbType.DateTime).Value       = nuevafecha;

                        M.Conectar();
                        cmdup.ExecuteNonQuery();
                        M.Desconectar();

                        Login.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Numero de Licencia Incorrecta");
                }
            }
        }
Пример #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            M.Desconectar();
            if (Program.Id > 0)
            {
                tickEstiloP();
            }
            else
            {
                using (SqlCommand cmd = new SqlCommand("RegistrarAlineamientoBalanceo", M.conexion))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@IdEmpleado", SqlDbType.Int).Value        = Convert.ToInt32(txtidEmp.Text);
                    cmd.Parameters.Add("@tipoDeTrabajo", SqlDbType.VarChar).Value = cbtipo.Text.ToUpper();
                    cmd.Parameters.Add("@vehiculo", SqlDbType.NVarChar).Value     = (txtMarca.Text + " " + txtmodelo.Text).ToUpper();
                    cmd.Parameters.Add("@AroGoma", SqlDbType.Int).Value           = Convert.ToInt32(txtaros.Text);
                    cmd.Parameters.Add("@fecha", SqlDbType.DateTime).Value        = Convert.ToDateTime(dtpFecha.Text);
                    cmd.Parameters.Add("@precio", SqlDbType.Decimal).Value        = Convert.ToDecimal(txtTotal.Text);
                    cmd.Parameters.Add("@nota", SqlDbType.NVarChar).Value         = txtnota.Text;

                    M.Conectar();
                    cmd.ExecuteNonQuery();
                    M.Desconectar();

                    using (SqlCommand cmd2 = new SqlCommand("pagos_re", M.conexion))
                    {
                        cmd2.CommandType = CommandType.StoredProcedure;

                        string idVenta = (Program.idcaja.ToString() + DateTime.Today.Second.ToString() + Program.IdEmpleadoLogueado.ToString());
                        //Tabla de pago
                        cmd2.Parameters.Add("@IdVenta", SqlDbType.Int).Value      = Convert.ToInt32(idVenta);
                        cmd2.Parameters.Add("@id_pago", SqlDbType.Int).Value      = Program.idPago;
                        cmd2.Parameters.Add("@id_caja", SqlDbType.Int).Value      = Program.idcaja;
                        cmd2.Parameters.Add("@monto", SqlDbType.Decimal).Value    = Program.Caja;
                        cmd2.Parameters.Add("@ingresos", SqlDbType.Decimal).Value = Program.pagoRealizado;

                        if (Program.Devuelta > 0)
                        {
                            cmd2.Parameters.Add("@egresos", SqlDbType.Decimal).Value = Program.Devuelta;
                        }
                        else
                        {
                            cmd2.Parameters.Add("@egresos", SqlDbType.Decimal).Value = 0;
                        }

                        cmd2.Parameters.Add("@fecha", SqlDbType.DateTime).Value = Convert.ToDateTime(Program.Fechapago);
                        cmd2.Parameters.Add("@deuda", SqlDbType.Decimal).Value  = 0;

                        M.Conectar();
                        cmd2.ExecuteNonQuery();
                        M.Desconectar();
                    }

                    Program.pagoRealizado = 0;
                    tickEstiloP();
                    clean();
                }
            }
        }
        public void cargardata()
        {
            M.Desconectar();
            double total = 0;

            limpiar();
            //variable de tipo Sqlcommand
            SqlCommand comando = new SqlCommand();
            //variable SqlDataReader para leer los datos
            SqlDataReader dr;

            comando.Connection = M.conexion;
            if (textBox1.Text != "")
            {
                //declaramos el comando para realizar la busqueda
                comando.CommandText = "select * from AlineamientoYBalanceo where vehiculo like '%" + textBox1.Text.ToUpper() + "%' and fecha BETWEEN convert(datetime, CONVERT(varchar(10), @fecha1, 103), 103) " +
                                      "AND convert(datetime, CONVERT(varchar(10), @fecha2, 103), 103) ORDER BY fecha";
                comando.Parameters.AddWithValue("@fecha1", dtpfecha1.Value);
                comando.Parameters.AddWithValue("@fecha2", dtpfecha2.Value);
            }
            else
            {
                //declaramos el comando para realizar la busqueda
                comando.CommandText = "select * from AlineamientoYBalanceo";
            }
            //especificamos que es de tipo Text
            comando.CommandType = CommandType.Text;
            //se abre la conexion
            M.Conectar();
            //limpiamos los renglones de la datagridview
            dataGridView1.Rows.Clear();
            //a la variable DataReader asignamos  el la variable de tipo SqlCommand
            dr = comando.ExecuteReader();
            while (dr.Read())
            {
                //variable de tipo entero para ir enumerando los la filas del datagridview
                int renglon = dataGridView1.Rows.Add();

                // especificamos en que fila se mostrará cada registro
                // nombredeldatagrid.filas[numerodefila].celdas[nombrdelacelda].valor=\
                dataGridView1.Rows[renglon].Cells["id"].Value            = Convert.ToString(dr.GetInt32(dr.GetOrdinal("id")));
                dataGridView1.Rows[renglon].Cells["tipoDeTrabajo"].Value = dr.GetString(dr.GetOrdinal("tipoDeTrabajo"));
                dataGridView1.Rows[renglon].Cells["vehiculo"].Value      = dr.GetString(dr.GetOrdinal("vehiculo"));
                dataGridView1.Rows[renglon].Cells["AroGoma"].Value       = Convert.ToString(dr.GetInt32(dr.GetOrdinal("AroGoma")));
                dataGridView1.Rows[renglon].Cells["precio"].Value        = dr.GetDecimal(dr.GetOrdinal("precio")).ToString("C2");
                dataGridView1.Rows[renglon].Cells["nota"].Value          = dr.GetString(dr.GetOrdinal("nota"));
                dataGridView1.Rows[renglon].Cells["fecha"].Value         = dr.GetDateTime(dr.GetOrdinal("fecha"));

                total         += Convert.ToDouble(dr.GetDecimal(dr.GetOrdinal("precio")));
                txttotalG.Text = total.ToString("C2");
            }
            M.Desconectar();
        }
Пример #5
0
        public void llenar_data(string id)
        {
            M.Desconectar();
            SqlCommand comando = new SqlCommand();
            //variable SqlDataReader para leer los datos
            SqlDataReader dr;

            comando.Connection = M.conexion;

            if (chkid.Checked && chknombre.Checked == false && id != null)
            {
                comando.CommandText = "select IdCotizacion,IdCliente = COALESCE(IdCliente, '0'),FechaCotizacion,Total,IdEmpleado," +
                                      "NombreCliente = COALESCE(NombreCliente, 'Sin Cliente') from Cotizacion WHERE " +
                                      "IdCotizacion = " + id + " ORDER BY IdCotizacion";
            }
            else if (chknombre.Checked && chkid.Checked == false && id != null)
            {
                comando.CommandText = "select IdCotizacion,IdCliente = COALESCE(IdCliente, '0'),FechaCotizacion,Total,IdEmpleado," +
                                      "NombreCliente = COALESCE(NombreCliente, 'Sin Cliente') from Cotizacion WHERE " +
                                      "NombreCliente LIKE '%" + id + "%' ORDER BY IdCotizacion";
            }
            else
            {
                comando.CommandText = "select IdCotizacion,IdCliente = COALESCE(IdCliente, '0'),FechaCotizacion,Total,IdEmpleado," +
                                      "NombreCliente = COALESCE(NombreCliente, 'Sin Cliente') from Cotizacion ORDER BY IdCotizacion";
            }

            //especificamos que es de tipo Text
            comando.CommandType = CommandType.Text;
            //se abre la conexion
            M.Conectar();
            //limpiamos los renglones de la datagridview
            dataGridView1.Rows.Clear();
            //a la variable DataReader asignamos  el la variable de tipo SqlCommand
            dr = comando.ExecuteReader();
            while (dr.Read())
            {
                //variable de tipo entero para ir enumerando los la filas del datagridview
                int renglon = dataGridView1.Rows.Add();
                // especificamos en que fila se mostrará cada registro
                // nombredeldatagrid.filas[numerodefila].celdas[nombrdelacelda].valor=\

                dataGridView1.Rows[renglon].Cells["id"].Value            = Convert.ToString(dr.GetInt32(dr.GetOrdinal("IdCotizacion")));
                dataGridView1.Rows[renglon].Cells["idEm"].Value          = Convert.ToString(dr.GetInt32(dr.GetOrdinal("IdEmpleado")));
                dataGridView1.Rows[renglon].Cells["total"].Value         = dr.GetDecimal(dr.GetOrdinal("Total")).ToString();
                dataGridView1.Rows[renglon].Cells["fecha"].Value         = dr.GetDateTime(dr.GetOrdinal("FechaCotizacion"));
                dataGridView1.Rows[renglon].Cells["nombrecliente"].Value = dr.GetString(dr.GetOrdinal("NombreCliente"));
            }

            M.Desconectar();
        }
Пример #6
0
        private void btnregistrar_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            if (!string.IsNullOrEmpty(lblmontocuadre.Text))
            {
                decimal montofinal = Convert.ToDecimal(lblmontocuadre.Text);

                using (SqlCommand cmd = new SqlCommand("Registrarcuadre", M.conexion))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    //tabla cuadre
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(lblidcaja.Text);
                    cmd.Parameters.Add("@descripcion", SqlDbType.NVarChar).Value = txtde5.Text + "," + txtde10.Text + "," + txtde25.Text + ","
                                                                                   + txtde50.Text + "," + txtde100.Text + "," + txtde200.Text + "," + txtde500.Text + "," + txtde1000.Text + "," + txtde2000.Text;
                    cmd.Parameters.Add("@monto", SqlDbType.Decimal).Value  = montofinal;
                    cmd.Parameters.Add("@Fecha", SqlDbType.DateTime).Value = DateTime.Today;

                    M.Conectar();
                    cmd.ExecuteNonQuery();
                    M.Desconectar();

                    To_pdf();
                    limpiar();
                    label18.Enabled = true;
                    MessageBox.Show("Cuadre Registrado");
                }
            }
            else
            {
                MessageBox.Show("Debe darle al boton de Sumar antes de registrar un nuevo Cuadre");
            }
        }
Пример #7
0
        public void obtenerFiladeCaja()
        {
            M.Desconectar();
            string cadSql = "SELECT id_caja, monto_inicial,fecha  FROM Caja where monto_final =0 AND fecha = convert(datetime,CONVERT(varchar(10), getdate(), 103),103)";

            M.Conectar();
            SqlCommand comando = new SqlCommand(cadSql, M.conexion);

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {
                tienefila = true;
            }
            M.Desconectar();
        }
Пример #8
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            if (txtCed.Text.Trim() != "")
            {
                if (txtUsu.Text.Trim() != "")
                {
                    if (txtCon.Text.Trim() != "")
                    {
                        if (txtConf.Text == txtCon.Text)
                        {
                            using (SqlCommand cmd = new SqlCommand("recuperarUsu", M.conexion))
                            {
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Add("@usu", SqlDbType.VarChar).Value    = txtUsu.Text;
                                cmd.Parameters.Add("@cedula", SqlDbType.VarChar).Value = Convert.ToString(txtCed.Text);
                                cmd.Parameters.Add("@clave", SqlDbType.VarChar).Value  = Convert.ToString(txtConf.Text);

                                M.Conectar();
                                cmd.ExecuteNonQuery();
                                M.Desconectar();

                                MessageBox.Show("Felicidades Ya Cambiaste la Contraseña");
                                limpiar();
                                panel1.Visible = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("La Confirmacion de la contraseña es incorrecta");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe Introducir la contraseña nueva del Usuario");
                    }
                }
                else
                {
                    MessageBox.Show("Debe Introducir el Nombre del Usuario que desea Recuperar");
                }
            }
            else
            {
                MessageBox.Show("Debe Introducir la Cedula del Usuario que desea Recuperar");
            }
        }
Пример #9
0
 public void EliminarCategoria(int idCat)
 {
     comando.Connection  = M.Conectar();
     comando.CommandText = "delete Categoria where IdCategoria=" + idCat;
     comando.CommandType = CommandType.Text;
     comando.ExecuteNonQuery();
     M.Desconectar();
 }
Пример #10
0
 public void EliminarEmpleado(int idEmpleado)
 {
     comando.Connection  = M.Conectar();
     comando.CommandText = "delete Empleado where IdEmpleado=" + idEmpleado;
     comando.CommandType = CommandType.Text;
     comando.ExecuteNonQuery();
     M.Desconectar();
 }
Пример #11
0
 public void EliminarProducto(int idProd)
 {
     comando.Connection  = M.Conectar();
     comando.CommandText = "delete Producto where IdProducto=" + idProd;
     comando.CommandType = CommandType.Text;
     comando.ExecuteNonQuery();
     M.Desconectar();
 }
Пример #12
0
        public void llenar()
        {
            M.Desconectar();
            string cadSql = "select montoactual from Caja where id_caja=" + Program.idcaja;

            SqlCommand comando = new SqlCommand(cadSql, M.conexion);

            M.Conectar();

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {
                txtCaja1.Text = leer["montoactual"].ToString();
            }
            M.Desconectar();
        }
Пример #13
0
        public void buscarid()
        {
            M.Desconectar();
            M.Conectar();
            string     sql = "select IdCategoria from Categoria where Descripcion =@id";
            SqlCommand cmd = new SqlCommand(sql, M.conexion);

            cmd.Parameters.AddWithValue("@id", cbxCategoria.Text);

            SqlDataReader reade = cmd.ExecuteReader();

            if (reade.Read())
            {
                id.Text              = Convert.ToString(reade["IdCategoria"]);
                txtdesc.Text         = cbxCategoria.Text;
                rbbuena.Checked      = false;
                rdmedia.Checked      = false;
                rbCero.Checked       = false;
                rbtodos.Checked      = false;
                radioButton1.Checked = false;
            }
            M.Desconectar();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            Program.IdEmpleado = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            if (Program.IdEmpleado > 0)
            {
                if (DevComponents.DotNetBar.MessageBoxEx.Show("¿Está Seguro que Desea Eliminar este Empleado.?", "Sistema de Ventas.", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    using (SqlCommand cmd = new SqlCommand("eliminarUsuario", M.conexion))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@IdEmpleado", SqlDbType.Int).Value = Program.IdEmpleado;

                        M.Conectar();
                        cmd.ExecuteNonQuery();
                        M.Desconectar();

                        using (SqlCommand cmd1 = new SqlCommand("eliminarEmpleado", M.conexion))
                        {
                            cmd1.CommandType = CommandType.StoredProcedure;
                            cmd1.Parameters.Add("@IdEmpleado", SqlDbType.Int).Value = Program.IdEmpleado;

                            M.Conectar();
                            cmd1.ExecuteNonQuery();
                            M.Desconectar();

                            MostrarListadoEmpleados();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Por Favor Seleccione un producto antes de eliminarlo");
            }
        }
Пример #15
0
        public void llenar()
        {
            M.Desconectar();
            string cadSql = "select top(1) IdCotizacion from Cotizacion order by IdCotizacion desc";

            M.Conectar();

            SqlCommand comando = new SqlCommand(cadSql, M.conexion);

            SqlDataReader leer = comando.ExecuteReader();

            int varcodigo;

            if (leer.Read() == true)
            {
                varcodigo       = Convert.ToInt32(leer["IdCotizacion"]) + 1;
                txtIdVenta.Text = varcodigo.ToString();
            }
            else
            {
                txtIdVenta.Text = "1";
            }
            M.Desconectar();
        }
Пример #16
0
        public void llenaridCliente(int idventa)
        {
            M.Desconectar();
            string cadSql = "select IdCliente =COALESCE(dbo.Venta.IdCliente,0) from Venta where idventa=" + idventa;

            M.Conectar();
            SqlCommand comando = new SqlCommand(cadSql, M.conexion);

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {
                Program.IdCliente = Convert.ToInt32(leer["IdCliente"]);
            }
            M.Desconectar();
        }
Пример #17
0
        public void llenar()
        {
            M.Desconectar();
            string     cadSql  = "select * from NomEmp";
            SqlCommand comando = new SqlCommand(cadSql, M.conexion);

            M.Conectar();
            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {
                lblDir.Text    = leer["DirEmp"].ToString();
                lblLogo.Text   = leer["NombreEmp"].ToString();
                lblTel1.Text   = leer["Tel1"].ToString();
                lblTel2.Text   = leer["Tel2"].ToString();
                lblCorreo.Text = leer["Correo"].ToString();
                lblrnc.Text    = leer["RNC"].ToString();
            }
            M.Desconectar();
        }
Пример #18
0
        private void button1_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            Program.IdCliente = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            if (Program.IdCliente > 0)
            {
                M.Conectar();
                string     sql = "select IdCliente from Venta where IdCliente =@id";
                SqlCommand cmd = new SqlCommand(sql, M.conexion);
                cmd.Parameters.AddWithValue("@id", Program.IdCliente);

                SqlDataReader reade = cmd.ExecuteReader();
                if (reade.Read())
                {
                    MessageBox.Show("No se Puede eliminar porque el Cliente tiene Ventas Registradas");
                }
                else
                {
                    if (DevComponents.DotNetBar.MessageBoxEx.Show("¿Está Seguro que Desea Eliminar este Cliente.?", "Sistema de Ventas.", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                    {
                        using (SqlCommand cmd1 = new SqlCommand("eliminarCliente", M.conexion))
                        {
                            cmd1.CommandType = CommandType.StoredProcedure;
                            cmd1.Parameters.Add("@id", SqlDbType.Int).Value = Program.IdCliente;

                            cmd1.ExecuteNonQuery();
                            ListarClientes();
                            ListarClientes1();
                        }
                    }
                }
                M.Desconectar();
            }
            else
            {
                MessageBox.Show("Por Favor Seleccione un cliente antes de eliminarlo");
            }
        }
Пример #19
0
        public static decimal Ganancias(List <int> ventasIds)
        {
            decimal ganancia = 0;

            try
            {
                if (ventasIds is null || ventasIds.Count == 0)
                {
                    ventasIds = idsVentas;
                }

                if (ventasIds.Count > 0 && listVentas.Count > 0)
                {
                    clsManejador M = new clsManejador();
                    foreach (var id in ventasIds)
                    {
                        string     cadSql  = $"select Sum(GananciaVenta) as ganancia from DetalleVenta where DetalleVenta.IdVenta ={id} group by DetalleVenta.IdVenta";
                        SqlCommand comando = new SqlCommand(cadSql, M.conexion);
                        M.Conectar();
                        SqlDataReader leer = comando.ExecuteReader();
                        if (leer.Read() == true)
                        {
                            var monto = Convert.ToDecimal(leer["ganancia"]) > 0 ? Convert.ToDecimal(leer["ganancia"]) : 0;
                            ganancia += monto;
                        }
                        M.Desconectar();
                    }
                }
                return(ganancia);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            return(ganancia);
        }
        public void llenardatoscomprobantes(int id)
        {
            M.Desconectar();
            M.Conectar();
            string     sql = "SELECT * FROM ncf INNER JOIN Comprobantes ON ncf.id_ncf = Comprobantes.id_comprobante where ncf.id_ncf=@id";
            SqlCommand cmd = new SqlCommand(sql, M.conexion);

            cmd.Parameters.AddWithValue("@id", id);

            SqlDataReader reade = cmd.ExecuteReader();

            if (reade.Read())
            {
                txtfinal.Text  = Convert.ToString(reade["secuenciaF"]);
                txtinicio.Text = Convert.ToString(reade["secuenciaIni"]);

                dtpinicio.Value = Convert.ToDateTime(reade["fecha_inicio"]);
                dtpfinal.Value  = Convert.ToDateTime(reade["fecha_final"]);
            }
            M.Desconectar();
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            if (M.conexion != null && M.conexion.State == ConnectionState.Open)
            {
                M.Desconectar();
            }

            clsProducto P = new clsProducto();

            if (txtProducto.Text.Trim() != "")
            {
                if (txtMarca.Text.Trim() != "")
                {
                    if (txtPCompra.Text.Trim() != "")
                    {
                        if (txtPVenta.Text.Trim() != "")
                        {
                            if (txtStock.Text.Trim() != "")
                            {
                                using (SqlCommand cmd = new SqlCommand("RegistrarProducto", M.conexion))
                                {
                                    var exist = clsGenericList.listProducto.FirstOrDefault(x => x.m_Producto == txtProducto.Text.ToUpper() && x.m_Marca == txtMarca.Text.ToUpper());
                                    if (exist != null)
                                    {
                                        DevComponents.DotNetBar.MessageBoxEx.Show("El producto ya existe", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        M.Desconectar();
                                    }
                                    else
                                    {
                                        cmd.CommandType = CommandType.StoredProcedure;
                                        cmd.Parameters.Add("@IdCategoria", SqlDbType.Int).Value        = cbxCategoria.SelectedValue;
                                        cmd.Parameters.Add("@Nombre", SqlDbType.NVarChar).Value        = txtProducto.Text.ToUpper();
                                        cmd.Parameters.Add("@Marca", SqlDbType.NVarChar).Value         = txtMarca.Text.ToUpper();
                                        cmd.Parameters.Add("@Stock", SqlDbType.Int).Value              = txtStock.Text;
                                        cmd.Parameters.Add("@PrecioCompra", SqlDbType.Decimal).Value   = txtPCompra.Text;
                                        cmd.Parameters.Add("@PrecioVenta", SqlDbType.Decimal).Value    = txtPVenta.Text;
                                        cmd.Parameters.Add("@itbis", SqlDbType.Decimal).Value          = txtitbis.Text;
                                        cmd.Parameters.Add("@TipoGoma", SqlDbType.NVarChar).Value      = cbtipo.Text;
                                        cmd.Parameters.Add("@FechaVencimiento", SqlDbType.Date).Value  = dateTimePicker1.Text;
                                        cmd.Parameters.Add("@FechaModificacion", SqlDbType.Date).Value = dateTimePicker1.Text;
                                        cmd.Parameters.Add("@Pmax", SqlDbType.Decimal).Value           = 0;
                                        cmd.Parameters.Add("@Pmin", SqlDbType.Decimal).Value           = 0;

                                        M.Conectar();
                                        cmd.ExecuteNonQuery();
                                        M.Desconectar();

                                        Producto product = new Producto();
                                        int      idP     = clsGenericList.listProducto.Count + 1;
                                        product.m_IdP               = idP;
                                        product.m_IdCategoria       = Convert.ToInt32(cbxCategoria.SelectedValue);
                                        product.m_Producto          = txtProducto.Text;
                                        product.m_tipoGoma          = cbtipo.Text;
                                        product.m_itbis             = Convert.ToDecimal(txtitbis.Text);
                                        product.m_PrecioVenta       = Convert.ToDecimal(txtPVenta.Text);
                                        product.m_PrecioCompra      = Convert.ToDecimal(txtPCompra.Text);
                                        product.m_Preciomax         = 0;
                                        product.m_Preciomin         = 0;
                                        product.m_Stock             = Convert.ToInt32(txtStock.Text);
                                        product.m_Marca             = txtMarca.Text;
                                        product.m_FechaModificacion = dateTimePicker1.Value;
                                        product.m_FechaVencimiento  = dateTimePicker1.Value;

                                        clsGenericList.listProducto.Add(product);

                                        P.Listar();
                                        ListarElementos();
                                        Limpiar();
                                    }
                                }
                            }
                            else
                            {
                                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Stock del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtStock.Focus();
                            }
                        }
                        else
                        {
                            DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Precio de Venta del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtPVenta.Focus();
                        }
                    }
                    else
                    {
                        DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Precio de Compra del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPCompra.Focus();
                    }
                }
                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Marca del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtMarca.Focus();
                }
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Nombre del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtProducto.Focus();
            }
        }
Пример #22
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            Char EstadoCivil = 'S';

            switch (cbxEstadoCivil.SelectedIndex)
            {
            case 1: EstadoCivil = 'S'; break;

            case 2: EstadoCivil = 'C'; break;

            case 3: EstadoCivil = 'D'; break;

            case 4: EstadoCivil = 'V'; break;
            }

            if (txtDni.Text.Trim() != "")
            {
                if (txtApellidos.Text.Trim() != "")
                {
                    if (txtNombres.Text.Trim() != "")
                    {
                        if (txtDireccion.Text.Trim() != "")
                        {
                            if (comboBox1.SelectedValue != null)
                            {
                                using (SqlCommand cmd = new SqlCommand("MantenimientoEmpleados", M.conexion))
                                {
                                    cmd.CommandType = CommandType.StoredProcedure;

                                    cmd.Parameters.Add("@IdCargo", SqlDbType.NVarChar).Value   = Convert.ToInt32(comboBox1.SelectedValue);
                                    cmd.Parameters.Add("@Dni", SqlDbType.NVarChar).Value       = txtDni.Text;
                                    cmd.Parameters.Add("@Apellidos", SqlDbType.NVarChar).Value = txtApellidos.Text;
                                    cmd.Parameters.Add("@Nombres", SqlDbType.NVarChar).Value   = txtNombres.Text;
                                    cmd.Parameters.Add("@Direccion", SqlDbType.NVarChar).Value = txtDireccion.Text;
                                    cmd.Parameters.Add("@EstadoCivil", SqlDbType.Char).Value   = EstadoCivil;
                                    cmd.Parameters.Add("@Sexo", SqlDbType.Char).Value          = rbnMasculino.Checked == true ? 'M' : 'F';
                                    cmd.Parameters.Add("@FechaNac", SqlDbType.Date).Value      = dateTimePicker1.Text;

                                    DevComponents.DotNetBar.MessageBoxEx.Show("Se Realizo Correctamente", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    M.Conectar();
                                    cmd.ExecuteNonQuery();
                                    M.Desconectar();
                                    Limpiar();
                                }
                            }
                            else
                            {
                                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese el cargo que ejercera este Empleado", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Dirección del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtDireccion.Focus();
                        }
                    }
                    else
                    {
                        DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Nombre(s) del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtNombres.Focus();
                    }
                }
                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Apellidos del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtApellidos.Focus();
                }
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese N° de D.N.I del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtDni.Focus();
            }
        }
Пример #23
0
        private void button1_Click(object sender, EventArgs e)
        {
            M.Desconectar();
            if (txtDni.Text.Trim() != "")
            {
                if (txtApellidos.Text.Trim() != "")
                {
                    if (txtNombres.Text.Trim() != "")
                    {
                        if (txtDireccion.Text.Trim() != "")
                        {
                            if (txtTelefono.Text.Trim() != "")
                            {
                                if (Program.Evento == 0)
                                {
                                    using (SqlCommand cmd = new SqlCommand("RegistrarCliente", M.conexion))
                                    {
                                        cmd.CommandType = CommandType.StoredProcedure;

                                        cmd.Parameters.Add("@Dni", SqlDbType.NVarChar).Value       = txtDni.Text;
                                        cmd.Parameters.Add("@Apellidos", SqlDbType.NVarChar).Value = txtApellidos.Text;
                                        cmd.Parameters.Add("@Nombres", SqlDbType.NVarChar).Value   = txtNombres.Text;
                                        cmd.Parameters.Add("@Direccion", SqlDbType.NVarChar).Value = txtDireccion.Text;
                                        cmd.Parameters.Add("@Telefono", SqlDbType.NVarChar).Value  = txtTelefono.Text;
                                        cmd.Parameters.Add("@estado", SqlDbType.Int).Value         = 1;

                                        DevComponents.DotNetBar.MessageBoxEx.Show("Se Registro Correctamente", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        M.Conectar();
                                        cmd.ExecuteNonQuery();
                                        M.Desconectar();

                                        Limpiar();
                                    }
                                }
                            }
                            else
                            {
                                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese N° de Teléfono o Celular.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                txtTelefono.Focus();
                            }
                        }
                        else
                        {
                            DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Dirección del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtDireccion.Focus();
                        }
                    }
                    else
                    {
                        DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Nombre(s) del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtNombres.Focus();
                    }
                }
                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese Apellidos del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtApellidos.Focus();
                }
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Por Favor Ingrese N° de D.N.I del Cliente.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtDni.Focus();
            }
        }