Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                conn.Open();


                string doc_id = textBox1.Text;
                string date   = textBox3.Text;
                string time   = textBox4.Text;
                if (doc_id == "" || date == "" || time == "")
                {
                    MessageBox.Show("การจัดตารางไม่สำเร็จ");
                }
                else
                {
                    string query = ("select count(*) from schedule_work_doctor where swd_date_work = '" + textBox3.Text + "' AND room_id = 2 AND room_id = 3 AND emp_doc_id = '" + textBox1.Text + "'");
                    cmd = new SqlCommand(query, conn);
                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();

                    sda.Fill(dt);

                    int swd_count1 = (int)cmd.ExecuteScalar();
                    if (swd_count1 < 1)
                    {
                        query = ("Update schedule_work_doctor set emp_doc_id = " + textBox1.Text + ",swd_status_room = 1  where swd_date_work = '" + textBox3.Text + "' and room_id = 1 AND swd_start_time = '" + textBox4.Text + "' ");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();

                        sda.Fill(dt);
                        clinic_ms_time_month doc1 = new clinic_ms_time_month();
                        doc1.Show();

                        clinic_ms_time_month clnlog = new clinic_ms_time_month();
                        clnlog.Close();
                        Visible = false;
                        MessageBox.Show("การจัดตารางเสร็จสิ้น");
                    }
                    else
                    {
                        MessageBox.Show("ไม่สามารถลงตารางปฏิบัติงานได้");
                    }
                }


                conn.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("ไม่มีข้อมูลการจัดตารางงาน");
            }
        }
Esempio n. 2
0
        /*    private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
         *  {
         *      if (comboBox2.SelectedItem.ToString() == "ปิด")
         *      {
         *     string query = ("Update schedule_work_doctor set swd_status_room = 0 ,emp_doc_id = 0 ,swd_work_place = '',swd_emp_work_place = '',swd_status = '" + comboBox2.SelectedItem.ToString() + "',swd_end_date = '',swd_note = ''  where swd_month_work = '"+lblmonth1.Text+"'");
         *          cmd = new SqlCommand(query, conn);
         *          sda = new SqlDataAdapter(cmd);
         *          dt = new DataTable();
         *
         *          sda.Fill(dt);
         *
         *          clinic_time_schms doc1 = new clinic_time_schms();
         *          doc1.Show();
         *          clinic_time_schms clnlog = new clinic_time_schms();
         *          clnlog.Close();
         *          Visible = false;
         *          MessageBox.Show("เปลี่ยนเป็นสถานะ  " + comboBox2.SelectedItem.ToString());
         *
         *
         *
         *      }
         *      else if (comboBox2.SelectedItem.ToString() == "เปิด")
         *      {
         *       string query = ("Update schedule_work_doctor set swd_status_room = 0 ,emp_doc_id = 0 ,swd_work_place = '',swd_emp_work_place = '',swd_status = '" + comboBox2.SelectedItem.ToString() + "',swd_end_date = '',swd_note = ''  where swd_month_work = '"+lblmonth1.Text+"'");
         *          cmd = new SqlCommand(query, conn);
         *          sda = new SqlDataAdapter(cmd);
         *          dt = new DataTable();
         *
         *          sda.Fill(dt);
         *
         *          clinic_time_schms doc1 = new clinic_time_schms();
         *          doc1.Show();
         *          clinic_time_schms clnlog = new clinic_time_schms();
         *          clnlog.Close();
         *          Visible = false;
         *          MessageBox.Show("เปลี่ยนเป็นสถานะ  " + comboBox2.SelectedItem.ToString());
         *
         *
         *      }
         *  }
         */
        private void button1_Click(object sender, EventArgs e)
        {
            string value = ((KeyValuePair <int, string>)comboBox1.SelectedItem).Value;

            int      month             = ((KeyValuePair <int, string>)comboBox1.SelectedItem).Key;
            DateTime month_today       = DateTime.Today;
            DateTime day_end           = Convert.ToDateTime(dateTimePicker1.Text);
            int      end_day           = day_end.Day;
            int      end_month         = day_end.Month;
            int      day_today         = month_today.Day;
            int      month_today_count = month_today.Month;
            int      month_year_count  = month_today.Year;
            int      year_end          = day_end.Year;

            /*
             * string query = ("Update schedule_work_doctor set swd_month_work = '" + value + "'");
             * cmd = new SqlCommand(query, conn);
             * sda = new SqlDataAdapter(cmd);
             * dt = new DataTable();
             *
             * sda.Fill(dt);*/
            if (day_today == 20)
            {
                try
                {
                    conn.Open();
                    //  query = ("Update schedule_work_doctor set swd_status = 'จัดตารางงานใหม่',swd_note = 'จัดตารางงานใหม่'");
                    string query = ("select count(schedule_work_doctor.emp_doc_id) from schedule_work_doctor inner join room on room.room_id = schedule_work_doctor.room_id where swd_status = 'เปิด' AND schedule_work_doctor.room_id = 1 AND swd_month_work = '" + lblmonth1.Text + "' AND emp_doc_id = 0 AND swd_date_work = '1900-01-01'");
                    cmd = new SqlCommand(query, conn);
                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();

                    sda.Fill(dt);

                    int swd_count = (int)cmd.ExecuteScalar();

                    query = ("select count(schedule_work_doctor.emp_doc_id) from schedule_work_doctor inner join room on room.room_id = schedule_work_doctor.room_id where swd_status = 'เปิด' AND schedule_work_doctor.room_id = 1 AND swd_month_work = '" + lblmonth1.Text + "' AND emp_doc_id = 0 ");
                    cmd   = new SqlCommand(query, conn);
                    sda   = new SqlDataAdapter(cmd);
                    dt    = new DataTable();

                    sda.Fill(dt);

                    int swd_count1 = (int)cmd.ExecuteScalar();

                    if (swd_count1 <= swd_count)
                    {
                        query = ("Update schedule_work_doctor set swd_status_chenge = 2 , swd_status = 'การจัดตารางงานเสร็จสิ้น' ");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();

                        sda.Fill(dt);
                        //       conn.Close();

                        //    MessageBox.Show("เปลี่ยนสถานะ ปิด" + day_work_ww4);

                        clinic_time_schms doc1 = new clinic_time_schms();
                        doc1.Show();

                        clinic_time_schms clnlog = new clinic_time_schms();
                        clnlog.Close();
                        Visible = false;
                        MessageBox.Show("จัดตารางปฏิบัติงานเสร็จสิ้น");
                    }
                    else
                    {
                        clinic_ms_time_month doc1 = new clinic_ms_time_month();
                        doc1.Show();
                    }

                    conn.Close();
                }
                catch (Exception)
                {
                }
            }
            else
            {
                MessageBox.Show("ยังไม่ถึงเวลาจัดตารางปฏิบัติงาน", "status");
            }
        }