Пример #1
0
        public static List <Detfactura> getDetsfacturaByIdPersona(Int64 pIdPersona)
        {
            List <Detfactura> lista = new List <Detfactura>();

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand comando = new MySqlCommand("select df.* from detfactura as df inner join factura as f " +
                                                            "on f.Id=df.IdFactura inner join Producto as p on p.Id = df.IdProducto where f.IdPersona = @pIdPersona " +
                                                            " and df.Tipo = 'R' and (SELECT sum(dfs.Total) from detfactura as dfs inner join factura fs on fs.Id=dfs.IdFactura where dfs.RefNFactura=df.RefNFactura and fs.Estado='C')" +
                                                            " < p.Precio and f.Estado='C' order by Id desc", _con);
                    comando.Parameters.AddWithValue("@pIdPersona", pIdPersona);

                    MySqlDataReader _reader = comando.ExecuteReader();
                    while (_reader.Read())
                    {
                        Detfactura item = new Detfactura(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetDecimal(2),
                            _reader.GetDecimal(3),
                            _reader.GetString(4),
                            _reader.IsDBNull(5) ? null : _reader.GetString(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            ProductoDAL.getProductoById(_reader.GetInt64(7)),
                            MatricdetfacDAL.getMatricdetfacByIdDetFactura(_reader.GetInt64(0))
                            );

                        lista.Add(item);
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(lista);
        }
Пример #2
0
        public static List <Detfactura> getDetsfacturaByIdFactura(Int64 pIdFactura)
        {
            List <Detfactura> lista = new List <Detfactura>();

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand comando = new MySqlCommand("select * from detfactura where IdFactura=@pIdFactura order by Id asc", _con);
                    comando.Parameters.AddWithValue("@pIdFactura", pIdFactura);

                    MySqlDataReader _reader = comando.ExecuteReader();
                    while (_reader.Read())
                    {
                        Detfactura item = new Detfactura(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetDecimal(2),
                            _reader.GetDecimal(3),
                            _reader.GetString(4),
                            _reader.IsDBNull(5) ? null : _reader.GetString(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            ProductoDAL.getProductoById(_reader.GetInt64(7)),
                            MatricdetfacDAL.getMatricdetfacByIdDetFactura(_reader.GetInt64(0))
                            );

                        lista.Add(item);
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(lista);
        }
Пример #3
0
        public static Detfactura getDetfacturaById(Int64 pId)
        {
            Detfactura item = null;

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand cmdGetItemById = new MySqlCommand("select * from detfactura where Id=@pId", _con);
                    cmdGetItemById.Parameters.AddWithValue("@pId", pId);
                    MySqlDataReader _reader = cmdGetItemById.ExecuteReader();
                    while (_reader.Read())
                    {
                        item = new Detfactura(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetDecimal(2),
                            _reader.GetDecimal(3),
                            _reader.GetString(4),
                            _reader.IsDBNull(5)?null:_reader.GetString(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            ProductoDAL.getProductoById(_reader.GetInt64(7)),
                            MatricdetfacDAL.getMatricdetfacByIdDetFactura(_reader.GetInt64(0))
                            );
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(item);
        }
Пример #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvProductos.CurrentRow != null && Val_NewObject())
                {
                    switch (opc)
                    {
                    case "Mensualidad":
                        if (dgvProductos.CurrentRow != null)
                        {
                            currentDetFactura = new Detfactura(
                                0,
                                "Mensualidad",
                                Convert.ToDecimal(txtAporte.Text),
                                Convert.ToDecimal(txtDescuento.Text),
                                "M",
                                null,
                                0,
                                ProductoDAL.getProductoMensualidad().Id,
                                ProductoDAL.getProductoMensualidad(),
                                new Matricdetfac(
                                    0,
                                    0,
                                    (Int64)dgvProductos.CurrentRow.Cells[0].Value)
                                );
                            this.Close();
                        }
                        break;

                    case "Cancelacion":
                        if (dgvProductos.CurrentRow != null)
                        {
                            currentDetFactura = new Detfactura(
                                (Int64)dgvProductos.CurrentRow.Cells[0].Value,
                                ProductoDAL.getProductoById(DetFacturaDAL.getDetfacturaById((Int64)dgvProductos.CurrentRow.Cells[0].Value).IdProducto).Nombre,
                                Convert.ToDecimal(txtAporte.Text),
                                Convert.ToDecimal(txtDescuento.Text),
                                "C",
                                DetFacturaDAL.getDetfacturaById((Int64)dgvProductos.CurrentRow.Cells[0].Value).RefNFactura,
                                0,
                                ProductoDAL.getProductoById(DetFacturaDAL.getDetfacturaById((Int64)dgvProductos.CurrentRow.Cells[0].Value).IdProducto).Id,
                                ProductoDAL.getProductoById(DetFacturaDAL.getDetfacturaById((Int64)dgvProductos.CurrentRow.Cells[0].Value).IdProducto),
                                null
                                );
                            this.Close();
                        }
                        break;

                    case "Contado":
                        if (dgvProductos.CurrentRow != null)
                        {
                            currentDetFactura = new Detfactura(
                                0,
                                "Al contado",
                                Convert.ToDecimal(txtAporte.Text),
                                Convert.ToDecimal(txtDescuento.Text),
                                Convert.ToDecimal(txtAporte.Text) < ProductoDAL.getProductoById((Int64)dgvProductos.CurrentRow.Cells[0].Value).Precio ? "R" : "F",
                                null,
                                0,
                                ProductoDAL.getProductoById((Int64)dgvProductos.CurrentRow.Cells[0].Value).Id,
                                ProductoDAL.getProductoById((Int64)dgvProductos.CurrentRow.Cells[0].Value),
                                null
                                );
                            this.Close();
                        }
                        break;

                    default: break;
                    }
                }
            }
            catch (Exception ex)
            {
                string folderName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Errores_" + Assembly.GetExecutingAssembly().GetName().Name + "_V_" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
                string fileName   = "Exeptions_" + Name + ".txt";

                Validation.FormManager frmManager = new Validation.FormManager();
                frmManager.writeException(folderName, fileName, ex, "Ha ocurrido un error al intentar seleccionar la información de este control");
                MessageBox.Show("Ha ocurrido un error al intentar seleccionar la información de este control, por favor comuniquese con el desarrollador al correo " + Properties.Settings.Default.developerEmail, "Error fatal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }