예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();
            string query = ("select * from employee_doctor where emp_doc_name = '" + txtname1.Text + "'");

            cmd = new SqlCommand(query, conn);

            sda = new SqlDataAdapter(cmd);
            dt  = new DataTable();
            sda.Fill(dt);
            sdr = cmd.ExecuteReader();
            if (sdr.Read())
            {
                CultureInfo ThaiCulture = new CultureInfo("th-TH");
                int         doc_id      = Convert.ToInt32(sdr["emp_doc_id"].ToString());
                // MessageBox.Show("" + doc_id);
                DateTime date_swd = Convert.ToDateTime(dateTimePicker1.Text);
                string   date     = date_swd.ToString("yyyy-MM-dd", ThaiCulture);

                query = ("Update schedule_work_doctor set swd_note = '',swd_status_room = 1,swd_work_place = '" + date + "',swd_emp_work_place = '" + txtname1.Text + "',emp_doc_id = '" + doc_id + "' where swd_id = '" + txtswdwork1.Text + "'");
                cmd   = new SqlCommand(query, conn);
                sda   = new SqlDataAdapter(cmd);
                dt    = new DataTable();
                sda.Fill(dt);
                query = ("select swd_id from schedule_work_doctor where swd_status_room = 1 AND swd_emp_work_place = '" + txtname1.Text + "' AND swd_id = '" + txtswdwork1.Text + "'");
                cmd   = new SqlCommand(query, conn);

                sda = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                sda.Fill(dt);
                sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    int swd_id = Convert.ToInt32(sdr["swd_id"].ToString());
                    //  query = ("update appointment SET status_approve = 3 ,swd_id = '" + swd_id + "' inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '"+ txtname1.Text + "'");
                    query = ("update appointment SET appointment.status_approve = 3,appointment.swd_id = '" + swd_id + "' from appointment inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '" + txtname1.Text + "'");
                    cmd   = new SqlCommand(query, conn);
                    sda   = new SqlDataAdapter(cmd);
                    dt    = new DataTable();
                    sda.Fill(dt);

                    MessageBox.Show("อนุมัติการเลื่อนปฏิบัติงานเรียบร้อย");
                    clinic_schedule m3 = new clinic_schedule();
                    m3.Show();
                    clinic_schedule clnlog = new clinic_schedule();
                    clnlog.Close();
                    Visible = false;
                }
            }



            conn.Close();
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            conn.Open();
            string query = ("select * from employee_doctor where emp_doc_name = '" + comboBox1.SelectedItem.ToString() + "'");

            cmd = new SqlCommand(query, conn);

            sda = new SqlDataAdapter(cmd);
            dt  = new DataTable();
            sda.Fill(dt);
            sdr = cmd.ExecuteReader();
            if (sdr.Read())
            {
                CultureInfo ThaiCulture = new CultureInfo("th-TH");
                int         doc_id      = Convert.ToInt32(sdr["emp_doc_id"].ToString());
                DateTime    date_swd    = Convert.ToDateTime(dateTimePicker1.Text);
                string      date        = date_swd.ToString("yyyy-MM-dd", ThaiCulture);

                query = ("Update schedule_work_doctor set swd_note = 'รอการอนุมัติทำงานแทน',swd_work_place = '" + date + "',swd_status_room = 4, swd_emp_work_place = '" + comboBox1.SelectedItem.ToString() + "',emp_doc_id ='" + doc_id + "' where swd_id = '" + txtswd.Text + "'");
                cmd   = new SqlCommand(query, conn);
                sda   = new SqlDataAdapter(cmd);
                dt    = new DataTable();
                sda.Fill(dt);


                clinic_schedule m3 = new clinic_schedule();
                m3.Show();
                clinic_schedule clnlog = new clinic_schedule();
                clnlog.Close();
                Visible = false;
            }



            conn.Close();
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            conn.Open();
            try
            {
                string query = ("select * from employee_doctor where emp_doc_name = '" + comboBox1.SelectedItem.ToString() + "'");
                cmd = new SqlCommand(query, conn);

                sda = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                sda.Fill(dt);
                sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    CultureInfo ThaiCulture = new CultureInfo("th-TH");
                    int         doc_id      = Convert.ToInt32(sdr["emp_doc_id"].ToString());

                    string doc_name = sdr["emp_doc_name"].ToString();
                    query = ("select schedule_work_doctor.room_id from schedule_work_doctor inner join employee_doctor on employee_doctor.emp_doc_id = schedule_work_doctor.emp_doc_id inner join specialist on specialist.emp_doc_specialistid = employee_doctor.emp_doc_specialistid where schedule_work_doctor.swd_date_work = '" + txttime.Text + "' AND schedule_work_doctor.emp_doc_id = '" + doc_id + "'");
                    cmd   = new SqlCommand(query, conn);

                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();
                    sda.Fill(dt);
                    sdr = cmd.ExecuteReader();
                    if (sdr.Read())
                    {
                        int room_id  = Convert.ToInt32(sdr["room_id"].ToString());
                        int room_swd = Convert.ToInt32(txtroom.Text);
                        if (room_id == room_swd)
                        {
                            if (doc_name == txtdoctorname.Text)
                            {
                                MessageBox.Show("ไม่สามารถส่งคำขอทำงานแทนได้");
                            }
                            else
                            {
                                query = ("Update schedule_work_doctor set swd_note = 'รอการอนุมัติทำงานแทน',swd_status_room = 4, swd_emp_work_place = '" + txtdoctorname.Text + "',emp_doc_id ='" + doc_id + "' where swd_id = '" + txtswd.Text + "'");
                                cmd   = new SqlCommand(query, conn);
                                sda   = new SqlDataAdapter(cmd);
                                dt    = new DataTable();
                                sda.Fill(dt);


                                clinic_schedule m3 = new clinic_schedule();
                                m3.Show();
                                clinic_schedule clnlog = new clinic_schedule();
                                clnlog.Close();
                                Visible = false;
                            }
                        }
                        else
                        {
                            MessageBox.Show("แพทย์มีข้อมูลการทำงานแล้ว");
                        }
                    }
                    else
                    {
                        query = ("Update schedule_work_doctor set swd_note = 'รอการอนุมัติทำงานแทน',swd_status_room = 4, swd_emp_work_place = '" + txtdoctorname.Text + "',emp_doc_id ='" + doc_id + "' where swd_id = '" + txtswd.Text + "'");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();
                        sda.Fill(dt);


                        clinic_schedule m3 = new clinic_schedule();
                        m3.Show();
                        clinic_schedule clnlog = new clinic_schedule();
                        clnlog.Close();
                        Visible = false;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("กรุณาเลือกข้อมูลแพทย์ที่ทำงานแทน");
            }



            conn.Close();
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();

            /*   if (label12.Text == "" && comboBox2.SelectedItem.ToString() == "" && txtswdwork1.Text == null || txtname1.Text == null || txtday1.Text == null || txtdateswd.Text == null || txttime1.Text == null)
             * {
             *
             *
             *     MessageBox.Show("ไม่มีข้อมูลการแลกเวรปฏิบัติงาน");
             *
             * }
             * else
             * {*/
            try
            {
                string query = ("select count(schedule_work_doctor.swd_emp_work_place) from schedule_work_doctor inner join employee_doctor on employee_doctor.emp_doc_id = schedule_work_doctor.emp_doc_id inner join specialist on specialist.emp_doc_specialistid = employee_doctor.emp_doc_specialistid where schedule_work_doctor.swd_status_room = 4 AND schedule_work_doctor.swd_emp_work_place = '" + txtname1.Text + "'");
                cmd = new SqlCommand(query, conn);
                sda = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                sda.Fill(dt);
                int count = (int)cmd.ExecuteScalar();
                if (count < 1)
                {
                    query = ("select * from employee_doctor where emp_doc_name = '" + txtname1.Text + "'");
                    cmd   = new SqlCommand(query, conn);

                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();
                    sda.Fill(dt);
                    sdr = cmd.ExecuteReader();
                    if (sdr.Read())
                    {
                        CultureInfo ThaiCulture = new CultureInfo("th-TH");
                        int         doc_id      = Convert.ToInt32(sdr["emp_doc_id"].ToString());
                        // MessageBox.Show("" + doc_id);


                        query = ("Update schedule_work_doctor set swd_note = 'เลื่อนปฏิบัติงาน',swd_status_room = 1,swd_emp_work_place = '" + txtname1.Text + "',emp_doc_id = '" + doc_id + "' where swd_id = '" + txtswdwork1.Text + "'");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();
                        sda.Fill(dt);
                        query = ("select swd_id,swd_date_work from schedule_work_doctor inner join employee_doctor on employee_doctor.emp_doc_id = schedule_work_doctor.emp_doc_id where swd_note = 'ทำงานแทน' AND schedule_work_doctor.swd_emp_work_place = '" + txtname1.Text + "'");
                        cmd   = new SqlCommand(query, conn);

                        sda = new SqlDataAdapter(cmd);
                        dt  = new DataTable();
                        sda.Fill(dt);
                        sdr = cmd.ExecuteReader();
                        while (sdr.Read())
                        {
                            /*          int swd_id = Convert.ToInt32(sdr["swd_id"].ToString());
                             *     DateTime date_sed = Convert.ToDateTime(sdr["swd_date_work"].ToString());
                             *        string date_swd = date_sed.ToString("yyyy-MM-dd");*/
                            int swd_id = sdr.GetInt32(0);

                            DateTime date_sed = sdr.GetDateTime(1);
                            string   date_swd = date_sed.ToString("yyyy-MM-dd");
                            query = ("select count(appointment.app_date) from appointment  inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where app_date = '" + date_swd + "' AND employee_doctor.emp_doc_name = '" + txtname1.Text + "'");
                            cmd   = new SqlCommand(query, conn);
                            sda   = new SqlDataAdapter(cmd);
                            dt    = new DataTable();
                            sda.Fill(dt);
                            int count_app = (int)cmd.ExecuteScalar();
                            if (count_app >= 1)
                            {
                                query = ("update appointment SET appointment.status_approve = 3,appointment.swd_id = '" + swd_id + "' from appointment inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '" + txtname1.Text + "' AND appointment.app_date = '" + date_swd + "'");
                                cmd   = new SqlCommand(query, conn);
                                sda   = new SqlDataAdapter(cmd);
                                dt    = new DataTable();
                                sda.Fill(dt);

                                //    MessageBox.Show("เลื่อน");
                            }
                            //  query = ("update appointment SET status_approve = 3 ,swd_id = '" + swd_id + "' inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '"+ txtname1.Text + "'");
                        }



                        MessageBox.Show("อนุมัติการเลื่อนปฏิบัติงานเรียบร้อย");
                        clinic_schedule m3 = new clinic_schedule();
                        m3.Show();
                        clinic_schedule clnlog = new clinic_schedule();
                        clnlog.Close();
                        Visible = false;
                    }
                }
                else
                {
                    MessageBox.Show("ยังไม่มีการอนุมัติการแลกตารางปฏิบัติงาน");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("ยังไม่มีข้อมูลการอนุมัติการปฏิบัติงาน");
            }


            /*
             *
             */

            conn.Close();

            /*
             * conn.Open();
             * try
             * {
             *
             *  string name = label12.Text;
             *  if (label12.Text == "อนุมัตเรียบร้อยแล้ว" && comboBox2.SelectedItem.ToString() == "" && txtswdwork1.Text == null && txtname1.Text == null && txtday1.Text == null && txtdateswd.Text == null && txttime1.Text == null)
             *  {
             *
             *      MessageBox.Show("กรุณาเลือกแพทย์");
             *
             *  }
             *  else
             *  {
             *
             *
             *
             *      string query = ("select count(*) from schedule_work_doctor inner join employee_doctor on employee_doctor.emp_doc_id = schedule_work_doctor.emp_doc_id inner join specialist on specialist.emp_doc_specialistid = employee_doctor.emp_doc_specialistid where schedule_work_doctor.swd_status_room = 4 AND emp_doc_name = '" + name + "' Group by employee_doctor.emp_doc_name");
             *      cmd = new SqlCommand(query, conn);
             *      sda = new SqlDataAdapter(cmd);
             *      dt = new DataTable();
             *      sda.Fill(dt);
             *      int count = (int)cmd.ExecuteScalar();
             *      if (count < 1)
             *      {
             *
             *
             *          query = ("select * from employee_doctor where emp_doc_name = '" + txtname1.Text + "'");
             *          cmd = new SqlCommand(query, conn);
             *
             *          sda = new SqlDataAdapter(cmd);
             *          dt = new DataTable();
             *          sda.Fill(dt);
             *          sdr = cmd.ExecuteReader();
             *          if (sdr.Read())
             *          {
             *              CultureInfo ThaiCulture = new CultureInfo("th-TH");
             *              int doc_id = Convert.ToInt32(sdr["emp_doc_id"].ToString());
             *              // MessageBox.Show("" + doc_id);
             *
             *
             *              query = ("Update schedule_work_doctor set swd_note = '',swd_status_room = 1,swd_emp_work_place = '" + txtname1.Text + "',emp_doc_id = '" + doc_id + "' where swd_id = '" + txtswdwork1.Text + "'");
             *              cmd = new SqlCommand(query, conn);
             *              sda = new SqlDataAdapter(cmd);
             *              dt = new DataTable();
             *              sda.Fill(dt);
             *              query = ("select swd_id from schedule_work_doctor where swd_status_room = 1  AND swd_id = '" + txtswdwork1.Text + "'");
             *              cmd = new SqlCommand(query, conn);
             *
             *              sda = new SqlDataAdapter(cmd);
             *              dt = new DataTable();
             *              sda.Fill(dt);
             *              sdr = cmd.ExecuteReader();
             *              if (sdr.Read())
             *              {
             *                  int swd_id = Convert.ToInt32(sdr["swd_id"].ToString());
             *                  //  query = ("update appointment SET status_approve = 3 ,swd_id = '" + swd_id + "' inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '"+ txtname1.Text + "'");
             *                  query = ("update appointment SET appointment.status_approve = 3,appointment.swd_id = '" + swd_id + "' from appointment inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id where employee_doctor.emp_doc_name = '" + txtname1.Text + "'");
             *                  cmd = new SqlCommand(query, conn);
             *                  sda = new SqlDataAdapter(cmd);
             *                  dt = new DataTable();
             *                  sda.Fill(dt);
             *
             *                  MessageBox.Show("อนุมัติการเลื่อนปฏิบัติงานเรียบร้อย");
             *                  clinic_schedule m3 = new clinic_schedule();
             *                  m3.Show();
             *                  clinic_schedule clnlog = new clinic_schedule();
             *                  clnlog.Close();
             *                  Visible = false;
             *
             *
             *              }
             *
             *
             *
             *
             *
             *
             *
             *          }
             *
             *
             *
             *
             *
             *
             *
             *
             *      }
             *      else
             *      {
             *          MessageBox.Show("ยังไม่มีการอนุมัติการแลกตารางปฏิบัติงาน");
             *      }
             *
             *
             *
             *
             *
             *
             *
             *
             *
             *
             *
             *  }
             *
             *
             *
             *
             * }
             * catch (Exception)
             * {
             *  MessageBox.Show("มีข้อผิดพลาด");
             * }
             *
             *
             *
             *
             *
             * conn.Close();
             */
        }
        private void docinputToolStripMenuItem_Click(object sender, EventArgs e)
        {
            clinic_schedule sc = new clinic_schedule();

            sc.Show();
        }