Esempio n. 1
0
        /*Function for subscription*/
        private void sup_btn_subscribe_Click(object sender, RoutedEventArgs e)
        {
            char[] sup_chk_duname = new char[30];                         //variable for converting string to char array

            if (sup_tbox_fname.Text == "")                                //check if First name text box is blank
            {
                img_fname.Visibility = System.Windows.Visibility.Visible; //show error image
                flag = 0;                                                 //all mandatory fields are
            }

            /*check whether date,month or year of birthdate is blank or not*/
            if (sup_bdate_date.SelectedIndex == -1 || sup_bdate_month.SelectedIndex == -1 || sup_bdate_year.Text == "")
            {
                img_dob.Visibility = Visibility.Visible;
                flag = 0;
            }
            /*If birthdate is not blank*/
            else
            {
                int temp_date = int.Parse(sup_bdate_date.SelectionBoxItem.ToString());
                int temp_year = int.Parse(sup_bdate_year.Text);

                /*Check for validation of leap year*/
                if (((sup_bdate_month.SelectionBoxItem.ToString() == "April") || (sup_bdate_month.SelectionBoxItem.ToString() == "June") || (sup_bdate_month.SelectionBoxItem.ToString() == "September") || (sup_bdate_month.SelectionBoxItem.ToString() == "November")) && (temp_date == 31))
                {
                    img_dob.Visibility = Visibility.Visible;
                    flag = 0;
                }
                if ((sup_bdate_month.SelectionBoxItem.ToString() == "February"))
                {
                    if (temp_year % 400 == 0 || (temp_year % 100 != 0 && temp_year % 4 == 0))
                    {
                        if ((temp_date == 30) || (temp_date == 31))
                        {
                            img_dob.Visibility = Visibility.Visible;
                            flag = 0;
                        }
                    }
                    else
                    {
                        if ((temp_date == 30) || (temp_date == 31) || (temp_date == 29))
                        {
                            img_dob.Visibility = Visibility.Visible;
                            flag = 0;
                        }
                    }
                }
            }

            if (sup_tbox_lname.Text == "")//Check whether last name is blank or not if blank then enter
            {
                //System.Windows.Browser.HtmlPage.Window.Alert("Please enter last name.");
                img_lname.Visibility = System.Windows.Visibility.Visible;
                flag = 0;
            }

            if (sup_tbox_duname.Text == "")//Check whether desired user name is blank or not if blank then enter
            {
                //System.Windows.Browser.HtmlPage.Window.Alert("Please enter Desired user name.");
                img_duname.Visibility = System.Windows.Visibility.Visible;
                flag = 0;
            }

            if (sup_pbox_pswd.Password == "")//Check whether password box is blank or not if blank then enter
            {
                //System.Windows.Browser.HtmlPage.Window.Alert("Please enter password.");
                img_pswd.Visibility = System.Windows.Visibility.Visible;
                flag = 0;
            }

            //Check whether both passwords matches or not
            if (sup_pbox_pswd.Password != sup_pbox_vpswd.Password)
            {
                img_pswd.Visibility  = System.Windows.Visibility.Visible;
                img_vpswd.Visibility = System.Windows.Visibility.Visible;
                System.Windows.Browser.HtmlPage.Window.Alert("Passwords does not match.");
                flag = 0;
            }

            //Check whether permanent email is blank or not if blank then enter
            if (sup_tbox_pemail.Text == "")
            {
                //System.Windows.Browser.HtmlPage.Window.Alert("Please enter primary Email ID.");
                img_pemail.Visibility = System.Windows.Visibility.Visible;
                flag = 0;
            }

            //Check whether alternet email is blank or not if blank then enter
            if (sup_tbox_pemail.Text == sup_tbox_aemail.Text && !(sup_tbox_pemail.Text == ""))
            {
                img_aemail.Visibility = System.Windows.Visibility.Visible;
                System.Windows.Browser.HtmlPage.Window.Alert("Primary and Alternate Email ID can not be same.");
                flag = 0;
            }

            /*If there is no error in any mandatory fields then make entry in database*/
            if (flag == 1)
            {
                DemoServiceClient webService = new DemoServiceClient();

                webService.InsertDataAsync(sup_tbox_fname.Text, sup_tbox_lname.Text, sup_tbox_duname.Text, sup_tbox_add.Text, malefemale, global_bdate, sup_pbox_pswd.Password, sup_tbox_pemail.Text, sup_tbox_aemail.Text);

                System.Windows.MessageBox.Show("Congratulation!!! You have subscribed succesfully.");

                App.Navigate(new Page());
            }
        }