private void button2_Click(object sender, RoutedEventArgs e)
        {
            checkLogin asw = new checkLogin();

            bool c = asw.checkLogin1();

            try
            {
                if (c)
                {
                    // pass = calculatePass();

                    //try
                    //{
                    //    total = Int32.Parse(textBox16.Text) + Int32.Parse(textBox17.Text) + Int32.Parse(textBox18.Text) + Int32.Parse(textBox19.Text) + Int32.Parse(textBox20.Text) + Int32.Parse(textBox31.Text);

                    //}
                    //catch
                    //{
                    //    total = 0;
                    //    MessageBox.Show("Something is missing");
                    //}


                    int total = Int32.Parse(textBox6.Text) + Int32.Parse(textBox7.Text) + Int32.Parse(textBox8.Text) + Int32.Parse(textBox9.Text) + Int32.Parse(textBox10.Text) + Int32.Parse(textBox28.Text) + Int32.Parse(textBox40.Text) + Int32.Parse(textBox41.Text) + Int32.Parse(textBox49.Text);
                    int nosub = total / 100;
                    //string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "insert into latestspas.exam (Student_idStudent,idClass,nepali, english, science,math,socialStudies,popAndEnvironment ,opt1,opt2,opt3,noSubject ) values ('" + this.sId.Text + "','" + (_class.SelectedIndex + 1) + "','" + this.textBox16.Text + "','" + this.textBox17.Text + "', '" + this.textBox18.Text + "', '" + this.textBox19.Text + "', '" + this.textBox20.Text + "', '" + this.textBox31.Text + "', '" + this.textBox44.Text + "','" + this.textBox45.Text + "','" + this.textBox51.Text + "','" + nosub + "') ;";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();
                        MessageBox.Show("Data has been Saved Successfully");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Something errors occurs in Database" + ex.Message);
                    }
                }


                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch
            {
                MessageBox.Show("Some Invalid Occurs");
            }
        }
Esempio n. 2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            //int total;
            string     Query;
            checkLogin asw = new checkLogin();
            bool       c   = asw.checkLogin1();

            try
            {
                if (c)
                {
                    //try
                    //{

                    //    total = Int32.Parse(textBox16.Text) + Int32.Parse(textBox17.Text) + Int32.Parse(textBox18.Text) + Int32.Parse(textBox19.Text) + Int32.Parse(textBox20.Text) + Int32.Parse(textBox31.Text)+Int32.Parse(textBox78.Text) + Int32.Parse(textBox79.Text) + Int32.Parse(textBox80.Text);

                    //}
                    //catch
                    //{
                    //    total = 0;
                    //    System.Windows.Forms.MessageBox.Show("Something is missing");
                    //}

                    // string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string constring = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    // System.Windows.Forms.MessageBox.Show(comboxx);

                    Query = "update latestspas.exam set nepali= '" + this.textBox16.Text + "', english='" + this.textBox17.Text + "', science= '" + this.textBox18.Text + "', socialStudies= '" + this.textBox20.Text + "', popAndEnvironment='" + this.textBox31.Text + "', math= '" + this.textBox19.Text + "'where  Student_idStudent='" + this.sId.Text + "' and idClass='" + (comboBox.SelectedIndex + 1) + "' ;";


                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();
                        System.Windows.Forms.MessageBox.Show("Data has been Updated");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show("Error in Updating " + ex.Message);
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("please login as Admin first");
                }
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Some Invalid Occurs");
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            checkLogin asw = new checkLogin();


            bool c = asw.checkLogin1();

            try
            {
                if (c)
                {
                    //string EncrptString = encrpted.Encrypt(this.password.Text);
                    // string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "insert into latestspas.staff (idStaff,name, address, mobile_number, gender, dob, email, father_name, mother_name) values ('" + this.Id.Text + "','" + this.Name.Text + "','" + this.Address.Text + "', '" + this.mobile.Text + "', '" + Gender + "', '" + this.DatePicker.Text + "', '" + this.Email1.Text + "', '" + this.FatherName.Text + "', '" + this.MotherName.Text + "') ; insert into latestspas.login (login_id, password,profession,Staff_idStaff) values ('" + this.Id.Text + "', password('" + this.password.Text + "'),'" + profession + "','" + this.Id.Text + "');";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();

                        MessageBox.Show("Data has been Saved Successfully");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Something errors occurs in Database" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch
            {
                MessageBox.Show("Some Invalid Occurs");
            }
        }
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            checkLogin asw = new checkLogin();


            bool c = asw.checkLogin1();

            try
            {
                if (c)
                {
                    // string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "insert into latestspas.remainder (event_name, event_date, event_by, event_details, staff_idStaff ) values ('" + this.EventName.Text + "','" + this.dateInsert.Text + "','" + this.EventBy.Text + "','" + this.EventDetails.Text + "','" + login.GID + "') ;";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();

                        MessageBox.Show("Data has been Saved Successfully");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Something errors occurs in Database" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch
            {
                MessageBox.Show("Some Invalid Occurs");
            }
        }
Esempio n. 5
0
        private void button_Click(object sender, RoutedEventArgs e) // pressing the apply button
        {
            checkLogin asw = new checkLogin();
            bool       c   = asw.checkLogin1();


            try
            {
                if (c == true)
                {
                    string enPassword = encrpted.Encrypt(this.Password.Text);
                    //string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "insert into latestspas.student (idStudent, name, address, class, dob, roll_no, father_name,father_phone, father_mobile, father_email, mother_name, mother_phone, mother_mobile, mother_email, gender, bus, hostel) values ('" + this.studentId.Text + "','" + this.Name.Text + "', '" + this.Address.Text + "', '" + this.Class.Text + "', '" + this.DatePicker.Text + "', '" + this.RollNo.Text + "','" + this.FatherName.Text + "', '" + this.Phone.Text + "', '" + this.MobileNumber.Text + "', '" + this.Email.Text + "', '" + this.MotherName.Text + "', '" + this.Phone1.Text + "', '" + this.MobileNumber1.Text + "', '" + this.Email1.Text + "', '" + Gender + "' , '" + BusService + "', '" + HostelService + "') ; insert into latestspas.login (login_id, password,profession,Student_idStudent) values ('" + this.studentId.Text + "', '" + enPassword + "','" + "student" + "','" + this.studentId.Text + "');  ";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();
                        //addStudentNumber();

                        MessageBox.Show("Data has been Saved Successfully");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Something errors occurs in Database" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch {
                MessageBox.Show("Some Invalid Occurs");
            }
        }
        private void Deletebutton_Click(object sender, RoutedEventArgs e)
        {
            checkLogin asw = new checkLogin();

            bool c = asw.checkLogin1();

            try
            {
                if (c == true)
                {
                    //string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "delete from latestspas.staff where idStaff = '" + this.Id.Text + "';";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();
                        MessageBox.Show("Data has been Deleted Successfully");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error in Deleting " + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch
            {
                MessageBox.Show("Some Invalid Occurs");
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            checkLogin asw = new checkLogin();
            bool       c   = asw.checkLogin1();

            try
            {
                if (c)
                {
                    string EncrptString = encrpted.Encrypt(this.password.Text);
                    //string constring = "datasource=localhost;port=3306;username=root;password=12345";
                    string          constring   = ConfigurationManager.ConnectionStrings["MySQL"].ToString();
                    string          Query       = "update latestspas.staff set name= '" + this.Name.Text + "' , idStaff= '" + this.Id.Text + "', address= '" + this.Address.Text + "', mobile_number='" + this.mobile.Text + "', gender= '" + Gender + "', dob= '" + this.DatePicker.Text + "', email= '" + this.Email1.Text + "', father_name= '" + this.FatherName.Text + "', mother_name= '" + this.MotherName.Text + "' where  idStaff='" + this.Id.Text + "' ; update latestspas.login set Staff_idStaff= '" + this.Id.Text + "', login_id= '" + this.Id.Text + "', password='******', profession='" + profession + "'where  Staff_idStaff='" + this.Id.Text + "' ";
                    MySqlConnection conDatabase = new MySqlConnection(constring);
                    MySqlCommand    cmdDatabase = new MySqlCommand(Query, conDatabase);
                    MySqlDataReader myReader;

                    try
                    {
                        conDatabase.Open();
                        myReader = cmdDatabase.ExecuteReader();
                        MessageBox.Show("Data has been Updated");
                        while (myReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error in Updating " + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("please login as Admin first");
                }
            }
            catch {
                MessageBox.Show("Some Invalid Occurs");
            }
        }