Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace NewWebDating
- {
- public partial class Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- LblCaption.Visible = false;
- string[] gender = new string[0];
- //string[] gender = new string[3];
- //gender[0] = "Select";
- //gender[1] = "Male";
- //gender[2] = "Female";
- //DrpGender.DataSource = gender;
- //DrpGender.DataBind();
- ViewState.Add("Gender", gender);
- int[] age = new int[0];
- ViewState.Add("Age", age);
- string[] prefGender1 = new string[0];
- ViewState.Add("PrefGender1", prefGender1);
- String[] prefGender2 = new string[0];
- ViewState.Add("PrefGender2", prefGender2);
- //DateTime today = DateTime.Now;
- //startCal.SelectedDate = today.Date;
- DateTime[] startDate = new DateTime[0];
- ViewState.Add("StartDate", startDate);
- DateTime[] arrendcal = new DateTime[0];
- ViewState.Add("Arrendcal", arrendcal);
- }
- }
- protected void saveButton_Click(object sender, EventArgs e)
- {
- #region Gender
- string[] gender = (string[])ViewState["Gender"];
- Array.Resize(ref gender, gender.Length + 1);
- int ArrayUpperIndex = gender.GetUpperBound(0);
- // gender[0]
- // gender[1]
- string[] genderMatchItem = new string[0];
- int j = 0;
- Random rnd = new Random();
- for (int i = 0; i < ArrayUpperIndex; i++) // we use the for loop to search the Array elements
- {
- if (gender[i] == DrpGender.SelectedItem.Text.ToString())
- {
- Array.Resize(ref genderMatchItem, genderMatchItem.Length + 1);
- genderMatchItem[j] = gender[i].ToString();
- j = j + 1;
- //resultLabel1.Text = gender[i].ToString();
- }
- }
- gender[ArrayUpperIndex] = DrpGender.SelectedItem.Text.ToString();
- if (j == 1)
- {
- resultLabel1.Text = genderMatchItem[0].ToString();
- }
- else if (j > 1)
- {
- int rndInt = rnd.Next(j - 1);
- resultLabel1.Text = genderMatchItem[rndInt].ToString();
- LblCaption.Visible = true;
- }
- ViewState.Add("Gender", gender);
- #endregion
- #region Age
- int[] age = (int[])ViewState["Age"];
- Array.Resize(ref age, age.Length + 1);
- int newItem1 = age.GetUpperBound(0);
- string[] ageMatchItem = new string[0];
- int z = 0;
- for (int i = 0; i < newItem1; i++)
- {
- if (age[i] == int.Parse(DrpAge.SelectedItem.Value))
- {
- Array.Resize(ref ageMatchItem, ageMatchItem.Length + 1);
- ageMatchItem[z] = age[i].ToString();
- z = z + 1;
- }
- }
- age[newItem1] = int.Parse(DrpAge.SelectedItem.Value);
- int arrupperIndex = age.GetUpperBound(0);
- if (z == 1)
- {
- resultLabel2.Text = ageMatchItem[0].ToString();
- }
- else if (z > 1)
- {
- Random rnd1 = new Random();
- int rndInt1 = rnd.Next(arrupperIndex);
- resultLabel2.Text = ageMatchItem[rndInt1].ToString();
- LblCaption.Visible = true;
- }
- ViewState.Add("Age", age);
- #endregion
- #region Prefered Gender1
- string[] prefGender1 = (string[])ViewState["PrefGender1"];
- Array.Resize(ref prefGender1, prefGender1.Length + 1);
- int newItem2 = prefGender1.GetUpperBound(0);
- string[] prefGen1MatchItem = new string[0];
- //Array.Resize(ref prefGen1MatchItem, prefGen1MatchItem.Length + 1);
- //int arrUpperIndexG1 = prefGender1.GetUpperBound(0);
- int t = 0;
- for (int i = 0; i < newItem2; i++)
- {
- if (prefGender1[i] == DrpprefGender1.SelectedItem.Value)
- {
- Array.Resize(ref prefGen1MatchItem, prefGen1MatchItem.Length + 1);
- prefGen1MatchItem[t] = prefGender1[i].ToString();
- t = t + 1;
- }
- prefGender1[newItem2] = DrpprefGender1.SelectedItem.Value.ToString();
- if (t == 1)
- {
- resultLabel3.Text = prefGen1MatchItem[0].ToString();
- }
- else
- {
- Random rnd2 = new Random();
- int rndInt2 = rnd.Next(t - 1);
- resultLabel3.Text = prefGen1MatchItem[rndInt2].ToString();
- }
- ViewState.Add("PrefGender1", prefGender1);
- #endregion
- #region Prefered Gender 2
- string[] prefGender2 = (string[])ViewState["PrefGender2"];
- Array.Resize(ref prefGender2, prefGender2.Length + 1);
- int newItem3 = prefGender2.GetUpperBound(0);
- string[] prefGen2MatchItem = new string[0];
- //Array.Resize(ref prefGen2MatchItem, prefGen2MatchItem.Length + 1);
- int f = 0;
- for (int g = 0; g < newItem3; g++)
- {
- if (prefGender2[g] == DrpprefGender2.SelectedItem.Value)
- {
- Array.Resize(ref prefGen2MatchItem, prefGen2MatchItem.Length + 1);
- prefGen2MatchItem[f] = prefGender1[g].ToString();
- f = f + 1;
- }
- prefGender2[newItem3] = DrpprefGender2.SelectedItem.Value.ToString();
- int arrUpperIndexG2 = prefGender2.GetUpperBound(0);
- if (f == 1)
- {
- resultLabel4.Text = prefGen2MatchItem[0].ToString();
- }
- else
- {
- Random rnd3 = new Random();
- int rndInt3 = rnd.Next(arrUpperIndexG2);
- resultLabel4.Text = prefGen2MatchItem[rndInt3].ToString();
- }
- ViewState.Add("PrefGender2", prefGender2);
- #endregion
- #region Start Calendar Date
- DateTime[] startDate = (DateTime[])ViewState["StartDate"];
- Array.Resize(ref startDate, startDate.Length + 1);
- int newItem4 = startDate.GetUpperBound(0);
- string[] calMatchItem1 = new string[0];
- //Array.Resize(ref calMatchItem1, calMatchItem1.Length + 1);
- int h = 0;
- for (int w = 0; w < newItem4; w++)
- {
- if (startDate[w] == startCal.SelectedDate)
- {
- Array.Resize(ref calMatchItem1, calMatchItem1.Length + 1);
- calMatchItem1[f] = startDate[w].ToString();
- h = h + 1;
- }
- startDate[newItem4] = startCal.SelectedDate;
- int arrUpperIndexC1 = startDate.GetUpperBound(0);
- if (h == 1)
- {
- resultLabel5.Text = calMatchItem1[0].ToString();
- }
- else
- {
- Random rnd4 = new Random();
- int rndInt4 = rnd.Next(arrUpperIndexC1);
- resultLabel5.Text = calMatchItem1[rndInt4].ToString();
- }
- ViewState.Add("StartDate", startDate);
- #endregion
- #region End Calendar Date
- DateTime[] arrendcal = (DateTime[])ViewState["Arrendcal"];
- Array.Resize(ref arrendcal, arrendcal.Length + 1);
- int newItem5 = arrendcal.GetUpperBound(0);
- string[] calMatchItem2 = new string[0];
- //Array.Resize(ref calMatchItem2, calMatchItem2.Length + 1);
- int d = 0;
- for (int k = 0; k < newItem5; k++)
- {
- if (arrendcal[k] == endCal.SelectedDate)
- {
- Array.Resize(ref calMatchItem2, calMatchItem2.Length + 1);
- calMatchItem2[f] = arrendcal[k].ToString();
- d = d + 1;
- }
- arrendcal[newItem5] = endCal.SelectedDate;
- int arrUpperIndexC2 = arrendcal.GetUpperBound(0);
- if (d == 1)
- {
- resultLabel6.Text = calMatchItem2[0].ToString();
- }
- else
- {
- Random rnd5 = new Random();
- int rndInt5 = rnd.Next(arrUpperIndexC2);
- resultLabel6.Text = calMatchItem2[rndInt5].ToString();
- }
- ViewState.Add("Arrendcal", arrendcal);
- #endregion
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement