public static void GetPlan(PolicyHolders newplan) { try { String str = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = 'F:\DDU STUFF\SEM 6\OOSE\LICPremiumPortal\LICPremiumPortal\LICPremiumPortal\LICPremiumPortalDB.mdf'; Integrated Security = True"; String query = "Insert into Policy_Holders( UserId , PlanId , Frequency , Opted_Amount , Policy_Term ) values (" + Form1.userid + "," + newplan.planId.planId + ",'" + newplan.frequency + "'," + newplan.optedAmount + "," + newplan.policyTerm + ")"; SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand(query, con); con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows == 0) { MessageBox.Show("Error inserting data into database !"); } else { MessageBox.Show("Please pay the first due premium to activate this plan!"); } } catch (Exception m) { MessageBox.Show(m.ToString()); } }
//Get this plan clicked private void Button1_Click(object sender, EventArgs e) { PolicyHolders pol = new PolicyHolders(); pol.frequency = comboBox1.SelectedItem.ToString(); pol.policyTerm = Convert.ToInt32(numericUpDown1.Value); pol.optedAmount = Convert.ToDouble(textBox1.Text); pol.planId = new Plans(); pol.planId.planId = Convert.ToInt32(label4.Text); PolicyHolders.GetPlan(pol); this.Close(); }
public DisplayQuotation() { InitializeComponent(); label4.Text = "( " + (PremiumCalculator.calc.planId.ToString()) + " )"; label7.Text = PremiumCalculator.calc.planName; double half, total, quart, full, month; total = PolicyHolders.calculatePremium(PremiumCalculator.age, PremiumCalculator.sum, PremiumCalculator.term); full = total; half = total / 2; quart = total / 3; month = total / 12; label15.Text = full.ToString("#.##"); label16.Text = half.ToString("#.##"); label17.Text = quart.ToString("#.##"); label18.Text = month.ToString("#.##"); }
public static List <PolicyHolders> showOngoingPolicies() { List <PolicyHolders> myPlans = new List <PolicyHolders>(); try { String str = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = 'F:\DDU STUFF\SEM 6\OOSE\LICPremiumPortal\LICPremiumPortal\LICPremiumPortal\LICPremiumPortalDB.mdf'; Integrated Security = True"; String query = "Select * from Policy_Holders as ph ,Plans as pl where ph.PlanId=pl.planId and ph.UserId=" + Form1.userid; SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand(query, con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); PolicyHolders plan; while (rdr.Read()) { plan = new PolicyHolders(); plan.policyNo = Convert.ToInt32(rdr["PolicyNo"]); plan.planId = new Plans(); plan.planId.planId = Convert.ToInt32(rdr["PlanId"]); plan.planId.planName = rdr["Plan_Name"].ToString(); plan.planId.planCategory = rdr["Plan_Category"].ToString(); plan.frequency = rdr["Frequency"].ToString(); plan.optedAmount = Convert.ToDouble(rdr["Opted_Amount"]); plan.policyTerm = Convert.ToInt32(rdr["Policy_Term"]); myPlans.Add(plan); } } catch (Exception es) { MessageBox.Show(es.Message); } return(myPlans); }
//Show results button clicked private void Button4_Click(object sender, EventArgs e) { //do //{ // foreach (DataGridViewRow row in dataGridView1.Rows) // { // try // { // dataGridView1.Rows.Remove(row); // } // catch (Exception) { } // } //} while (dataGridView1.Rows.Count > 1); //dataGridView1.Rows.Clear(); //dataGridView1.Refresh(); if (comboBox1.Text == "All available") { List <Plans> show; dataGridView1.DataSource = null; show = Plans.showExistingPlans(); if (show != null) { dataGridView1.DataSource = show; //dataGridView1.DataSource = null; //dataGridView1.AllowUserToOrderColumns = true; //dataGridView1.ColumnCount = 6; //dataGridView1.Columns[0].Name = "Plan Id"; //dataGridView1.Columns[1].Name = "Plan Name"; //dataGridView1.Columns[2].Name = "Plan Type"; //dataGridView1.Columns[3].Name = "Plan Description"; //dataGridView1.Columns[4].Name = "Minimum Policy Term"; //dataGridView1.Columns[5].Name = "Minimum Policy Amount"; //string[] rows; //for (int i = 0; i < show.Count; i++) //{ // DataGridViewRow r = new DataGridViewRow(); // rows = new string[] { // show[i].planId.ToString() , // show[i].planName , // show[i].planCategory, // show[i].planDescription, // show[i].minimumTermSpan.ToString(), // show[i].minimumAmount.ToString() // }; // r.SetValues(rows); // dataGridView1.Rows.Add(r); //} //show.Clear(); } } else if (comboBox1.Text == "My Ongoing") { List <PolicyHolders> ongoing = null; ongoing = PolicyHolders.showOngoingPolicies(); if (ongoing != null) { var l = (from obj in ongoing select new { obj.policyNo, obj.planId.planId, obj.planId.planName, obj.planId.planCategory, obj.policyTerm, obj.frequency, obj.optedAmount }).ToList(); dataGridView1.DataSource = l; //dataGridView1.AllowUserToOrderColumns = true; //dataGridView1.ColumnCount = 7; //dataGridView1.Columns[0].Name = "Client Policy No"; //dataGridView1.Columns[1].Name = "Plan Id"; //dataGridView1.Columns[2].Name = "Plan Name"; //dataGridView1.Columns[3].Name = "Plan Type"; //dataGridView1.Columns[4].Name = "Policy Term"; //dataGridView1.Columns[5].Name = "Premium Payment Freq."; //dataGridView1.Columns[6].Name = "Total Policy Amount"; //string[] rows; //for(int i=0; i<ongoing.Count; i++) //{ // DataGridViewRow r = new DataGridViewRow(); // rows = new string[] { ongoing[i].policyNo.ToString() , // ongoing[i].planId.planId.ToString() , // ongoing[i].planId.planName, // ongoing[i].planId.planCategory, // ongoing[i].policyTerm.ToString(), // ongoing[i].frequency, // ongoing[i].optedAmount.ToString() // }; // r.SetValues(rows); // dataGridView1.Rows.Add(r); //} //ongoing.Clear(); } else { MessageBox.Show(" You do not have any ongoing policies! "); } } }