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(); } } } }
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(); } } } }
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(); }
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(); }
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(); } } }
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(); } }
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; } }