示例#1
0
        public bool Agregar(Facturacion_Venta Nuevo, string entregado, int idpedido)
        {
            bool Agre = false;

            try
            {
                Agre = R_Factura.Agregar(Nuevo, entregado, idpedido);
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(Agre);
        }
示例#2
0
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                if (!_isRefresh)
                {
                    AuxPedido = (Pedido)Session["PedidoSession"];
                    Facturacion_Venta Nuevo = new Facturacion_Venta()
                    {
                        Cod_factura   = Convert.ToInt32(TxtnroFactura.Text),
                        Fecha         = Convert.ToDateTime(txtfechamostrar.Text),
                        Importetotal  = Convert.ToDouble(Session["ImporteTotal"]),
                        Clienteid     = AuxPedido.Clienteid,
                        Empleadoid    = Convert.ToInt32(ddlEmpleado.SelectedValue),
                        Metododepago  = DdlMetododePago.SelectedValue,
                        Pedidoid      = Convert.ToInt32(txtnropedidomostrar.Text),
                        Tipodefactura = Convert.ToChar(TxtTipoFactura.Text)
                    };
                    Pedido AuxiP = ControlPedido.BuscarNro(Convert.ToInt32(txtnropedidomostrar.Text));
                    if (ControlFacturacion.Agregar(Nuevo, "entregado", AuxiP.Pedidoid))
                    {
                        if (Convert.ToChar(TxtTipoFactura.Text) == 'A')
                        {
                            ControlConfig.ProximoFacturaA(NroFacturaA);
                        }
                        else
                        {
                            ControlConfig.ProximaFacturaB(NroFacturaB);
                        }
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "AgregarFactura();", true);

                        Response.AddHeader("REFRESH", "2;URL=AgregarFactura.aspx");
                        Session["ImporteTotal"] = null;
                    }
                }
                else
                {
                    Response.Redirect("AgregarFactura.aspx");
                }
            }
        }
示例#3
0
        public List <Facturacion_Venta> RangoTotal(DateTime Desde, DateTime Hasta)
        {
            List <Facturacion_Venta> Lista = new List <Facturacion_Venta>();
            Facturacion_Venta        Fact  = null;

            try
            {
                conex.AbrirConexion();
                MySqlCommand Comando = conex.CrearComando();
                Comando.CommandText = "SELECT * FROM facturaciones WHERE (fecha BETWEEN CAST(@Desde AS DATE) AND CAST(@Hasta AS DATE))";
                Comando.Parameters.Add("@Desde", MySqlDbType.Date);
                Comando.Parameters["@Desde"].Value = Desde;
                Comando.Parameters.Add("@Hasta", MySqlDbType.Date);
                Comando.Parameters["@Hasta"].Value = Hasta;
                Comando.Prepare();
                MySqlDataReader Dr = Comando.ExecuteReader();
                while (Dr.Read())
                {
                    Fact = new Facturacion_Venta()
                    {
                        Cod_factura   = Dr.GetInt32(0),
                        Fecha         = Dr.GetDateTime(1),
                        Importetotal  = Dr.GetDouble(2),
                        Clienteid     = Dr.GetInt32(3),
                        Empleadoid    = Dr.GetInt32(4),
                        Metododepago  = Dr.GetString(5),
                        Pedidoid      = Dr.GetInt32(6),
                        Tipodefactura = Dr.GetChar(7)
                    }; Lista.Add(Fact);
                }
                Dr.Close();
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            finally { conex.CerrarConexion(); }
            return(Lista);
        }
示例#4
0
        public Facturacion_Venta Buscar(int cod, char tipofactura)
        {
            Facturacion_Venta Fac = null;

            try
            {
                conex.AbrirConexion();
                MySqlCommand Comando = conex.CrearComando();
                Comando.CommandText = "SELECT * FROM facturaciones WHERE cod_factura = @cod_factura AND tipofactura = @tipofactura";
                Comando.Parameters.Add("@cod_factura", MySqlDbType.Int32);
                Comando.Parameters["@cod_factura"].Value = cod;
                Comando.Parameters.Add("@tipofactura", MySqlDbType.VarChar);
                Comando.Parameters["@tipofactura"].Value = tipofactura;
                Comando.Prepare();
                MySqlDataReader Dr = Comando.ExecuteReader();
                if (Dr.Read())
                {
                    Fac = new Facturacion_Venta()
                    {
                        Cod_factura   = Dr.GetInt32(0),
                        Fecha         = Dr.GetDateTime(1),
                        Importetotal  = Dr.GetDouble(2),
                        Clienteid     = Dr.GetInt32(3),
                        Empleadoid    = Dr.GetInt32(4),
                        Metododepago  = Dr.GetString(5),
                        Pedidoid      = Dr.GetInt32(6),
                        Tipodefactura = Dr.GetChar(7)
                    };
                }
                Dr.Close();
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            finally { conex.CerrarConexion(); }
            return(Fac);
        }
示例#5
0
        public Facturacion_VentaDTO Buscar(int cod, char tipofactura)
        {
            Facturacion_Venta    Fact    = null;
            Facturacion_VentaDTO FactDTO = null;

            try
            {
                Fact = R_Factura.Buscar(cod, tipofactura);
                if (Fact != null)
                {
                    Cliente  AuxCli = R_Cli.BuscarID(Fact.Clienteid);
                    Empleado AuxEmp = R_Emp.BuscarID(Fact.Empleadoid);
                    Pedido   AuxP   = R_Ped.BuscarIDTotal(Fact.Pedidoid);

                    FactDTO = new Facturacion_VentaDTO(Fact.Cod_factura, Fact.Fecha, Fact.Importetotal, AuxCli, AuxEmp, Fact.Metododepago, AuxP, Fact.Tipodefactura);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(FactDTO);
        }
示例#6
0
        public List <Facturacion_Venta> ListarFacturaFiltroCliente(string TxtFiltro)
        {
            List <Facturacion_Venta> Lista = new List <Facturacion_Venta>();
            Facturacion_Venta        Fact  = null;

            try
            {
                conex.AbrirConexion();
                MySqlCommand Comando = conex.CrearComando();
                Comando.CommandText = "SELECT fac.* FROM facturaciones AS fac INNER JOIN clientes AS cli ON(fac.clienteid = cli.clienteid) WHERE(cli.apellido LIKE @SearchText or cli.nombre LIKE @SearchText) ";
                Comando.Prepare();
                Comando.Parameters.AddWithValue("@SearchText", "%" + TxtFiltro + "%");

                MySqlDataReader Dr = Comando.ExecuteReader();
                while (Dr.Read())
                {
                    Fact = new Facturacion_Venta()
                    {
                        Cod_factura   = Dr.GetInt32(0),
                        Fecha         = Dr.GetDateTime(1),
                        Importetotal  = Dr.GetDouble(2),
                        Clienteid     = Dr.GetInt32(3),
                        Empleadoid    = Dr.GetInt32(4),
                        Metododepago  = Dr.GetString(5),
                        Pedidoid      = Dr.GetInt32(6),
                        Tipodefactura = Dr.GetChar(7)
                    }; Lista.Add(Fact);
                }
                Dr.Close();
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            finally { conex.CerrarConexion(); }
            return(Lista);
        }
示例#7
0
        public List <Facturacion_Venta> DevolverTodo()
        {
            List <Facturacion_Venta> Lista = new List <Facturacion_Venta>();
            Facturacion_Venta        Fac   = null;

            try
            {
                conex.AbrirConexion();
                MySqlCommand Comando = conex.CrearComando();
                Comando.CommandText = "SELECT * FROM facturaciones";
                Comando.Prepare();
                MySqlDataReader Dr = Comando.ExecuteReader();
                while (Dr.Read())
                {
                    Fac = new Facturacion_Venta()
                    {
                        Cod_factura   = Dr.GetInt32(0),
                        Fecha         = Dr.GetDateTime(1),
                        Importetotal  = Dr.GetDouble(2),
                        Clienteid     = Dr.GetInt32(3),
                        Empleadoid    = Dr.GetInt32(4),
                        Metododepago  = Dr.GetString(5),
                        Pedidoid      = Dr.GetInt32(6),
                        Tipodefactura = Dr.GetChar(7)
                    };
                    Lista.Add(Fac);
                }
                Dr.Close();
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            finally { conex.CerrarConexion(); }
            return(Lista);
        }
示例#8
0
        public bool Agregar(Facturacion_Venta Nuevo, string entregado, int idpedido)
        {
            bool Agre     = false;
            bool commited = false;

            try
            {
                conex.AbrirConexion();
                MySqlCommand Comando = conex.CrearComando();
                Transaccion = conex.conexion.BeginTransaction(IsolationLevel.Serializable);
                MySqlCommand SelectComand = conex.CrearComando();
                SelectComand.Connection  = conex.conexion;
                SelectComand.CommandText = "INSERT INTO facturaciones(cod_factura, fecha, importetotal, clienteid, empleadoid, metodopago, pedidoid,tipofactura) VALUES (@cod_factura,@fecha,@importetotal,@clienteid,@empleadoid,@metodopago,@pedidoid,@tipofactura)";
                SelectComand.Parameters.Add("@cod_factura", MySqlDbType.Int32);
                SelectComand.Parameters["@cod_factura"].Value = Nuevo.Cod_factura;
                SelectComand.Parameters.Add("@fecha", MySqlDbType.Date);
                SelectComand.Parameters["@fecha"].Value = Nuevo.Fecha;
                SelectComand.Parameters.Add("@importetotal", MySqlDbType.Double);
                SelectComand.Parameters["@importetotal"].Value = Nuevo.Importetotal;
                SelectComand.Parameters.Add("@clienteid", MySqlDbType.Int32);
                SelectComand.Parameters["@clienteid"].Value = Nuevo.Clienteid;
                SelectComand.Parameters.Add("@empleadoid", MySqlDbType.Int32);
                SelectComand.Parameters["@empleadoid"].Value = Nuevo.Empleadoid;
                SelectComand.Parameters.Add("@pedidoid", MySqlDbType.Int32);
                SelectComand.Parameters["@pedidoid"].Value = Nuevo.Pedidoid;
                SelectComand.Parameters.Add("@metodopago", MySqlDbType.String);
                SelectComand.Parameters["@metodopago"].Value = Nuevo.Metododepago;
                SelectComand.Parameters.Add("@tipofactura", MySqlDbType.VarChar);
                SelectComand.Parameters["@tipofactura"].Value = Nuevo.Tipodefactura;
                SelectComand.Prepare();
                SelectComand.Transaction = Transaccion;
                SelectComand.ExecuteNonQuery();


                Comando.Parameters.Clear();
                Comando.CommandText = "UPDATE pedidos SET entregado=@entregado WHERE pedidoid = @idp";
                Comando.Parameters.Add("@idp", MySqlDbType.Int32);
                Comando.Parameters["@idp"].Value = idpedido;
                Comando.Parameters.Add("@entregado", MySqlDbType.VarChar);
                Comando.Parameters["@entregado"].Value = entregado;
                Comando.Prepare();
                Comando.ExecuteNonQuery();

                Transaccion.Commit();

                commited = true;
                Agre     = true;
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            finally
            {
                if (!commited)
                {
                    if (Transaccion != null)
                    {
                        Transaccion.Rollback();
                    }
                }

                if (conex.conexion.State.Equals(ConnectionState.Open))
                {
                    conex.CerrarConexion();
                }
            }
            return(Agre);
        }