void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Teacher_Page1 = ((WpfApp2.Teacher_Page)(target));
                return;

            case 2:
                this.bordertashih = ((System.Windows.Controls.Border)(target));
                return;

            case 3:
                this.Qmount = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.Totalscore = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.SaveExam = ((System.Windows.Controls.Button)(target));

            #line 20 "..\..\Teacher Page.xaml"
                this.SaveExam.Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.lblusershow = ((System.Windows.Controls.Label)(target));
                return;

            case 7:

            #line 38 "..\..\Teacher Page.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);

            #line default
            #line hidden
                return;

            case 8:
                this.PictureBoxQ = ((System.Windows.Controls.Image)(target));
                return;

            case 9:

            #line 41 "..\..\Teacher Page.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_3);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (rdbINTeacher.IsChecked == true)
            {
                string INPass = userINTeacher.Text;
                int    i      = 0;
                int    count  = 0;

                /* SqlConnection cnn = new SqlConnection(connectionString);
                 * cnn.Open();
                 * string querystring = "select count(TeacherID)from Teacher";
                 * SqlCommand command = new SqlCommand(querystring, cnn);
                 * SqlDataReader reader = command.ExecuteReader();
                 *
                 * while (reader.Read())
                 * {
                 *   count = Convert.ToInt32(reader[0]);
                 *   //MessageBox.Show(count + "");
                 *
                 * }*/

                SqlConnection cnn1 = new SqlConnection(connectionString);

                //string querystring1 = "select * from Teacher";
                SqlCommand command1 = new SqlCommand();
                try
                {
                    if (userINTeacher.Text == string.Empty || PassINTeacher.Password == string.Empty)
                    {
                        MessageBox.Show("لطفا تمام فیلد های ورودی را تکمیل کنید", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    command1 = new SqlCommand("select count(*) from Teacher where TeacherID='" + userINTeacher.Text +
                                              "'and Password='******'", cnn1);
                    //SqlDataReader reader1 = command1.ExecuteReader();

                    if (cnn1.State == ConnectionState.Closed)
                    {
                        cnn1.Open();
                        i = (int)command1.ExecuteScalar();
                    }
                    cnn1.Close();
                    if (i > 0)
                    {
                        Teacher_Page frm = new Teacher_Page(userINTeacher.Text);
                        frm.Show();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("نام کاربری یا رمز عبور اشتباه است", "خطای ورود", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    i = 0;
                    cnn1.Close();
                }

                cnn1.Close();



                //-------------------------------------------------------------------------------------------

                /*cnn.Open();
                 * string querystringp = "select  Password from Teacher";
                 * SqlCommand commandp = new SqlCommand(querystringp, cnn);
                 * SqlDataReader readerp = commandp.ExecuteReader();
                 * while (readerp.Read())
                 * {
                 *   //b = readerp[1].ToString();
                 * }
                 * cnn.Close();*/
                // MessageBox.Show(a + " - " + b);

                //Teacher_Page f1 = new Teacher_Page();
                //f1.Show();
            }
            else if (rdbINStudent.IsChecked == true)
            {
                string INPass = userINTeacher.Text;
                int    i      = 0;
                int    count  = 0;

                /* SqlConnection cnn = new SqlConnection(connectionString);
                 * cnn.Open();
                 * string querystring = "select count(TeacherID)from Teacher";
                 * SqlCommand command = new SqlCommand(querystring, cnn);
                 * SqlDataReader reader = command.ExecuteReader();
                 *
                 * while (reader.Read())
                 * {
                 *   count = Convert.ToInt32(reader[0]);
                 *   //MessageBox.Show(count + "");
                 *
                 * }*/

                SqlConnection cnn1 = new SqlConnection(connectionString);

                //string querystring1 = "select * from Teacher";
                SqlCommand command1 = new SqlCommand();

                try
                {
                    if (userINTeacher.Text == string.Empty || PassINTeacher.Password == string.Empty)
                    {
                        MessageBox.Show("لطفا تمام فیلد های ورودی را تکمیل کنید", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    command1 = new SqlCommand("select count(*) from Student where StudentID='" + userINTeacher.Text +
                                              "'and Password='******'", cnn1);
                    //SqlDataReader reader1 = command1.ExecuteReader();

                    if (cnn1.State == ConnectionState.Closed)
                    {
                        cnn1.Open();
                        i = (int)command1.ExecuteScalar();
                    }
                    cnn1.Close();
                    if (i > 0)
                    {
                        Student_Page s2 = new Student_Page(userINTeacher.Text);
                        s2.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("نام کاربری یا رمز عبور اشتباه است", "خطای ورود", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    i = 0;
                    cnn1.Close();
                }

                cnn1.Close();
            }
            else
            {
                MessageBox.Show("لطفا سطح دسترسی خود را انتخاب کنید -استاد یا دانشجو");
            }
        }