Пример #1
0
        private void btnAddSupplier_Click(object sender, RoutedEventArgs e)
        {
            if (textBox.Text.Equals("") || textBox1.Text.Equals("") || textBox2.Text.Equals("") || comboBox.SelectedItem.ToString().Equals("") ||
                textBox3.Text.Equals("") || textBox4.Text.Equals("") || textBox5.Text.Equals(""))
            {
                MessageBox.Show("Please fill all fields");
            }
            else
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string Query = "insert into supplier values('" + textBox.Text + "', '" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboBox.Text + "', '" + datepicker.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "');";

                    MySqlCommand    MyCommand2 = new MySqlCommand(Query, conn);
                    MySqlDataReader MyReader2;

                    MyReader2 = MyCommand2.ExecuteReader();
                    MessageBox.Show("Data Added . . .");

                    textBox.Text  = ""; textBox1.Text = ""; textBox2.Text = "";
                    textBox3.Text = ""; textBox4.Text = ""; datepicker.Text = "";
                    textBox5.Text = "";

                    load_table();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
        {
            MySqlConnection conn = DBConnect.connectToDb();

            try
            {
                string q = "select * from appointment where pat_contact_no='" + pat_contact_no.Text + "';";

                MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                MySqlDataReader MyReader2;

                MyReader2 = MyCommand2.ExecuteReader();

                while (MyReader2.Read())
                {
                    pat_name.Text    = MyReader2.GetValue(0).ToString();
                    pat_age.Text     = MyReader2.GetValue(1).ToString();
                    pat_address.Text = MyReader2.GetValue(2).ToString();
                }
                MyReader2.Close();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message.ToString());
            }
        }
Пример #3
0
        private void btnAddDoctor_Click(object sender, RoutedEventArgs e)
        {
            if (textBox.Text.ToString().Equals(""))
            {
                MessageBox.Show("Please fill");
            }
            else
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string Query = "insert into user.doctor(name,age,contact_no,department,specialist_in,address,join_date,counsiling_hour,id,password) values('" + textBox.Text + "', '" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboboxDept.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + datepicker.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + textBox8.Text + "');";

                    MySqlCommand    MyCommand2 = new MySqlCommand(Query, conn);
                    MySqlDataReader MyReader2;

                    MyReader2 = MyCommand2.ExecuteReader();
                    MessageBox.Show("Data Added . . .");

                    textBox.Text      = ""; textBox1.Text = ""; textBox2.Text = "";
                    comboboxDept.Text = "";
                    textBox4.Text     = ""; textBox5.Text = "";
                    datepicker.Text   = ""; textBox6.Text = ""; textBox7.Text = "";
                    textBox8.Text     = "";
                    MyReader2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public void load_details()
        {
            MySqlConnection con = DBConnect.connectToDb();

            try
            {
                string           sql = "select * from appointment_medicine where pat_contact_no='" + contact_no + "' and appointment_date='" + date + "';";
                DataSet          ds  = new DataSet();
                MySqlDataAdapter da  = new MySqlDataAdapter(sql, con);
                da.Fill(ds);
                detailsDatagrid.ItemsSource = ds.Tables[0].DefaultView;
                con.Close();

                con.Open();
                //string sql2 = "select * from user.appointment_test where pat_contact_no='" + contact_no + "' and appointment_date='" + date + "';";
                string           sql2 = "SELECT * FROM appointment_test WHERE pat_contact_no='" + contact_no + "' AND appointment_date='" + date + "';";
                DataSet          ds2  = new DataSet();
                MySqlDataAdapter da2  = new MySqlDataAdapter(sql2, con);
                da2.Fill(ds2);
                detailsDatagrid2.ItemsSource = ds2.Tables[0].DefaultView;
            }
            catch (Exception except)
            {
                MessageBox.Show(except.Message.ToString());
            }
        }
        private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (textBox2.Text.Equals(""))
            {
                textBox.Text = "";
                status.Text  = "";
            }
            else
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string q = "select * from user.appointment where pat_contact_no='" + textBox2.Text + "';";

                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;

                    MyReader2 = MyCommand2.ExecuteReader();

                    while (MyReader2.Read())
                    {
                        textBox.Text = MyReader2.GetValue(0).ToString();
                        status.Text  = MyReader2.GetValue(8).ToString();
                        textBox.Focus();
                        status.Focus();
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message.ToString());
                }
            }
        }
Пример #6
0
        private void btnAddStaff_Click(object sender, RoutedEventArgs e)
        {
            if (textBox.Text.Equals("") || textBox1.Text.Equals("") || textBox2.Text.Equals("") || textBox3.Text.Equals("") || textBox4.Text.Equals("") || datepicker.Text.Equals("") || textBox5.Text.Equals("") || textBox7.Text.Equals("") || textBox8.Text.Equals(""))
            {
                MessageBox.Show("Please Fill All the fields");
            }

            else
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string Query = "insert into user.staff(name,age,contact_num,post,blood_group,join_date,address,staff_id,staff_password) values('" + textBox.Text + "', '" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + datepicker.Text + "', '" + textBox5.Text + "', '" + textBox7.Text + "', '" + textBox8.Text + "');";

                    MySqlCommand    MyCommand2 = new MySqlCommand(Query, conn);
                    MySqlDataReader MyReader2;

                    MyReader2 = MyCommand2.ExecuteReader();
                    MessageBox.Show("Data Added . . .");

                    conn.Close();

                    textBox.Text  = ""; textBox1.Text = ""; textBox2.Text = "";
                    textBox3.Text = ""; textBox4.Text = ""; datepicker.Text = "";
                    textBox5.Text = ""; textBox7.Text = ""; textBox8.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #7
0
 void load_table()
 {
     try
     {
         string           sql = "select company_name,contact_no,product_name,product_type,purchased_date,quantity from supplier;";
         MySqlConnection  con = DBConnect.connectToDb();
         DataSet          ds  = new DataSet();
         MySqlDataAdapter da  = new MySqlDataAdapter(sql, con);
         da.Fill(ds);
         datagridSupplier.ItemsSource = ds.Tables[0].DefaultView;
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.Message.ToString());
     }
 }
 void datagrid()
 {
     try
     {
         string           sql = "select product_name,quantity,selling_price,company_name from supplier where product_type='Medicine';";
         MySqlConnection  con = DBConnect.connectToDb();
         DataSet          ds  = new DataSet();
         MySqlDataAdapter da  = new MySqlDataAdapter(sql, con);
         da.Fill(ds);
         datagridDispensary.ItemsSource = ds.Tables[0].DefaultView;
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.Message.ToString());
     }
 }
 void load_table()
 {
     try
     {
         string           sql = "select * from user.appointment;";
         MySqlConnection  con = DBConnect.connectToDb();
         DataSet          ds  = new DataSet();
         MySqlDataAdapter da  = new MySqlDataAdapter(sql, con);
         da.Fill(ds);
         datagridAppointmentStatus.ItemsSource = ds.Tables[0].DefaultView;
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message.ToString());
     }
 }
Пример #10
0
 void show_all()
 {
     try
     {
         string           sql1 = "select pat_name,pat_age,pat_contact_no,pat_address,appointment_date,appointment_status from appointment where doc_id='" + ulala.Text + "' and appointment_status='" + "pending" + "';";
         MySqlConnection  con1 = DBConnect.connectToDb();
         DataSet          ds1  = new DataSet();
         MySqlDataAdapter da1  = new MySqlDataAdapter(sql1, con1);
         da1.Fill(ds1);
         datagridAllRequest.ItemsSource = ds1.Tables[0].DefaultView;
     }
     catch (Exception show)
     {
         MessageBox.Show(show.Message.ToString());
     }
 }
Пример #11
0
 void accept_table()
 {
     try
     {
         string           sql = "select pat_name,pat_age,pat_contact_no,pat_address,appointment_date,appointment_status from appointment where appointment_status='" + "Accepted" + "' and doc_id='" + ulala.Text + "';";
         MySqlConnection  con = DBConnect.connectToDb();
         DataSet          ds  = new DataSet();
         MySqlDataAdapter da  = new MySqlDataAdapter(sql, con);
         da.Fill(ds);
         datagridAccepted.ItemsSource = ds.Tables[0].DefaultView;
     }
     catch (Exception accept)
     {
         MessageBox.Show(accept.Message.ToString());
     }
 }
Пример #12
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            MySqlConnection conn = DBConnect.connectToDb();

            try
            {
                string          q          = "update appointment set appointment_status='" + "Accepted" + "' where pat_contact_no='" + contact_no + "' and appointment_date='" + textField + "';";////
                MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                MySqlDataReader MyReader2;
                MyReader2 = MyCommand2.ExecuteReader();
                MessageBox.Show("Appointment Accepted Succesfully . . .");
                conn.Close();
                accept_table();
                show_all();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #13
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MySqlConnection con        = DBConnect.connectToDb();
                string          q1         = "delete from appointment where pat_contact_no='" + contact_no + "' and appointment_date='" + textField + "';";
                MySqlCommand    MyCommand5 = new MySqlCommand(q1, con);
                MySqlDataReader MyReader5;
                MyReader5 = MyCommand5.ExecuteReader();
                MessageBox.Show("Appointment Rejected");
                MyReader5.Close();


                delete_request(); //Remove that patient because appointment is rejected
                show_all();       /// Refreshing Request Table
                                  ///
                con.Close();
            }
            catch (Exception ee) { MessageBox.Show(ee.Message.ToString()); }
        }
Пример #14
0
        void fill_combo()
        {
            MySqlConnection conn = DBConnect.connectToDb();

            try
            {
                string          Query      = "select * from product_type;";
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, conn);
                MySqlDataReader MyReader2;
                MyReader2 = MyCommand2.ExecuteReader();
                while (MyReader2.Read())
                {
                    string name = MyReader2.GetString(0);
                    comboBox.Items.Add(name);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (combobox.SelectedItem == null)
            {
                MessageBox.Show("Please choose an option");
            }
            else if (combobox.SelectedItem.Equals("Staff"))
            {
                /*StaffWindow objStaffWindow = new StaffWindow();
                 * objStaffWindow.Show();
                 * this.Close();*/

                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from staff where staff_id='" + textboxUsername.Text + "' and staff_password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                    if (MyReader2.Read())
                    {
                        MessageBox.Show("You have succesfully logged in");
                        StaffWindow objStaffWindow = new StaffWindow();
                        objStaffWindow.Show();
                        objStaffWindow.loginAsStaff.Text = textboxUsername.Text;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            else if (combobox.SelectedItem.Equals("Doctor"))
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from doctor where id='" + textboxUsername.Text + "' and password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();
                    if (MyReader2.Read())
                    {
                        MessageBox.Show("You have succesfully logged in");
                        DoctorWindow objDoctorWindow = new DoctorWindow();
                        objDoctorWindow.loginAsDoctor.Text = textboxUsername.Text;
                        objDoctorWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (combobox.SelectedItem.Equals("Adminstrator"))
            {
                MySqlConnection conn = DBConnect.connectToDb();
                try
                {
                    string          q          = "select * from admin where username='******' and password='******';";
                    MySqlCommand    MyCommand2 = new MySqlCommand(q, conn);
                    MySqlDataReader MyReader2;
                    MyReader2 = MyCommand2.ExecuteReader();
                    if (MyReader2.Read())
                    {
                        MessageBox.Show("You have succesfully logged in");
                        AdminWindow objAdminWindow = new AdminWindow();
                        objAdminWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password do not match");
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }