Example #1
0
        private void logincheck()
        {
            if (!(String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text)))
            {
                try
                {
                    connection CN = new connection();
                    CN.thisConnection.Open();
                    OracleCommand thisCommand = new OracleCommand();
                    thisCommand.Connection  = CN.thisConnection;
                    thisCommand.CommandText = "SELECT * FROM HOSPITAL_LOGIN WHERE username='******' AND password='******'";
                    thisReader = thisCommand.ExecuteReader();



                    if (thisReader.Read())
                    {
                        if (comboBox1.Text == "Administrator" && thisReader["designation"].ToString() == "admin")
                        {
                            AdminPage oform = new AdminPage();
                            oform.Show();
                            this.Hide();
                        }
                        else if (comboBox1.Text == "Doctor" && thisReader["designation"].ToString() == "doctor")
                        {
                            DoctorPage pat = new DoctorPage(textBox1.Text);
                            pat.Show();
                            this.Hide();
                        }
                        else if (comboBox1.Text == "Receptionist" && thisReader["designation"].ToString() == "receptionist")
                        {
                            PatientPage oform = new PatientPage();
                            oform.Show();
                            this.Hide();
                        }
                        else if (comboBox1.Text == "Compounder" && thisReader["designation"].ToString() == "compounder")
                        {
                            compounder oform = new compounder();
                            oform.Show();
                            this.Hide();
                        }
                        else if (comboBox1.Text == "Nurse" && thisReader["designation"].ToString() == "nurse")
                        {
                            nurse_page oform = new nurse_page();
                            oform.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("select your using position");
                        }
                    }
                    else
                    {
                        MessageBox.Show("username or password incorrect");
                    }
                    //this.Close();
                    CN.thisConnection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }


            else
            {
                MessageBox.Show("Please input username and password!!!!");
            }
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            connection sv = new connection();

            sv.thisConnection.Open();

            OracleCommand thisCommand = sv.thisConnection.CreateCommand();

            thisCommand.CommandText =
                "SELECT * FROM HOSPITAL_LOGIN where username='******'";

            OracleDataReader thisReader = thisCommand.ExecuteReader();

            if (!thisReader.Read())
            {
                OracleDataAdapter    thisAdapter  = new OracleDataAdapter(" SELECT * FROM doctor_data", sv.thisConnection);
                OracleDataAdapter    thisAdapter2 = new OracleDataAdapter(" SELECT * FROM salary_account ", sv.thisConnection);
                OracleDataAdapter    thisAdapter3 = new OracleDataAdapter(" SELECT * FROM hospital_login ", sv.thisConnection);
                OracleCommandBuilder thisBuilder  = new OracleCommandBuilder(thisAdapter);
                OracleCommandBuilder thisBuilder2 = new OracleCommandBuilder(thisAdapter2);
                OracleCommandBuilder thisBuilder3 = new OracleCommandBuilder(thisAdapter3);
                DataSet thisDataSet = new DataSet();
                thisAdapter.Fill(thisDataSet, "doctor_data");
                DataSet thisDataSet2 = new DataSet();
                thisAdapter2.Fill(thisDataSet2, "salary_account");
                DataSet thisDataSet3 = new DataSet();
                thisAdapter3.Fill(thisDataSet3, "hospital_login");
                DataRow thisRow = thisDataSet.Tables["doctor_data"].NewRow();
                DataRow hello   = thisDataSet2.Tables["salary_account"].NewRow();
                DataRow account = thisDataSet3.Tables["hospital_login"].NewRow();

                try
                {
                    if (position.Text.Contains("doctor") == true)
                    {
                        thisRow["doc_id"]           = Id.Text;
                        hello["id"]                 = Id.Text;
                        thisRow["doc_name"]         = em_name.Text;
                        hello["name"]               = em_name.Text;
                        thisRow["appointment_time"] = textBox1.Text;
                        thisRow["doc_des"]          = Designation.Text;
                        hello["position"]           = position.Text;
                        thisRow["ward_no"]          = ward_no.Text;
                        thisRow["duty_time"]        = DutyTime.Text;
                        hello["join_date"]          = dateTimePicker1.Text;
                        thisRow["department"]       = depart.Text;
                        hello["duty_time"]          = DutyTime.Text;
                        hello["salary"]             = salaryBox.Text;
                        hello["accountid"]          = acId.Text;
                        account["username"]         = un.Text;
                        account["password"]         = pass.Text;
                        account["designation"]      = position.Text;
                        account["id"]               = Id.Text;

                        thisDataSet.Tables["doctor_data"].Rows.Add(thisRow);

                        thisAdapter.Update(thisDataSet, "doctor_data");

                        thisDataSet2.Tables["salary_account"].Rows.Add(hello);

                        thisAdapter2.Update(thisDataSet2, "salary_account");
                        thisDataSet3.Tables["hospital_login"].Rows.Add(account);

                        thisAdapter3.Update(thisDataSet3, "hospital_login");

                        MessageBox.Show("Submitted");
                    }
                    else if (position.Text.Contains("doctor") == false)
                    {
                        hello["id"]            = Id.Text;
                        hello["name"]          = em_name.Text;
                        hello["position"]      = position.Text;
                        hello["join_date"]     = dateTimePicker1.Text;
                        hello["duty_time"]     = DutyTime.Text;
                        hello["salary"]        = salaryBox.Text;
                        hello["accountid"]     = acId.Text;
                        account["username"]    = un.Text;
                        account["password"]    = pass.Text;
                        account["designation"] = position.Text;
                        account["id"]          = Id.Text;

                        thisDataSet2.Tables["salary_account"].Rows.Add(hello);
                        thisAdapter2.Update(thisDataSet2, "salary_account");

                        thisDataSet3.Tables["hospital_login"].Rows.Add(account);

                        thisAdapter3.Update(thisDataSet3, "hospital_login");

                        MessageBox.Show("Submitted");
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                sv.thisConnection.Close();

                AdminPage ob = new AdminPage();
                ob.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("username already exists.");
            }
        }