Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection connLogin = new SqlConnection(sQuery.ConnectString());

            sQuery.Command = @"select * from Staff where S_Username = '******' AND S_Password = '******' AND S_Restriction = '" + cboEmpRestriction.Text + "'";
            try
            {
                connLogin.Open();
                SqlCommand    cmd        = new SqlCommand(sQuery.Command, connLogin);
                SqlDataReader dataReader = cmd.ExecuteReader();
                if (dataReader.HasRows)
                {
                    if (cboEmpRestriction.Text == "Administrator")
                    {
                        MessageBox.Show("Successfully Logged In", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        WinForms.Admin.Show();
                        WinForms.Main.Hide();
                        globals.setCredentials(txtEmpUser.Text, txtEmpPass.Text, cboEmpRestriction.Text);
                    }
                    else if (cboEmpRestriction.Text == "Dentist")
                    {
                        MessageBox.Show("Successfully Logged In", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        WinForms.Dentist.Show();
                        WinForms.Main.Hide();
                        globals.setCredentials(txtEmpUser.Text, txtEmpPass.Text, cboEmpRestriction.Text);
                    }
                    else
                    {
                        MessageBox.Show("Successfully Logged In", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        WinForms.Patient.Show();
                        WinForms.Main.Hide();
                        globals.setCredentials(txtEmpUser.Text, txtEmpPass.Text, cboEmpRestriction.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password!", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEmpUser.Focus();
                    txtEmpPass.Clear();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connLogin.Close();
            }
        }
Exemplo n.º 2
0
        void update()
        {
            dataPatient.AutoResizeColumns();


            dataPatient.AutoSizeColumnsMode =
                DataGridViewAutoSizeColumnsMode.AllCells;
            SqlConnection  con;
            SqlDataAdapter adapt;
            DataTable      dt;

            con = new SqlConnection(sQuery.ConnectString());
            con.Open();
            SqlConnection conn = new SqlConnection(sQuery.ConnectString());

            adapt = new SqlDataAdapter("select * from Patient", con);
            dt    = new DataTable();
            adapt.Fill(dt);
            dataPatient.DataSource = dt;
            con.Close();
        }
Exemplo n.º 3
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(sQuery.ConnectString());

            if (txtPatientID.Text != "" && txtPatientFName.Text != "" && txtPatientLName.Text != "" && txtPatientMName.Text != "" && txtPatientAge.Text != "" && cboPatientSex.Text != "" && txtPatientAdd.Text != "" && txtPatientContact.Text != "")
            {
                conn.Open();
                sQuery.Command = "INSERT INTO Patient VALUES (" + txtPatientID.Text + " , '" + txtPatientLName.Text + "' , '" + txtPatientFName.Text + "' , '" + txtPatientMName.Text + "' , " + txtPatientAge.Text + " , '" + cboPatientSex.Text + "' ,'" + txtPatientAdd.Text + "' ,'" + txtPatientContact.Text + "')";
                SqlCommand SDA = new SqlCommand(sQuery.Command, conn);
                try
                {
                    SDA.ExecuteNonQuery();
                    MessageBox.Show("Added Successfully!");
                    txtPatientID.Text      = "";
                    txtPatientFName.Text   = "";
                    txtPatientLName.Text   = "";
                    txtPatientAge.Text     = "";
                    txtPatientContact.Text = "";
                    txtPatientAdd.Text     = "";
                    txtPatientMName.Text   = "";
                    cboPatientSex.Text     = "";
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Values!");
                }
                finally
                {
                    conn.Close();
                }
            }
            else
            {
                MessageBox.Show("Missing Values");
            }

            update();
        }
Exemplo n.º 4
0
        void update()
        {
            SqlConnection  con;
            SqlDataAdapter adapt;
            DataTable      dt;

            con = new SqlConnection(sQuery.ConnectString());
            con.Open();
            SqlConnection conn = new SqlConnection(sQuery.ConnectString());

            adapt = new SqlDataAdapter("select * from Inventory", con);
            dt    = new DataTable();
            adapt.Fill(dt);
            dataInventory.DataSource = dt;
            con.Close();
        }
Exemplo n.º 5
0
        private void btnSignup_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(sQuery.ConnectString());

            if (txtEmpCode.Text != "" && txtEmpFName.Text != "" && txtEmpLName.Text != "" && txtEmpAge.Text != "" && txtEmpContact.Text != "" && txtEmpUser.Text != "" && txtEmpPass.Text != "" && cboEmpRestriction.Text != "")
            {
                //insertData(Convert.ToInt32(txtEmpCode.Text), txtEmpLName.Text, txtEmpFName.Text, Convert.ToInt32(txtEmpAge.Text), Convert.ToInt32(txtEmpContact.Text), txtEmpUser.Text, txtEmpPass.Text, cboEmpRestriction.Text);
                conn.Open();
                sQuery.Command = "INSERT INTO Staff VALUES (" + txtEmpCode.Text + " , '" + txtEmpFName.Text + "' , '" + txtEmpLName.Text + "' , '" + txtEmpAge.Text + "' , " + txtEmpContact.Text + " , '" + txtEmpUser.Text + "' ,'" + txtEmpPass.Text + "' ,'" + cboEmpRestriction.Text + "')";
                SqlCommand SDA = new SqlCommand(sQuery.Command, conn);

                try
                {
                    SDA.ExecuteNonQuery();
                    MessageBox.Show("Signup Successfully!");
                    txtEmpCode.Text        = "";
                    txtEmpFName.Text       = "";
                    txtEmpLName.Text       = "";
                    txtEmpAge.Text         = "";
                    txtEmpContact.Text     = "";
                    txtEmpUser.Text        = "";
                    txtEmpPass.Text        = "";
                    cboEmpRestriction.Text = "";
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Code!");
                }
                finally
                {
                    conn.Close();
                }
            }
            else
            {
                MessageBox.Show("Missing Values");
            }
        }