Ejemplo n.º 1
0
        public static void Actualizar(cVendedor Vendedor)
        {
            try
            {
                //Declaramos la conexion hacia la base de datos
                using (MySqlConnection Conn = new MySqlConnection(cConexion.CadenaConexion()))
                {
                    Conn.Open();
                    //Nombre del procedimiento
                    string StoreProc = "uspActualizarVend";
                    //Creamos el command para la insercion
                    MySqlCommand Cmd = new MySqlCommand(StoreProc, Conn);
                    Cmd.CommandType = CommandType.StoredProcedure;

                    //Parametros
                    Cmd.Parameters.AddWithValue("p_Codigo", Vendedor.Codigo);
                    Cmd.Parameters.AddWithValue("p_Nombre", Vendedor.Nombre);
                    Cmd.Parameters.AddWithValue("p_Apellido", Vendedor.Apellido);
                    Cmd.Parameters.AddWithValue("p_Telefono", Vendedor.Telefono);
                    Cmd.Parameters.AddWithValue("p_Celular", Vendedor.Celular);
                    Cmd.Parameters.AddWithValue("p_Cedula", Vendedor.Cedula);
                    Cmd.Parameters.AddWithValue("p_Comision", Vendedor.Comision);
                    Cmd.Parameters.AddWithValue("p_Eliminado", Vendedor.Eliminado);
                    Cmd.ExecuteNonQuery();
                }
            }
            catch (MySqlException Ex)
            {
                throw Ex;
            }
        }
Ejemplo n.º 2
0
        private void verToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cVendedor cVendedor = new cVendedor();

            cVendedor.Show();
            cVendedor.MdiParent = this;
        }
Ejemplo n.º 3
0
        private void ConsultarVendedoresToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cVendedor consulta = new cVendedor();

            consulta.MdiParent = this;
            consulta.Show();
        }
Ejemplo n.º 4
0
        private void vendedoresToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cVendedor ConsultaVendedor = new cVendedor();

            ConsultaVendedor.MdiParent = this;
            ConsultaVendedor.Show();
        }
Ejemplo n.º 5
0
        protected void rdGridVendedores_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cVendedor oVendedor = new cVendedor(ref oConn);
                oVendedor.CodNkey = oIsUsuario.CodNkey;
                oVendedor.Nombre  = rdTxtNombreDeudor.Text;
                DataTable dtVendedor = oVendedor.Get();
                rdGridVendedores.DataSource = dtVendedor;
            }
            oConn.Close();
        }
Ejemplo n.º 6
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            //Eliminar vendedor
            DialogResult Resultado = MessageBox.Show("Se eliminara el vendedor del sistema, ¿Esta seguro que desea continuar?", "Eliminar vendedor", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Resultado == DialogResult.Yes)
            {
                VendedorBL ObjetoVendedor = new VendedorBL();
                cVendedor  Vendedor       = ObjetoVendedor.BuscarPorID(VendedorID);

                Vendedor.Eliminado = true;

                ObjetoVendedor.GuardarCambios(Vendedor);
            }
        }
Ejemplo n.º 7
0
 private void MostrarDatos(cVendedor Vendedor)
 {
     try
     {
         txtCodigo.Text   = Vendedor.Codigo.ToString();
         txtNombre.Text   = Vendedor.Nombre;
         txtApellido.Text = Vendedor.Apellido;
         txtCelular.Text  = Vendedor.Celular;
         txtCedula.Text   = Vendedor.Cedula;
         txtTelefono.Text = Vendedor.Telefono;
         txtComision.Text = Vendedor.Comision.ToString();
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Ex.Message, "Error al mostrar informacion de vendedor", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 8
0
        public static List <cVendedor> Listar()
        {
            try
            {
                //Declaramos la conexion hacia la base de datos
                using (MySqlConnection Conn = new MySqlConnection(cConexion.CadenaConexion()))
                {
                    Conn.Open();
                    //Nombre del procedimiento
                    string StoreProc = "uspListarVend";
                    //Creamos el command para la insercion
                    MySqlCommand Cmd = new MySqlCommand(StoreProc, Conn);
                    Cmd.CommandType = CommandType.StoredProcedure;
                    //Ejecutamos el lector
                    MySqlDataReader Reader = Cmd.ExecuteReader();


                    List <cVendedor> Lista = new List <cVendedor>();
                    while (Reader.Read())
                    {
                        cVendedor Vendedor = new cVendedor();
                        Vendedor.Codigo   = Reader.GetInt32(Reader.GetOrdinal("Codigo"));
                        Vendedor.Nombre   = Reader.GetString(Reader.GetOrdinal("Nombre"));
                        Vendedor.Cedula   = Reader.IsDBNull(Reader.GetOrdinal("Cedula")) ? null : Reader.GetString(Reader.GetOrdinal("Cedula"));
                        Vendedor.Telefono = Reader.IsDBNull(Reader.GetOrdinal("Telefono")) ? null : Reader.GetString(Reader.GetOrdinal("Telefono"));
                        Vendedor.Celular  = Reader.IsDBNull(Reader.GetOrdinal("Celular")) ? null : Reader.GetString(Reader.GetOrdinal("Celular"));
                        Vendedor.Comision = Reader.IsDBNull(Reader.GetOrdinal("Comision")) ? 0 : Reader.GetDecimal(Reader.GetOrdinal("Comision"));

                        //Agregamos el articulo a la lista
                        Lista.Add(Vendedor);
                    }
                    //Cerramos la conexion
                    Conn.Close();
                    //Retornamos la lista de clientes
                    return(Lista);
                }
            }
            catch (MySqlException Ex)
            {
                throw Ex;
            }
        }
Ejemplo n.º 9
0
 public void GuardarCambios(cVendedor Vendedor)
 {
     try
     {
         //Si el almacen existe entonces actualizamos
         if (VendedorDA.Existe(Vendedor.Codigo))
         {
             VendedorDA.Actualizar(Vendedor);
         }
         else
         //Si el almacen es nuevo entonces creamos
         {
             VendedorDA.Crear(Vendedor);
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
 }
Ejemplo n.º 10
0
        private cVendedor ObtenerDatos()
        {
            try
            {
                cVendedor Vendedor = new cVendedor();
                Vendedor.Codigo   = Convert.ToInt32(txtCodigo.Text);
                Vendedor.Nombre   = txtNombre.Text;
                Vendedor.Apellido = txtApellido.Text;
                Vendedor.Telefono = txtTelefono.Text;
                Vendedor.Celular  = txtCelular.Text;
                Vendedor.Cedula   = txtCedula.Text;
                Vendedor.Comision = ObtenerComision();

                return(Vendedor);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Error en la obtencion de datos del vendedor" + ' ' + Ex.Message, "Error en obtencion de datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Ejemplo n.º 11
0
        public static cVendedor BuscarPorID(int ID)
        {
            try
            {
                //Declaramos la conexion hacia la base de datos
                using (MySqlConnection Conn = new MySqlConnection(cConexion.CadenaConexion()))
                {
                    Conn.Open();
                    //Nombre del procedimiento
                    string StoreProc = "uspBuscarVendPorCodigo";
                    //Creamos el command para la insercion
                    MySqlCommand Cmd = new MySqlCommand(StoreProc, Conn);
                    Cmd.CommandType = CommandType.StoredProcedure;
                    //Parametros
                    Cmd.Parameters.AddWithValue("p_Codigo", ID);
                    MySqlDataReader Reader = Cmd.ExecuteReader();

                    cVendedor Vendedor = new cVendedor();
                    while (Reader.Read())
                    {
                        Vendedor.Codigo   = Reader.GetInt32(Reader.GetOrdinal("Codigo"));
                        Vendedor.Nombre   = Reader.GetString(Reader.GetOrdinal("Nombre"));
                        Vendedor.Apellido = Reader.GetString(Reader.GetOrdinal("Apellido"));
                        Vendedor.Cedula   = Reader.GetString(Reader.GetOrdinal("Cedula"));
                        Vendedor.Celular  = Reader.GetString(Reader.GetOrdinal("Celular"));
                        Vendedor.Telefono = Reader.GetString(Reader.GetOrdinal("Telefono"));
                        Vendedor.Comision = Reader.GetDecimal(Reader.GetOrdinal("Comision"));
                    }
                    //Cerramos la conexion
                    Conn.Close();
                    //Retornamos los datos
                    return(Vendedor);
                }
            }
            catch (MySqlException Ex)
            {
                throw Ex;
            }
        }
        private void CargarCiudadProvincia(Int32 CodVendedor)
        {
            cVendedor ven  = new cVendedor();
            DataTable trdo = ven.GetVendedorxCodVendedor(CodVendedor);

            if (trdo.Rows.Count > 0)
            {
                if (trdo.Rows[0]["CodVendedor"].ToString() != "")
                {
                    if (trdo.Rows[0]["CodProvincia"].ToString() != "")
                    {
                        Int32 CodProv = Convert.ToInt32(trdo.Rows[0]["CodProvincia"].ToString());
                        CargarCiudadxProv(CodProv);
                        cmbProvincia.SelectedValue = CodProv.ToString();
                    }

                    if (trdo.Rows[0]["CodCiudad"].ToString() != "")
                    {
                        Int32 CodCiudad = Convert.ToInt32(trdo.Rows[0]["CodCiudad"].ToString());
                        cmb_CodCiudad.SelectedValue = CodCiudad.ToString();
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private void LeerVendedores()
        {
            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet;
            Excel.Range       range;

            string str  = "";
            int    rCnt = 0;
            int    cCnt = 0;
            int    rw   = 0;
            int    cl   = 0;

            string Ruta = txt_Ruta.Text;

            // string Ruta = "C:\\SISTEMA\\LISTA.xlsx";
            //  string Ruta = "D:\\AG\\LISTA.xlsx";
            xlApp       = new Excel.Application();
            xlWorkBook  = xlApp.Workbooks.Open(Ruta, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            range = xlWorkSheet.UsedRange;
            rw    = range.Rows.Count;
            cl    = range.Columns.Count;
            string     NroDocumento = "";
            string     Nombre       = "";
            string     Apellido     = "";
            Double     Telefono     = 0;
            string     Direccion    = "";
            string     Ciudad       = "";
            string     Provincia    = "";
            Int32      CodProvincia = 0;
            Int32      CodCiudad    = 0;
            cProvincia objProvincia = new cProvincia();
            cCiudad    objCiudad    = new cCiudad();
            cVendedor  vend         = new cVendedor();

            string Codigo = "";
            Int32? Id     = 0;


            cArticulo Articulo = new Clases.cArticulo();

            for (rCnt = 2; rCnt <= rw; rCnt++)
            {
                for (cCnt = 1; cCnt <= cl; cCnt++)
                {
                    txtProceso.Text = rCnt.ToString();
                    switch (cCnt)
                    {
                    case 1:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Id = (Int32)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        break;

                    case 2:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            NroDocumento = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                            // NroDocumento = NroDocumento.Replace (".","");
                        }

                        else
                        {
                            NroDocumento = "";
                        }
                        break;

                    case 3:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Nombre = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        else
                        {
                            Nombre = "";
                        }
                        // string[] vec = tip.Split();
                        // Tipo = vec[0];
                        break;

                    case 4:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {     //Codigo
                            Apellido = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                            // string[] vec = Cod.Split(); ;
                            //Codigo = vec[0];
                        }
                        else
                        {
                            Apellido = "";
                        }

                        break;

                    case 8:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Direccion = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        else
                        {
                            Direccion = "";
                        }
                        break;

                    case 9:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Ciudad = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        else
                        {
                            Ciudad = "";
                        }
                        break;

                    case 10:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Provincia = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        else
                        {
                            Provincia = "";
                        }
                        break;

                    case 22:
                        if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
                        {
                            Telefono = (Double)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
                        }
                        else
                        {
                            Telefono = 0;
                        }
                        break;
                    }
                }
                Nombre       = Nombre.Replace("'", "");
                CodProvincia = objProvincia.GetCodxNombre(Provincia);
                if (CodProvincia == -1)
                {
                    if (Provincia != "")
                    {
                        CodProvincia = objProvincia.Insertar(Provincia);
                    }
                }
                CodCiudad = objCiudad.GetCodxNombre(Ciudad);
                if (CodCiudad == -1)
                {
                    if (Ciudad.Trim() != "")
                    {
                        CodCiudad = objCiudad.Insertar(Ciudad, CodProvincia);
                    }
                }
                cVendedor ven = new cVendedor();
                if (ven.Existe(NroDocumento) == false)
                {
                    ven.Insertar(NroDocumento, Apellido, Nombre, Telefono.ToString(), CodCiudad, Direccion);
                }
            }
            string msj = "Filas recorridos " + rCnt.ToString();

            MessageBox.Show(msj);
            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            // Marshal.ReleaseComObject(xlWorkSheet);
            // Marshal.ReleaseComObject(xlWorkBook);
            //  Marshal.ReleaseComObject(xlApp);
        }
        private void form_FormClosing(object sender, FormClosingEventArgs e)
        {
            cVendedor ven   = new cVendedor();
            string    Tabla = Principal.TablaPrincipal;

            if (Principal.CodigoPrincipalAbm != null)
            {
                switch (Tabla)
                {
                case "Vendedor":
                    Int32     CodVendedor = Convert.ToInt32(Principal.CodigoPrincipalAbm);
                    DataTable trdo        = ven.GetVendedorxCodVendedor(CodVendedor);
                    if (trdo.Rows.Count > 0)
                    {
                        if (trdo.Rows.Count > 0)
                        {
                            if (trdo.Rows[0]["CodVendedor"].ToString() != "")
                            {
                                txtNroDocumento.Text = trdo.Rows[0]["NroDocumento"].ToString();
                                txtCodVendedor.Text  = trdo.Rows[0]["CodVendedor"].ToString();
                                txtNombre.Text       = trdo.Rows[0]["Nombre"].ToString();
                                txtApellido.Text     = trdo.Rows[0]["Apellido"].ToString();
                                txtDireccion.Text    = trdo.Rows[0]["Direccion"].ToString();
                                txtTelefono.Text     = trdo.Rows[0]["Telefono"].ToString();

                                if (trdo.Rows[0]["CodProvincia"].ToString() != "")
                                {
                                    Int32 CodProv = Convert.ToInt32(trdo.Rows[0]["CodProvincia"].ToString());
                                    CargarCiudadxProv(CodProv);
                                    cmbProvincia.SelectedValue = CodProv.ToString();
                                }

                                if (trdo.Rows[0]["CodCiudad"].ToString() != "")
                                {
                                    Int32 CodCiudad = Convert.ToInt32(trdo.Rows[0]["CodCiudad"].ToString());
                                    cmbCiudad.SelectedValue = CodCiudad.ToString();
                                }
                            }
                        }
                    }
                    break;

                case "Joya":
                    cJoya     joya    = new cJoya();
                    Int32     CodJoya = Convert.ToInt32(Principal.CodigoPrincipalAbm);
                    DataTable trJoya  = joya.GetJoyaxCodJoya(CodJoya);
                    if (trJoya.Rows.Count > 0)
                    {
                        if (trJoya.Rows[0]["CodJoya"].ToString() != "")
                        {
                            txtCodigo.Text     = trJoya.Rows[0]["Codigo"].ToString();
                            txtCodJoya.Text    = trJoya.Rows[0]["CodJoya"].ToString();
                            txtNombreJoya.Text = trJoya.Rows[0]["Nombre"].ToString();
                            txtStock.Text      = trJoya.Rows[0]["Stock"].ToString();
                            txtPrecio.Text     = trJoya.Rows[0]["PrecioVenta"].ToString();
                            if (trJoya.Rows[0]["CodTipo"].ToString() != "")
                            {
                                cmbTipo.SelectedValue = trJoya.Rows[0]["CodTipo"].ToString();
                            }
                            if (txtPrecio.Text != "")
                            {
                                txtPrecio.Text = fun.SepararDecimales(txtPrecio.Text);
                                txtPrecio.Text = fun.FormatoEnteroMiles(txtPrecio.Text);
                            }
                            txtCodigo.Focus();
                        }
                    }
                    break;
                }
            }
        }
        private void GrabarPresupuesto()
        {
            SqlTransaction Transaccion;
            SqlConnection  con = new SqlConnection(cConexion.GetConexion());

            con.Open();
            Transaccion = con.BeginTransaction();
            DateTime  Fecha = Convert.ToDateTime(txtFecha.Text);
            Int32?    CodVendedor = null;
            string    Nombre = "", Apellido = "";
            string    NroDocumento = "", Telefono = "";
            string    Direccion = "";
            Int32?    CodCiudad = null;
            cVendedor vendedor  = new cVendedor();

            Nombre       = txtNombre.Text;
            Apellido     = txtApellido.Text;
            Telefono     = txtTelefono.Text;
            NroDocumento = txtNroDocumento.Text;
            Direccion    = txtDireccion.Text;
            string Ciudad = "", Provincia = "";
            string DomicilioCompleto = "";

            if (cmbCiudad.SelectedIndex > 0)
            {
                CodCiudad = Convert.ToInt32(cmbCiudad.SelectedValue);
                Ciudad    = cmbCiudad.Text;
            }
            if (cmbProvincia.SelectedIndex > 0)
            {
                Provincia = cmbProvincia.Text;
            }

            if (Direccion != "")
            {
                DomicilioCompleto = Direccion;
            }
            if (Ciudad != "")
            {
                DomicilioCompleto = DomicilioCompleto + " " + Ciudad;
            }
            if (Provincia != "")
            {
                DomicilioCompleto = DomicilioCompleto + " " + Provincia;
            }

            Int32    CodPresupuesto = 0;
            Int32    CodJoya        = 0;
            Double   Precio         = 0;
            Int32    Cantidad       = 0;
            DateTime?FechaRendicion = null;
            Double   SubTotal       = 0;
            Double   Total          = 0;

            if (txtTotal.Text != "")
            {
                Total = Convert.ToDouble(txtTotal.Text);
            }
            if (txtFechaRendicion.Text != "  /  /")
            {
                FechaRendicion = Convert.ToDateTime(txtFechaRendicion.Text);
            }
            // string Col = "CodArticulo;Nombre;Precio;Cantidad;Subtotal";
            int          Orden = 1;
            cPresupuesto pre   = new cPresupuesto();

            try
            {
                if (txtCodVendedor.Text == "")
                {
                    CodVendedor = (Int32)vendedor.InsertarVendedorTran(con, Transaccion, Apellido, Nombre, Telefono, NroDocumento, Direccion, CodCiudad, DomicilioCompleto);
                }
                else
                {
                    CodVendedor = Convert.ToInt32(txtCodVendedor.Text);
                    vendedor.ActualizarVendedor(con, Transaccion, Convert.ToInt32(CodVendedor), Apellido, Nombre, Telefono, NroDocumento, Direccion, CodCiudad, DomicilioCompleto);
                }


                CodPresupuesto = pre.InsertarPresupuesto(con, Transaccion, Total,
                                                         Fecha
                                                         , CodVendedor, FechaRendicion);

                Principal.CodigoSenia = CodPresupuesto.ToString();
                string NroPresupuesto = GetNroPresupueto(CodPresupuesto.ToString());
                pre.ActualizarNroPresupuesto(con, Transaccion, CodPresupuesto, NroPresupuesto);
                for (int i = 0; i < tbDetalle.Rows.Count; i++)
                {
                    CodJoya  = Convert.ToInt32(tbDetalle.Rows[i]["CodJoya"].ToString());
                    Precio   = Convert.ToDouble(tbDetalle.Rows[i]["Precio"].ToString());
                    Cantidad = Convert.ToInt32(tbDetalle.Rows[i]["Cantidad"].ToString());
                    SubTotal = Convert.ToDouble(tbDetalle.Rows[i]["SubTotal"].ToString());
                    pre.InsertarDetalle(con, Transaccion, CodPresupuesto, Cantidad, Precio, CodJoya, SubTotal, Orden);
                    Orden++;
                }
                Transaccion.Commit();
                con.Close();
                Mensaje("Datos grabados correctamente");
                Principal.CodigoPrincipalAbm = CodPresupuesto.ToString();
                FrmVerReportePresupuesto frm = new FrmVerReportePresupuesto();
                frm.Show();
                Limpiar();
                // FrmReporte frm = new SistemaFact.FrmReporte();
                // frm.Show();
                // this.GetJugadorxCodigoTableAdapter.Fill(this.DataSet1.GetJugadorxCodigo, Codigo);
            }
            catch (Exception exa)
            {
                MessageBox.Show(exa.Message.ToString());
                Transaccion.Rollback();
                con.Close();
                Mensaje("Hubo un error en el proceso de grabacion");
                Mensaje(exa.Message);
            }
        }