Exemplo n.º 1
0
        //Menu inicial

        private void btnHome_Click(object sender, EventArgs e)
        {
            ctrlHome frm = new ctrlHome();

            pnPage.Controls.Clear();
            pnPage.Controls.Add(frm);
            frm.Show();
            frm.Dock                = DockStyle.Fill;
            frm.AutoSize            = true;
            btnClients.ForeColor    = Color.Black;
            btnBeneficios.ForeColor = Color.Black;
            btnHome.ForeColor       = Color.White;
            btnPartners.ForeColor   = Color.Black;
            btnPlans.ForeColor      = Color.Black;
            btnDashboard.ForeColor  = Color.Black;
            btnFaturas.ForeColor    = Color.Black;
            btnPagamentos.ForeColor = Color.Black;
            btnRelatorios.ForeColor = Color.Black;
        }
Exemplo n.º 2
0
        private async void FrmGeral_Load(object sender, EventArgs e)
        {
            monthNow = DateTime.Now.Month.ToString() + '-' + DateTime.Now.Year.ToString();
            if (DateTime.Now.Month < 10)
            {
                monthNow = "0" + monthNow;
            }
            string path = AppDomain.CurrentDomain.BaseDirectory + @"pro-vantagens-firebase-adminsdk-5cf5q-82ec44750b.json";

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path);
            FirestoreDb db = FirestoreDb.Create("pro-vantagens");

            lbUserName.Text = User.Name;

            Query         Query     = db.Collection("users");
            QuerySnapshot snapshots = await Query.GetSnapshotAsync();

            foreach (DocumentSnapshot documentSnapshot in snapshots)
            {
                Clients users = documentSnapshot.ConvertTo <Clients>();

                if (users.plan != "")
                {
                    if (users.plan != null)
                    {
                        DocumentReference invoiceReference = db.Collection("users").Document(documentSnapshot.Id).Collection("invoices").Document(monthNow);
                        DocumentSnapshot  invoiceSnap      = await invoiceReference.GetSnapshotAsync();

                        if (invoiceSnap.Exists)
                        {
                        }
                        else
                        {
                            int dependents = 0;
                            for (int i = 0; i < users.dependents.Count; i++)
                            {
                                if (users.dependents[i].aditional == true)
                                {
                                    dependents = dependents + 1;
                                }
                            }

                            double dpvalue    = dependents * 9.90;
                            double totalValue = (double.Parse(users.planvalue.Replace("R$ ", "")) + dpvalue);

                            Dictionary <string, object> invoiceData = new Dictionary <string, object>()
                            {
                                { "aditional", dpvalue },
                                { "dueDate", users.dueDate },
                                { "holder", users.name },
                                { "month", DateTime.Now.Month.ToString() },
                                { "paymentMethod", users.paymentMethod },
                                { "planName", users.plan },
                                { "status", "Pendente" },
                                { "totalValue", totalValue },
                                { "value", users.planvalue },
                            };
                            await invoiceReference.SetAsync(invoiceData);
                        }
                    }
                }
            }
            if (User.AccessLevel > 1)
            {
                gbFinances.Visible = true;
            }

            ctrlHome frm = new ctrlHome();

            pnPage.Controls.Clear();
            pnPage.Controls.Add(frm);
            frm.Show();
            frm.Dock                = DockStyle.Fill;
            frm.AutoSize            = true;
            btnClients.ForeColor    = Color.Black;
            btnBeneficios.ForeColor = Color.Black;
            btnHome.ForeColor       = Color.White;
            btnPartners.ForeColor   = Color.Black;
            btnPlans.ForeColor      = Color.Black;
            btnDashboard.ForeColor  = Color.Black;
            btnFaturas.ForeColor    = Color.Black;
            btnPagamentos.ForeColor = Color.Black;
            btnRelatorios.ForeColor = Color.Black;
        }