Ejemplo n.º 1
0
        private void ExpensePage_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'testDataSet1.ExpenseCategory' table. You can move, or remove it, as needed.
            this.expenseCategoryTableAdapter1.Fill(this.testDataSet1.ExpenseCategory);
            if (ExpenseDetails.ExpenseId != 0)
            {
                using (MoneyPred db = new MoneyPred())
                {
                    var expenseDetails = from expense in db.Expenses
                                         where expense.ExpensseId == ExpenseDetails.ExpenseId && expense.IsActive == 1
                                         select expense;

                    foreach (var item in expenseDetails)
                    {
                        this.txtEAmount.Text              = item.Amount.ToString();
                        this.txtEAmount.Text              = item.Amount.ToString();
                        this.txtEDescription.Text         = item.Description.ToString();
                        this.txtEPayerName.Text           = item.PayerName.ToString();
                        this.dtpEDate.Text                = item.Date.ToString();
                        this.dtpESpecDate.Text            = item.SpecDate.ToString();
                        this.cmdExpCategory.SelectedIndex = cmdExpCategory.Items.IndexOf(item.CategoryId);
                        this.rbEEnd.Checked               = item.IsEndMonth == 1 ? true : false;
                        this.rbESpecific.Checked          = item.IsSpecDate == 1 ? true : false;
                        this.rbIEBegining.Checked         = item.IsBeginingMonth == 1 ? true : false;
                        this.chkEReurEvent.Checked        = item.IsRecurringEvent == 1 ? true : false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void IncomePage_Load(object sender, EventArgs e)
        {
            if (ExpenseDetails.IncomeId != 0)
            {
                using (MoneyPred db = new MoneyPred())
                {
                    var incomeDetails = from income in db.Incomes
                                        where income.IncomeId == ExpenseDetails.IncomeId && income.ISActive == 1
                                        select income;

                    foreach (var item in incomeDetails)
                    {
                        this.txtAmount.Text           = item.Amount.ToString();
                        this.txtDescription.Text      = item.Description.ToString();
                        this.txtPayerName.Text        = item.PayerName.ToString();
                        this.dtpDate.Text             = item.Date.ToString();
                        this.dtpSpecDate.Text         = item.SpecDate.ToString();
                        this.rbIncomeEnd.Checked      = item.IsEndMonth == 1 ? true : false;
                        this.rbIncomeSpecific.Checked = item.IsSpecDate == 1 ? true : false;
                        this.rbIncomeBegining.Checked = item.IsBeginingMonth == 1 ? true : false;
                        this.chkReurEvent.Checked     = item.IsRecurringIncome == 1 ? true : false;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void btnESave_Click(object sender, EventArgs e)
 {
     using (MoneyPred db = new MoneyPred())
     {
         Expense expense = new Expense
         {
             Description      = txtEDescription.Text.ToString(),
             PayerName        = txtEPayerName.Text.ToString(),
             Amount           = Convert.ToDecimal(txtEAmount.Text),
             Date             = DateTime.Parse(dtpEDate.Text),
             IsRecurringEvent = Convert.ToByte(chkEReurEvent.Checked),
             IsActive         = 1,
             IsEndMonth       = Convert.ToByte(rbEEnd.Checked),
             IsBeginingMonth  = Convert.ToByte(rbIEBegining.Checked),
             IsSpecDate       = Convert.ToByte(rbESpecific.Checked),
             SpecDate         = DateTime.Parse(dtpESpecDate.Text),
             UserID           = UserDetails.UserId,
             CategoryId       = Convert.ToInt16(cmdExpCategory.SelectedValue)
         };
         db.Expenses.Add(expense);
         db.SaveChanges();
         if (AppoinmentDetails.AppoinmentId != 0)
         {
             var expenseId = from exp in db.Expenses
                             select exp;
             var result = db.Appoinments.SingleOrDefault(b => b.AppoinmentId == AppoinmentDetails.AppoinmentId);
             if (result != null)
             {
                 result.ExpenseId = Convert.ToInt32(expenseId.First());
                 db.SaveChanges();
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     using (MoneyPred db = new MoneyPred())
     {
         Income income = new Income
         {
             Description       = txtDescription.Text.ToString(),
             PayerName         = txtPayerName.Text.ToString(),
             Amount            = Convert.ToDecimal(txtAmount.Text),
             Date              = DateTime.Parse(dtpDate.Text),
             IsRecurringIncome = Convert.ToByte(chkReurEvent.Checked),
             ISActive          = 1,
             IsEndMonth        = Convert.ToByte(rbIncomeEnd.Checked),
             IsBeginingMonth   = Convert.ToByte(rbIncomeBegining.Checked),
             IsSpecDate        = Convert.ToByte(rbIncomeSpecific.Checked),
             SpecDate          = DateTime.Parse(dtpSpecDate.Text),
             UserID            = UserDetails.UserId
         };
         db.Incomes.Add(income);
         db.SaveChanges();
         if (AppoinmentDetails.AppoinmentId != 0)
         {
             var incomeId = from inc in db.Incomes
                            select inc;
             var result = db.Appoinments.SingleOrDefault(b => b.AppoinmentId == AppoinmentDetails.AppoinmentId);
             if (result != null)
             {
                 result.IncomeId = Convert.ToInt32(incomeId.First());
                 db.SaveChanges();
             }
         }
     }
 }
Ejemplo n.º 5
0
        private void FinancePredicPage_Load(object sender, EventArgs e)
        {
            DateTime now       = DateTime.Now;
            var      startDate = new DateTime(now.Year, now.Month, 1);

            using (MoneyPred db = new MoneyPred())
            {
                var allIncomes = from income in db.Incomes
                                 where income.Date <DateTime.Now &&
                                                    income.Date> startDate
                                 select income.Amount;

                var totalIncome = allIncomes.Sum();

                txtIncome.Text = totalIncome.ToString();

                var allExpense = from expense in db.Expenses
                                 where expense.Date <DateTime.Now &&
                                                     expense.Date> startDate
                                 select expense.Amount;

                var totalExpense = allExpense.Sum();

                txtExpense.Text = totalExpense.ToString();
            }
        }
Ejemplo n.º 6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtUserName.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                MessageBox.Show("Please Enter user Details to Sign in or Sign Up!");
                return;
            }
            using (MoneyPred db = new MoneyPred())
            {
                var user = from users in db.Users
                           where (users.UserName == txtUserName.Text && users.Password == txtPassword.Text)
                           select users.UserID;
                UserDetails.UserId = user.FirstOrDefault();
                if (UserDetails.UserId == 0)
                {
                    MessageBox.Show("Invalid User Name or Password");
                    txtPassword.Clear();
                    txtUserName.Clear();
                    return;
                }
                db.SaveChanges();
            }
            this.Hide();
            var homePage = new HomePage();

            homePage.Activate();
            homePage.ShowDialog();
        }
Ejemplo n.º 7
0
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFname.Text) || string.IsNullOrWhiteSpace(txtLname.Text) || string.IsNullOrWhiteSpace(txtUserName.Text) ||
                string.IsNullOrWhiteSpace(txtProf.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                MessageBox.Show("Please Enter Values to all the fields!");
                return;
            }
            using (MoneyPred db = new MoneyPred())
            {
                User user = new User
                {
                    FirstName  = txtFname.Text.ToString(),
                    LastName   = txtLname.Text.ToString(),
                    EMail      = txtEmail.Text.ToString(),
                    Proffesion = txtProf.Text.ToString(),
                    UserName   = txtUserName.Text.ToString(),
                    Password   = txtPassword.Text.ToString(),
                    isActive   = 1,
                };
                db.Users.Add(user);
                db.SaveChanges();
            }
            this.Hide();
            var loginPage = new Login();

            loginPage.Activate();
            loginPage.ShowDialog();
        }
Ejemplo n.º 8
0
        private void HomePage_Load(object sender, EventArgs e)
        {
            using (MoneyPred db = new MoneyPred())
            {
                var result = (from expense in db.Expenses
                              join category in db.ExpenseCategories
                              on expense.CategoryId equals category.CategoryId
                              where expense.IsActive == 1
                              select new
                {
                    Amount = expense.Amount,
                    CategoryName = category.CategoryName
                }).ToList();

                var a = result.GroupBy(o => o.CategoryName)
                        .Select(g => new { CategoryName = g.Key, total = g.Sum(i => i.Amount) }).ToList();
                double[] total        = new double[a.Count];
                string[] categoryName = new string[a.Count];

                for (int i = 0; i < a.Count; i++)
                {
                    total[i]        = Convert.ToDouble(a[i].total);
                    categoryName[i] = a[i].CategoryName;
                }

                pieChart.Series = new PieSeries(
                    total,
                    categoryName,
                    categoryName)
                {
                    Title = "Expenses For Categories"
                };
                pieChart.Dock  = DockStyle.Fill;
                pieChart.Title = "Expenses For Categories";

                pieChart.AllowZoom   = true;
                pieChart.AllowRotate = true;

                pieChart.ShowLegend     = false;
                pieChart.ShowDataLabels = LabelKinds.OuterLabel;

                pieChart.Theme                         = new Theme();
                pieChart.Theme.SeriesFills             = GetPieFills();
                pieChart.Theme.UniformSeriesStroke     = new MindFusion.Drawing.SolidBrush(Color.FromArgb(240, 240, 240));
                pieChart.Theme.SeriesStrokeThicknesses = new List <List <double> >()
                {
                    new List <double>()
                    {
                        15
                    }
                };
                pieChart.Theme.HighlightStroke          = new MindFusion.Drawing.SolidBrush(Color.White);
                pieChart.Theme.HighlightStrokeThickness = 10;
                pieChart.Theme.DataLabelsFontSize       = 14;
            }
        }
Ejemplo n.º 9
0
 private void btnEDelete_Click(object sender, EventArgs e)
 {
     using (MoneyPred db = new MoneyPred())
     {
         var result = db.Expenses.SingleOrDefault(b => b.ExpensseId == ExpenseDetails.ExpenseId);
         if (result != null)
         {
             result.IsActive = 0;
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 10
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     using (MoneyPred db = new MoneyPred())
     {
         ExpenseCategory category = new ExpenseCategory
         {
             CategoryName  = txtCatName.Text.ToString(),
             CategoryOwner = txtCatOwner.Text.ToString(),
             CategoryType  = txtCatType.Text.ToString(),
             Icon          = txtCatIcon.Text.ToString(),
         };
         db.ExpenseCategories.Add(category);
         db.SaveChanges();
     }
 }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(dtpFromDate.Text) || string.IsNullOrEmpty(dtpToDate.Text))
            {
                MessageBox.Show("You must select Date range!");
                return;
            }
            else if (chkExpense.Checked)
            {
                using (MoneyPred db = new MoneyPred())
                {
                    var expenseDetails = from expenses in db.Expenses
                                         where dtpFromDate.Value <expenses.Date &&
                                                                  dtpToDate.Value> expenses.Date
                                         select new
                    { Description = expenses.Description, Amount = expenses.Amount, Date = expenses.Date, Id = expenses.ExpensseId };

                    expenseDataGrid.DataSource = expenseDetails.ToList();
                }
                expenseDataGrid.Visible = true;
                lblExpGrid.Visible      = true;
            }
            else if (chkIncome.Checked)
            {
                using (MoneyPred db = new MoneyPred())
                {
                    var incomeDetails = from incomes in db.Incomes
                                        where dtpFromDate.Value <incomes.Date &&
                                                                 dtpToDate.Value> incomes.Date
                                        select new
                    { Description = incomes.Description, Amount = incomes.Amount, Date = incomes.Date, Id = incomes.IncomeId };

                    incomeDataGrid.DataSource = incomeDetails.ToList();
                }
                incomeDataGrid.Visible = true;
                lblIncGrid.Visible     = true;
            }
        }
Ejemplo n.º 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (MoneyPred db = new MoneyPred())
            {
                Appoinment appoinmentDetails = new Appoinment
                {
                    InviteeName = txtInviteeName.Text.ToString(),
                    Location    = txtLocation.Text.ToString(),
                    Purpose     = txtPurpose.Text.ToString()
                };

                db.Appoinments.Add(appoinmentDetails);
                db.SaveChanges();

                var appoinmentId = from appoinment in db.Appoinments
                                   select appoinment.AppoinmentId;

                AppoinmentDetails.AppoinmentId = Convert.ToInt32(appoinmentId.First());

                btnExpense.Visible = true;
                btnIncome.Visible  = true;
            }
        }