コード例 #1
0
        private void updateSlots()
        {
            command             = conn.CreateCommand();
            command.CommandText = "SELECT reservation_visit_slot FROM reservation WHERE reservation_visit_date=@date ";
            command.Parameters.AddWithValue("@date", dateTimePicker1.Value.ToString("yyyy-MM-dd"));

            conn.Open();

            SqlDataReader            reader = command.ExecuteReader();
            Dictionary <int, string> slots  = Utilis.getSlots();

            while (reader.Read())
            {
                slots.Remove(reader.GetInt32(0));
            }

            comboBox1.Items.Clear();
            foreach (object slot in slots.ToArray())
            {
                comboBox1.Items.Add(slot);
            }

            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }

            conn.Close();
        }
コード例 #2
0
        private void updateCombo(int visit_slot)
        {
            Dictionary <int, string> slots = Utilis.getSlots();

            command             = conn.CreateCommand();
            command.CommandText = "SELECT reservation_visit_slot FROM reservation WHERE reservation_visit_date = @date AND reservation_id <> @id";
            command.Parameters.AddWithValue("@date", dateTimePicker1.Value.ToString("yyyy-MM-dd"));
            command.Parameters.AddWithValue("@id", txtReservationID.Text);
            conn.Open();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                slots.Remove(reader.GetInt32(0));;
            }

            comboBox1.Items.Clear();

            foreach (KeyValuePair <int, string> slot in slots)
            {
                comboBox1.Items.Add(slot);
                if (slot.Key == visit_slot)
                {
                    comboBox1.SelectedItem = slot;
                }
            }

            conn.Close();
        }
コード例 #3
0
        private void updateForm()
        {
            if (listBox1.SelectedIndex < 0 || listBox1.SelectedIndex >= listBox1.Items.Count)
            {
                MessageBox.Show("Please, select a reservation");
                return;
            }

            reservation res = (reservation)listBox1.SelectedItem;

            txtReservationID.Text = res.id.ToString();
            txtPatient.Text       = res.patient.ToString();
            txtNurse.Text         = res.nurse.ToString();
            txtVisitDate.Text     = res.visit_date.Date.ToString();
            txtVisitSlot.Text     = Utilis.getSlots()[res.slot];
            txtDate.Text          = res.date.ToString();

            if (account_type == 0 && res.visit_date >= DateTime.Today)
            {
                btnEdit.Enabled = true;
            }
            else
            {
                btnEdit.Enabled = false;
            }

            //enabling button if account is doctor
            if (account_type == 1)
            {
                btnVisits.Enabled = true;
            }
            else
            {
                btnVisits.Enabled = false;
            }
        }
コード例 #4
0
ファイル: AdminPanel.cs プロジェクト: gf-solutions/WonderCMS
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                try
                {
                    //sql connection
                    SqlConnection conn    = new SqlConnection(connString);
                    SqlCommand    command = conn.CreateCommand();
                    command.CommandText = "INSERT INTO [user] (username, password) VALUES (@username, @password) ";
                    command.Parameters.AddWithValue("@username", txtUsername.Text);
                    command.Parameters.AddWithValue("@password", Utilis.hashPassword(txtPassword.Text));

                    conn.Open();

                    if (command.ExecuteNonQuery() > 0)
                    {
                        // we created the user record
                        command.CommandText = "SELECT user_id FROM [user] WHERE username = @username ";

                        int user_id = (int)command.ExecuteScalar();

                        command.CommandText = "INSERT INTO user_account (account_user_id, account_name,account_gender, account_dob, " +
                                              " account_phone,   account_type, account_notes, account_creation_date  )" +
                                              "VALUES (@user_id, @name,@account_gender, @dob, @phone, @type, @notes, @date)";

                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@user_id", user_id);
                        command.Parameters.AddWithValue("@name", txtName.Text);
                        command.Parameters.AddWithValue("@account_gender", cmbGender.SelectedItem.ToString());
                        command.Parameters.AddWithValue("@dob", dtpDOB.Value.ToString());
                        command.Parameters.AddWithValue("@phone", txtPhone.Text);
                        command.Parameters.AddWithValue("@type", cmbType.SelectedIndex);
                        command.Parameters.AddWithValue("@notes", rchNotes.Text);
                        command.Parameters.AddWithValue("@date", DateTime.Now);

                        if (command.ExecuteNonQuery() > 0)
                        {
                            //All good, account created
                            MessageBox.Show("Account was successfully created");

                            txtUsername.Clear();
                            txtPassword.Clear();
                            txtName.Clear();
                            txtPhone.Clear();
                            rchNotes.Clear();
                            //cmbType.Items.Clear();
                        }
                        else
                        {
                            MessageBox.Show("Error while creating account");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error while creating account");
                    }

                    conn.Close();

                    updateList("");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #5
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                using (conn = new SqlConnection(connString))
                {
                    try
                    {
                        ////dataAdapter = new SqlDataAdapter(@"SELECT account_role, account_id FROM [user_account] JOIN [user]
                        ////                                    ON [user_account].user_id = [user].user_id
                        ////                                 WHERE username='******' and password='******' ", conn);

                        SqlCommand command = conn.CreateCommand();
                        //command.CommandText = @"SELECT account_type, account_id FROM [user_account] JOIN [user]
                        //                                    ON [user_account].account_user_id = [user].user_id
                        //                                 WHERE username=@username and password=@password";

                        command.CommandText = @"SELECT user_id FROM [user] WHERE username=@username and password=@password";

                        command.Parameters.AddWithValue("@username", txtUsername.Text);
                        command.Parameters.AddWithValue("@password", Utilis.hashPassword(txtPassword.Text));
                        //command.Parameters.AddWithValue("@password", txtPassword.Text);

                        //table = new System.Data.DataTable();
                        //dataAdapter.Fill(table);

                        conn.Open();
                        var result = command.ExecuteScalar();
                        conn.Close();



                        if (result != null)
                        {
                            //Authenticate

                            if (txtUsername.Text == "admin")
                            {
                                //Admin Panel
                                Hide();
                                AdminPanel adminPanel = new AdminPanel();
                                adminPanel.ShowDialog();
                                Show();
                            }
                            else
                            {
                                conn.Open();
                                command.CommandText = "Select account_id, account_type From user_account Where account_user_id = @user_id ";
                                command.Parameters.AddWithValue("@user_id", result.ToString());
                                SqlDataReader reader = command.ExecuteReader();


                                if (reader.Read())
                                {
                                    int account_id   = reader.GetInt32(0);
                                    int account_type = reader.GetInt32(1);


                                    conn.Close();

                                    if (account_type == 0)
                                    {
                                        //Nurse Panel
                                        Hide();
                                        NursePanel nursePanel = new NursePanel(account_id);
                                        nursePanel.ShowDialog();
                                        Show();
                                        Clear();
                                    }
                                    else if (account_type == 1)
                                    {
                                        //Doctor Panel
                                        Hide();

                                        DoctorPanel doctorPanel = new DoctorPanel(account_id);
                                        doctorPanel.ShowDialog();
                                        Show();
                                        Clear();
                                    }
                                }
                            }
                        }
                        else
                        {
                            //Authentication failure
                            MessageBox.Show("Invalid Username and Password");
                            Clear();
                            txtUsername.Focus();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
コード例 #6
0
 private void Login_Load(object sender, EventArgs e)
 {
     Utilis.createAdmin("12345");
 }
コード例 #7
0
 public override string ToString()
 {
     return(base.ToString() + ":" + patient.Value + ":" + visit_date.Date.ToString() + "=>" + Utilis.getSlots()[slot]);
 }