public bool insertPhysician(string id, string name, string speciality, string workhrs, string workdays, string number)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `physician`(`Physician_id`, `Physician Name`, `Speciality`, `Working Hours`, `Working Days`, `Contact Number`) VALUES (@id,@nm,@speclty,@wrkhrs,@wrkdays,@num)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@id", MySqlDbType.VarChar).Value      = id;
            command.Parameters.Add("@nm", MySqlDbType.VarChar).Value      = name;
            command.Parameters.Add("@speclty", MySqlDbType.VarChar).Value = speciality;
            command.Parameters.Add("@wrkhrs", MySqlDbType.VarChar).Value  = workhrs;
            command.Parameters.Add("@wrkdays", MySqlDbType.VarChar).Value = workdays;
            command.Parameters.Add("@num", MySqlDbType.VarChar).Value     = number;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
            //return true;
        }
        public DataTable getStaffs()
        {
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `staffs` ", conn.getConnection());
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            DataTable        table   = new DataTable();

            adapter.SelectCommand = command;
            adapter.Fill(table);

            return(table);
        }
        public bool insertPatient(string id, string name, string age, string sex, string number, string address, string testsdone, string testres, string medicalhist, string reasonofassess, string allergies, string dob, string bloodgroup, string physician_id, string date, string ward_num, string time)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `patients`(Patient_id, Patient_Name, Age, Sex, Contact_Number, Address, Tests_Done, Tests_Results, Medical_History, Reason_for_Assessment, Allergies, Date_Of_Birth, Blood_Group, Physician_id_fk, Date_Of_Visit, Ward_Numer, Time) VALUES( @id,@nm, @age,@sex, @num, @address, @tests, @res, @hist, @rsn, @alrg, @dob, @bldgrp, @doc, @date, @wrdnum, @time)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@id", MySqlDbType.VarChar).Value      = id;
            command.Parameters.Add("@nm", MySqlDbType.VarChar).Value      = name;
            command.Parameters.Add("@age", MySqlDbType.VarChar).Value     = age;
            command.Parameters.Add("@sex", MySqlDbType.VarChar).Value     = sex;
            command.Parameters.Add("@num", MySqlDbType.VarChar).Value     = number;
            command.Parameters.Add("@address", MySqlDbType.VarChar).Value = address;
            command.Parameters.Add("@tests", MySqlDbType.VarChar).Value   = testsdone;
            command.Parameters.Add("@res", MySqlDbType.VarChar).Value     = testres;
            command.Parameters.Add("@hist", MySqlDbType.VarChar).Value    = medicalhist;
            command.Parameters.Add("@rsn", MySqlDbType.VarChar).Value     = reasonofassess;
            command.Parameters.Add("@alrg", MySqlDbType.VarChar).Value    = allergies;
            command.Parameters.Add("@dob", MySqlDbType.VarChar).Value     = dob;
            command.Parameters.Add("@bldgrp", MySqlDbType.VarChar).Value  = bloodgroup;
            command.Parameters.Add("@doc", MySqlDbType.VarChar).Value     = physician_id;
            command.Parameters.Add("@date", MySqlDbType.VarChar).Value    = date;
            command.Parameters.Add("@wrdnum", MySqlDbType.VarChar).Value  = ward_num;
            command.Parameters.Add("@time", MySqlDbType.VarChar).Value    = time;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
            //return true;
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            CONNECT          conn    = new CONNECT();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           query   = "SELECT * FROM `users` WHERE `username`=@usn AND `password`=@pass";

            command.CommandText = query;
            command.Connection  = conn.getConnection();
            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = textBoxUsername.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPassword.Text;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                //MessageBox.Show("YES");
                this.Hide();
                Main_Form mform = new Main_Form();
                mform.Show();
            }
            else
            {
                //MessageBox.Show("No");
                if (textBoxUsername.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter your username to Login", "Empty username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (textBoxPassword.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter your password to Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Incorrect password or username", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }