private void LOadPlans() { using (AxaContext ctx = new AxaContext()) { planBindingSource.DataSource = ctx.Plans.ToList(); } }
private void cb_PlanType_SelectedIndexChanged(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { if (cb_PlanType.SelectedIndex == -1) { } else { try { string tempPlan = cb_PlanType.SelectedItem.ToString(); var category_list = ctx.Plans.Where(x => x.PlanType == tempPlan).ToList(); cb_Category.DataSource = category_list; //cb_Course.Items.Add(cb_Course.DataSource = ctx.Courses.ToString()); cb_Category.DisplayMember = "Category"; cb_Category.ValueMember = "PlanId"; cb_Category.SelectedIndex = -1; cb_Category.SelectionLength = 0; cb_Category.Enabled = true; cb_Description.Enabled = false; } catch (Exception) { } } } }
private void populateClientPlans() { using (AxaContext ctx = new AxaContext()) { var result = from e in ctx.ClientPlans join d in ctx.Plans on e.PlanId equals d.PlanId //into empDept //from ed in empDept.DefaultIfEmpty() where e.ClientId == 1 select new { e.PolicyNo, e.SumInsured, e.ModeOfPayment, e.DueOfPayment, d.PlanType, d.Category, d.Description, }; clientPlanBindingSource.DataSource = ctx.ClientPlans.Where(x => x.ClientId == 1).ToList(); //dataGridView_LoadPlans.Rows.Add("a", "aa", "aa"); //dataGridView_LoadPlans.Rows.Add(result.ToList()); } }
private void tb_PaidClients_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { dataGridView_ClientList.DataSource = ctx.Clients.ToList(); } }
private void tb_DueClients_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { DateTime dt = DateTime.Now; int day = dt.Day; var result = from f in ctx.ClientPlans join d in ctx.Clients on f.ClientId equals d.ClientId into empDept from ed in empDept.DefaultIfEmpty() where f.DueOfPayment <= day select new { ed.CFirstName, ed.CMiddleName, ed.CLastName, ed.CellphoneNo }; dataGridView_ClientList.DataSource = result.ToList(); //dataGridView_ClientList.DataSource = ctx.Clients.Where(x => x.Due) ToList(); } }
private void pictureBox1_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { dataGridView_ListOfEmployee.DataSource = ctx.Employees.ToList(); } }
private void LoadUserList() { using (AxaContext ctx = new AxaContext()) { userBindingSource.DataSource = ctx.Users.ToList(); } dataGridView_User.ClearSelection(); }
//private DataGridViewRow tempIdplan; private void AddEditPlan_Load(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { planBindingSource.DataSource = ctx.Plans.ToList(); } dataGridView_Plan.ClearSelection(); }
private void LoadClientList() { try { using (AxaContext ctx = new AxaContext()) { employeeBindingSource.DataSource = ctx.Users.ToList(); } } catch (Exception) { MessageBox.Show("No Database"); } }
private void button1_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { dataGridView_Client.DataSource = ctx.Clients.Where(x => x.CFirstName.Contains(tb_SearchEmployee.Text)).ToList(); } dataGridView_Client.Visible = true; dataGridView_FinancialAdvisor.Visible = false; bt_FAMonitoring.Enabled = false; bt_FAMonitoring.BackColor = Color.DimGray; button3.BackColor = Color.Firebrick; button3.Enabled = true; }
private void ClienrtsPaymentMonitoring_Load(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { if (dgvrClientPlanMonitoring == null) { } else { int clientId = Int32.Parse(dgvrClientPlanMonitoring.Cells[0].Value.ToString()); clientPlanBindingSource.DataSource = ctx.ClientPlans.Where(x => x.ClientId == clientId).ToList(); } } }
private void cb_Category_SelectedIndexChanged(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { var classfication_List = ctx.Plans.Where(x => x.Category == cb_Category.Text).ToList(); cb_Description.DataSource = classfication_List; //cb_Course.Items.Add(cb_Course.DataSource = ctx.Courses.ToString()); cb_Description.DisplayMember = "Description"; cb_Description.ValueMember = "PlanId"; cb_Description.SelectedIndex = -1; cb_Description.Enabled = true; } }
private void button3_Click(object sender, EventArgs e) { if (dataGridView_ListOfClients.SelectedRows.Count > 0) { using (AddEditClient addEditClient = new AddEditClient()) { addEditClient.action = "Edit"; using (AxaContext ctx = new AxaContext()) { //int client_id = (int)dataGridView_ListOfClients.SelectedRows[0].Cells[0].Value; //addEditClient.selected_client = ctx.Clients.Find(client_id); //addEditClient.ShowDialog(); } } } }
private void button2_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { dataGridView_FinancialAdvisor.DataSource = ctx.Employees.Where(x => x.DesignatedPostion == "Financial advisor").ToList(); } dataGridView_FinancialAdvisor.Visible = true; dataGridView_Client.Visible = false; bt_FAMonitoring.Enabled = true; bt_FAMonitoring.BackColor = Color.Firebrick; button3.BackColor = Color.DimGray; button3.Enabled = false; }
private void bt_SavePlan_Click(object sender, EventArgs e) { using (AxaContext ctx = new AxaContext()) { if (tb_Description.Text == "") { MessageBox.Show("Please filled up all fields"); } else { if (dataGridView_Plan.SelectedRows.Count > 0) { int tempIdplan = Int32.Parse(dataGridView_Plan.SelectedRows[0].Cells[0].Value.ToString()); var planUpdate = new Plan { PlanId = tempIdplan, Description = tb_Description.Text, PlanType = cb_PlanType.SelectedItem.ToString(), Category = cb_PlanCategory.SelectedItem.ToString(), }; ctx.Plans.Attach(planUpdate); ctx.Entry(planUpdate).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); ClearTextField(); AddEditPlan_Load(null, null); MessageBox.Show("Plan Succesfully Updated"); } else { var plan = new Plan { Description = tb_Description.Text, PlanType = cb_PlanType.SelectedItem.ToString(), Category = cb_PlanCategory.SelectedItem.ToString(), }; ctx.Plans.Add(plan); ctx.SaveChanges(); ClearTextField(); AddEditPlan_Load(null, null); MessageBox.Show("Plan SUccesfully Added"); } } } }
private void FinancialAdviserMonitoring_Load(object sender, EventArgs e) { FAName.Text = dgvr.Cells[1].Value.ToString() + " " + dgvr.Cells[2].Value.ToString() + " " + dgvr.Cells[3].Value.ToString(); AddEditClient.tempFinancialAdvisorName = FAName.Text; string imagePath = Application.StartupPath + "\\EmployeePicture\\" + dgvr.Cells[4].Value.ToString(); PopulateClientIDImage(imagePath, 1); // PopulateClientIDImage(dgvr.Cells[4].Value.ToString(), 1); int clientId = Int32.Parse(dgvr.Cells[0].Value.ToString()); using (AxaContext ctx = new AxaContext()) { clientBindingSource.DataSource = ctx.Clients.Where((x => x.EmployeeId == clientId)).ToList(); } }
private void loadEmployeeList() { using (AxaContext ctx = new AxaContext()) { if (tb_SearchEmployee.Text == "") { dataGridView_ListOfEmployee.DataSource = ctx.Employees.ToList(); } else { dataGridView_ListOfEmployee.DataSource = ctx.Employees.Where(x => x.EFirstName == tb_SearchEmployee.Text).ToList(); } //dataGridView_ListOfEmployee.DataSource = ctx.Employees.Where(x => x.EFirstName == tb_SearchEmployee.Text + x.EMiddleName == tb_SearchEmployee.Text) } }
private void ValidateUser() { using (AxaContext ctx = new AxaContext()) { var user = ctx.Users.Where(u => u.UserName.Equals(tb_Username.Text)).FirstOrDefault(); if (user != null) { if (user.Password != tb_Password.Text) { MessageBox.Show("Invalid Password."); } //else if (user.IsActive == false) //{ // MessageBox.Show("Your Account is suspended. Please contact the administraor"); //} else if (user.Role == "Admin") { this.Close(); //this.Dispose(); } else if (user.Role == "Clerk") { LoginAsClerk = true; this.Close(); } else { this.Close(); //this.Dispose(); } } else { MessageBox.Show("No (" + tb_Username.Text + ") user found"); } } }
private void loadListOfClients() { int tempEployeeId = Int32.Parse(dgvrAddEditEmployee.Cells[0].Value.ToString()); using (AxaContext ctx = new AxaContext()) { var result = from ee in ctx.Clients where ee.EmployeeId == tempEployeeId select new { ee.CFirstName, ee.CMiddleName, ee.CLastName, }; dataGrid_ListClients.DataSource = result.ToList(); dataGrid_ListClients.Columns[0].HeaderCell.Value = "First Name"; dataGrid_ListClients.Columns[1].HeaderCell.Value = "Middle Name"; dataGrid_ListClients.Columns[2].HeaderCell.Value = "Last Name"; } }
private void LoadClientBday() { using (AxaContext ctx = new AxaContext()) { DateTime dt = DateTime.Now; var result = from f in ctx.Clients where f.CBirthday.Day == dt.Day && f.CBirthday.Month == dt.Month select new { f.CFirstName, f.CMiddleName, f.CLastName, f.CellphoneNo }; dataGridView_ClientList.DataSource = result.ToList(); //dataGridView_ClientList.DataSource = ctx.Clients.Where(x => x.Due) ToList(); } }
private void SaveEmployee() { if (dgvrAddEditEmployee == null) { try { using (AxaContext ctx = new AxaContext()) { var employee = new Employee { IdPicture = textBox1.Text, ELastName = tb_LastName.Text, EMiddleName = tb_MiddleName.Text, EFirstName = tb_FirstName.Text, BirthDate = dateTimePicker1.Value.Date, Age = tb_Age.Text, EmailAddress = tb_EmailAddress.Text, Gender = cb_Gender.SelectedItem.ToString(), CivilStatus = cb_CivilStatus.Text, CellphoneNo = tb_CellphoneNo.Text, Address = tb_Address.Text, DesignatedPostion = cb_DisignatedPosition.SelectedItem.ToString(), }; ctx.Employees.Add(employee); ctx.SaveChanges(); MessageBox.Show("Save Successful"); this.Close(); this.Dispose(); // Clearfields(); } } catch (System.Exception) { MessageBox.Show("Save unSuccessful"); } } else { try { int tempEployeeId = Int32.Parse(dgvrAddEditEmployee.Cells[0].Value.ToString()); using (AxaContext ctx = new AxaContext()) { var employeeUpdate = new Employee { EmployeeId = tempEployeeId, IdPicture = textBox1.Text, ELastName = tb_LastName.Text, EMiddleName = tb_MiddleName.Text, EFirstName = tb_FirstName.Text, BirthDate = dateTimePicker1.Value.Date, Age = tb_Age.Text, EmailAddress = tb_EmailAddress.Text, Gender = cb_Gender.SelectedItem.ToString(), CivilStatus = cb_CivilStatus.Text, CellphoneNo = tb_CellphoneNo.Text, Address = tb_Address.Text, DesignatedPostion = cb_DisignatedPosition.SelectedItem.ToString(), }; ctx.Employees.Attach(employeeUpdate); ctx.Entry(employeeUpdate).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); MessageBox.Show("Update Successful"); this.Close(); this.Dispose(); } } catch { } } }
private void SaveClient() { //Add Client user using (AxaContext ctx = new AxaContext()) { var clientInfo = new Client { CLastName = tb_LastName.Text, CMiddleName = tb_MiddleName.Text, CFirstName = tb_FirstName.Text, SpouseLastName = tb_SLastName.Text, SpouseMiddleName = tb_SMiddleName.Text, SpouseFirstName = tb_SFirstName.Text, Gender = cb_Gender.Text, CivilStatus = cb_CivilStatus.Text, PolicyStatus = cb_PolicyStatus.Text, CBirthday = dtp_Dob.Value, Age = tb_Age.Text, PlaceOfBirth = tb_PlaceOfBirth.Text, Height = 11, //Height = float.Parse(tb_Height.Text), //Weight = float.Parse(tb_Weight.Text), Weight = 11, CAddress = tb_Address.Text, CellphoneNo = tb_CellphoneNo.Text, TelephoneNo = tb_TelephoneNo.Text, EmailAddress = tb_EmailAddress.Text, Occupation = tb_COccupation.Text, //WorkSalary = float.Parse(tb_CWorkSalary.Text), //BusinessIncome = float.Parse(tb_CBusinessIncome.Text), //OtherSource = float.Parse(tb_COtherSource.Text), WorkSalary = 11, BusinessIncome = 11, OtherSource = 11, CompanyName = tb_CName.Text, CompanyAddress = tb_CAddress.Text, CompanyContact = tb_CompanyContactNo.Text, NatureOfBusiness = tb_CNatureOfBusiness.Text, TaxIdNumber = tb_TaxIdentication.Text, Sss_gsisNumber = tb_SSSorGSIS_Number.Text, ValidId1 = idPic1.Text, ValidId2 = idPic2.Text, // EmployeeId = tempEmployeeId EmployeeId = 1 }; ctx.Clients.Add(clientInfo); ctx.SaveChanges(); // save client plan var clientPlan = new ClientPlan(); for (int row = 0; row < dataGridView_LoadPlans.Rows.Count; row++) { clientPlan.PolicyNo = dataGridView_LoadPlans.Rows[row].Cells["col_PolicyNo"].Value.ToString(); clientPlan.SumInsured = dataGridView_LoadPlans.Rows[row].Cells["col_SumInsured"].Value.ToString(); clientPlan.ModeOfPayment = dataGridView_LoadPlans.Rows[row].Cells["col_ModeOfPayment"].Value.ToString(); clientPlan.DueOfPayment = Int32.Parse(dataGridView_LoadPlans.Rows[row].Cells["col_DueOfPayment"].Value.ToString()); string tempPlanCategory = dataGridView_LoadPlans.Rows[row].Cells["col_PlanCategory"].Value.ToString(); string tempPlanAvail = dataGridView_LoadPlans.Rows[row].Cells["col_PlanAvail"].Value.ToString(); var tempPlanId = ctx.Plans.Where(x => x.Category == tempPlanCategory && x.Description == tempPlanAvail).Select(p => p.PlanId).FirstOrDefault().ToString(); clientPlan.PlanId = Convert.ToInt32(tempPlanId); clientPlan.ClientId = clientInfo.ClientId; ctx.ClientPlans.Add(clientPlan); ctx.SaveChanges(); } } }
private void SaveUser() { using (AxaContext ctx = new AxaContext()) { if (tb_FName.Text == "") { MessageBox.Show("Please Filled up all the fields"); } else { if (dataGridView_User.SelectedRows.Count > 0) { try { bool statusAccount = false; if (radioButton1.Checked == true) { statusAccount = true; } else { statusAccount = false; } int userId = Int32.Parse(dataGridView_User.SelectedRows[0].Cells[0].Value.ToString()); var userUpdate = new User { UserId = userId, UFirstName = tb_FName.Text, UMiddleName = tb_MName.Text, ULastName = tb_LName.Text, ContactNumber = tb_ContactNo.Text, UserName = tb_Username.Text, Password = tb_Password.Text, UAddress = tb_Address.Text, UGender = cb_Gender.GetItemText(cb_Gender.SelectedItem), Role = cb_Role.GetItemText(cb_Role.SelectedItem), IsActive = statusAccount }; ctx.Users.Attach(userUpdate); ctx.Entry(userUpdate).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); ClearTextField(); LoadUserList(); MessageBox.Show("Update Successful"); } catch (Exception) { } } else { var user = new User { UFirstName = tb_FName.Text, UMiddleName = tb_MName.Text, ULastName = tb_LName.Text, ContactNumber = tb_ContactNo.Text, UserName = tb_Username.Text, Password = tb_Password.Text, UAddress = tb_Address.Text, UGender = cb_Gender.GetItemText(cb_Gender.SelectedItem), Role = cb_Role.GetItemText(cb_Role.SelectedItem) }; ctx.Users.Add(user); ctx.SaveChanges(); ClearTextField(); LoadUserList(); MessageBox.Show("Save Successful"); } } } }