private void submitBed_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                p.textboxWard.Text    = this.comboboxChooseWard.SelectedItem.ToString();
                p.textboxBed.Text     = this.comboboxChooseBed.SelectedItem.ToString();
                p.textboxBedType.Text = this.check();

                string          Query      = "update bed set pat_contact_no='" + contact + "',bed_status='" + "Occupied" + "' where bed_no='" + comboboxChooseBed.SelectedItem.ToString() + "';";
                MySqlCommand    MyCommand4 = new MySqlCommand(Query, conn);
                MySqlDataReader MyReader4;
                MyReader4 = MyCommand4.ExecuteReader();
                while (MyReader4.Read())
                {
                    name = MyReader4.GetString(0);
                    comboboxChooseBed.Items.Add(name);
                }
                MyReader4.Close();
                this.Close();
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message.ToString());
            }
        }
 private void comboboxChooseWard_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     comboboxChooseBed.Items.Clear();
     try
     {
         string          text       = comboboxChooseWard.SelectedItem.ToString();
         string          Query      = "select bed_no from ward_bed where ward_name='" + text + "' and bed_status='" + "Free" + "' and bed_type='" + check().ToString() + "';";
         MySqlCommand    MyCommand4 = new MySqlCommand(Query, conn);
         MySqlDataReader MyReader4;
         MyReader4 = MyCommand4.ExecuteReader();
         while (MyReader4.Read())
         {
             name = MyReader4.GetString(0);
             comboboxChooseBed.Items.Add(name);
         }
         MyReader4.Close();
     }
     catch
     { }
     this.comboboxChooseBed.IsEnabled = true;
     radiobtnNormal.IsEnabled         = false;
     radiobtnVIP.IsEnabled            = false;
 }
Esempio n. 3
0
        private void send_btn_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(Connec);
                connection.Open();

                string          query   = @"SELECT user_id FROM  internal_communication_4.users 
                               WHERE user_name = " + login_form.user_name + " ";
                MySqlCommand    command = new MySqlCommand(query, connection);
                MySqlDataReader MyReader2;
                MyReader2 = command.ExecuteReader();
                while (MyReader2.Read())
                {
                    user_id_messages = Convert.ToInt32(MyReader2.GetString(0));
                }

                connection.Close();


                MySqlConnection connection3 = new MySqlConnection(Connec);
                connection3.Open();

                string          query3   = @"SELECT Project_project_id FROM  internal_communication_4.subjects 
                               WHERE subject_id = " + subj_id_lbl.Text + " ";
                MySqlCommand    command3 = new MySqlCommand(query3, connection3);
                MySqlDataReader MyReader4;
                MyReader4 = command3.ExecuteReader();
                while (MyReader4.Read())
                {
                    project_id = Convert.ToInt32(MyReader4.GetString(0));
                }

                connection3.Close();
            }

            catch
            {
                MessageBox.Show("error in data integrity");
            }

            try
            {
                Message_class mes = new Message_class();
                mes.Message_content = input_txtbx.Text;
                mes.Subject_id      = Convert.ToInt32(subj_id_lbl.Text);
                mes.User_id         = user_id_messages;
                mes.Project_id      = project_id;
                mes.Message_posting = DateTime.Now;

                MySqlConnection connection2 = new MySqlConnection(Connec);
                connection2.Open();

                MySqlCommand command2 = connection2.CreateCommand();
                command2.CommandText = @"INSERT INTO internal_communication_4.messages
                                                (user_user_id,subjects_subject_id,subjects_Project_project_id,message_content, message_posting) 
                                     VALUES( @user_user_id,  @subjects_subject_id, @subjects_Project_project_id, @message_content, @message_posting)";
                command2.Parameters.AddWithValue("@user_user_id", mes.User_id);
                command2.Parameters.AddWithValue("@subjects_subject_id", mes.Subject_id);
                command2.Parameters.AddWithValue("@subjects_Project_project_id", mes.Project_id);
                command2.Parameters.AddWithValue("@message_content", mes.Message_content);
                command2.Parameters.AddWithValue("@message_posting", mes.Message_posting);
                command2.ExecuteNonQuery();

                connection2.Close();

                message_lstbx.Items.Add(mes.Showmessage());
            }

            catch
            {
                MessageBox.Show("could not add message");
            }
        }