Exemple #1
0
        private void bt3_Click(object sender, EventArgs e)
        {
            //   MessageBox.Show(lbltime.Text);
            conn.Open();
            CultureInfo ThaiCulture = new CultureInfo("th-TH");
            DateTime    date_app    = Convert.ToDateTime(dtp1.Text);

            string date = date_app.ToString("yyyy-MM-dd", ThaiCulture);
            string day  = date_app.ToString("dddd", ThaiCulture);
            double time = Convert.ToDouble(comboBox1.SelectedItem.ToString());

            if (time <= 12.00)
            {
                string query = ("select count(*) from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'เช้า' AND swd_day_work = '" + day + "'");
                cmd = new SqlCommand(query, conn);
                sda = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                sda.Fill(dt);
                int count_appswd = (int)cmd.ExecuteScalar();
                if (count_appswd == 1)
                {
                    // MessageBox.Show("เช้า" + day);
                    query = ("select schedule_work_doctor.swd_id,schedule_work_doctor.swd_timezone from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'เช้า' AND swd_day_work = '" + day + "'");
                    cmd   = new SqlCommand(query, conn);
                    //    conn.Open();
                    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());
                        string timezone = sdr["swd_timezone"].ToString();
                        query = ("select count(*) from appointment where app_time = '" + comboBox1.SelectedItem.ToString() + "' AND day = '" + day + "' AND swd_id = '" + swd_id + "'");
                        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)
                        {
                            //    MessageBox.Show("   " + swd_id + "    " + timezone + "   " + count_app + "    " + lbliddoc.Text);

                            query = ("Update appointment SET day = '" + day + "',app_date = '" + date + "' , app_time = '" + comboBox1.SelectedItem.ToString() + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                            cmd   = new SqlCommand(query, conn);
                            sda   = new SqlDataAdapter(cmd);
                            dt    = new DataTable();

                            sda.Fill(dt);

                            clinic_app_ms doc1 = new clinic_app_ms();
                            doc1.Show();
                            clinic_app_ms clnlog = new clinic_app_ms();
                            clnlog.Close();
                            Visible = false;
                            MessageBox.Show("นัดหมายเรียบร้อย");
                        }
                        else
                        {
                            MessageBox.Show(" มีคนไข้นัดอยู่แล้ว ");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("ตารางปฏิบัติงานว่าง");
                }
            }
            else if (time >= 12.01)
            {
                string query = ("select count(*) from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'บ่าย' AND swd_day_work = '" + day + "'");
                cmd = new SqlCommand(query, conn);
                sda = new SqlDataAdapter(cmd);
                dt  = new DataTable();
                sda.Fill(dt);
                int count_appswd = (int)cmd.ExecuteScalar();
                if (count_appswd == 1)
                {
                    // MessageBox.Show("เช้า" + day);
                    query = ("select schedule_work_doctor.swd_id,schedule_work_doctor.swd_timezone from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'บ่าย' AND swd_day_work = '" + day + "'");
                    cmd   = new SqlCommand(query, conn);
                    //    conn.Open();
                    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());
                        string timezone = sdr["swd_timezone"].ToString();
                        query = ("select count(*) from appointment where app_time = '" + comboBox1.SelectedItem.ToString() + "' AND day = '" + day + "' AND swd_id = '" + swd_id + "'");
                        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)
                        {
                            //    MessageBox.Show("   " + swd_id + "    " + timezone + "   " + count_app + "    " + lbliddoc.Text);

                            query = ("Update appointment SET day = '" + day + "',app_date = '" + dtp1.Text + "' , app_time = '" + comboBox1.SelectedItem.ToString() + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                            cmd   = new SqlCommand(query, conn);
                            sda   = new SqlDataAdapter(cmd);
                            dt    = new DataTable();

                            sda.Fill(dt);

                            clinic_app_ms doc1 = new clinic_app_ms();
                            doc1.Show();
                            clinic_app_ms clnlog = new clinic_app_ms();
                            clnlog.Close();
                            Visible = false;
                            MessageBox.Show("นัดหมายเรียบร้อย");
                        }
                        else
                        {
                            MessageBox.Show(" มีคนไข้นัดอยู่แล้ว ");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("ตารางปฏิบัติงานว่าง");
                }
            }



            /*
             *
             *    clinic_app_ms doc1 = new clinic_app_ms();
             * doc1.Show();
             * clinic_app_ms clnlog = new clinic_app_ms();
             * clnlog.Close();
             * Visible = false;
             * MessageBox.Show("นัดหมายเรียบร้อย");
             */
            conn.Close();
        }
Exemple #2
0
        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            clinic_app_ms ser = new clinic_app_ms();

            ser.Show();
        }
        private void manuappToolStripMenuItem_Click(object sender, EventArgs e)
        {
            clinic_app_ms cliapp = new clinic_app_ms();

            cliapp.Show();
        }
Exemple #4
0
        private void bt3_Click(object sender, EventArgs e)
        {
            //   MessageBox.Show(lbltime.Text);
            conn.Open();
            try
            {
                CultureInfo ThaiCulture = new CultureInfo("th-TH");
                DateTime    date_app    = Convert.ToDateTime(txtdate.Text);

                string   date           = date_app.ToString("yyyy-MM-dd");
                string   day            = date_app.ToString(txtday.Text);
                int      date_app_day   = date_app.Day;
                int      date_app_month = date_app.Month;
                DateTime today_th       = DateTime.Today;
                string   today          = today_th.ToString("yyyy-MM-dd", new CultureInfo("th-TH"));

                int    today_day   = today_th.Day;
                int    today_month = today_th.Month;
                double time        = Convert.ToDouble(txttime.Text);

                //   MessageBox.Show("day"   + day);

                if (time <= 12.00)
                {
                    string query = ("select Count(*) from appointment where app_time = '08.30'");
                    cmd = new SqlCommand(query, conn);
                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();
                    sda.Fill(dt);
                    int count_app_1 = (int)cmd.ExecuteScalar();
                    if (count_app_1 <= 9)
                    {
                        query = ("select count(*) from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'เช้า'  AND swd_date_work = '" + date + "' ");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();
                        sda.Fill(dt);
                        int count_appswd = (int)cmd.ExecuteScalar();
                        if (count_appswd == 1)
                        {
                            // MessageBox.Show("เช้า" + day);
                            query = ("select schedule_work_doctor.swd_id,schedule_work_doctor.swd_timezone from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'เช้า' AND swd_date_work = '" + date + "'");
                            cmd   = new SqlCommand(query, conn);
                            //    conn.Open();
                            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());
                                string timezone = sdr["swd_timezone"].ToString();
                                query = ("select count(*) from appointment where app_time = '" + txttime.Text + "' AND day = '" + day + "' AND swd_id = '" + swd_id + "'");
                                cmd   = new SqlCommand(query, conn);
                                sda   = new SqlDataAdapter(cmd);
                                dt    = new DataTable();
                                sda.Fill(dt);
                                int count_app = (int)cmd.ExecuteScalar();
                                if (count_app <= 9)
                                {
                                    //   MessageBox.Show("   " + swd_id + "    " + timezone + "   " + count_app + "    " + lbliddoc.Text);
                                    if (date_app_day > today_day)
                                    {
                                        /*       Queue<int> collection = new Queue<int>();
                                         *         query = ("select count(treatr_medi_queue) from treatment_record where treatr_status = 2");
                                         *         cmd = new SqlCommand(query, conn);
                                         *         sda = new SqlDataAdapter(cmd);
                                         *         dt = new DataTable();
                                         *         sda.Fill(dt);
                                         *
                                         *         int queue = (int)cmd.ExecuteScalar();
                                         *         int plus = queue + 1;
                                         *         collection.Enqueue(plus);
                                         *         foreach (int value in collection)
                                         *         {
                                         */
                                        /*      query = ("select  count(*) from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where treatment_record.treatr_status = 2 AND opd.opd_name = '"+lb33.Text+"'");
                                         *    cmd = new SqlCommand(query, conn);
                                         *    sda = new SqlDataAdapter(cmd);
                                         *    dt = new DataTable();
                                         *    sda.Fill(dt);
                                         *
                                         *    int sent_count = (int)cmd.ExecuteScalar();
                                         *    if (sent_count < 1)
                                         *    {*/
                                        query = ("Update appointment SET day = '" + day + "',app_date = '" + date + "' , app_time = '" + txttime.Text + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                                        cmd   = new SqlCommand(query, conn);
                                        sda   = new SqlDataAdapter(cmd);
                                        dt    = new DataTable();

                                        sda.Fill(dt);



                                        clinic_app_ms doc1 = new clinic_app_ms();
                                        doc1.Show();
                                        clinic_app_ms clnlog = new clinic_app_ms();
                                        clnlog.Close();
                                        Visible = false;
                                        MessageBox.Show("นัดหมายเรียบร้อย");
                                        //      }

                                        /*        else
                                         *      {
                                         *
                                         *          query = ("select treatment_record.treatr_id from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where treatment_record.treatr_status = 2 AND opd.opd_name = '" + lb33.Text + "'");
                                         *          cmd = new SqlCommand(query, conn);
                                         *          sda = new SqlDataAdapter(cmd);
                                         *          dt = new DataTable();
                                         *          sda.Fill(dt);
                                         *          sdr = cmd.ExecuteReader();
                                         *          if (sdr.Read())
                                         *          {
                                         *
                                         *
                                         *           int id = Convert.ToInt32(sdr["treatr_id"].ToString());
                                         *              query = ("Update treatment_record set treatment_record.treatr_medi_queue = '" + value + "' from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where opd.opd_name = '" + lb33.Text + "'");
                                         *              //
                                         *              cmd = new SqlCommand(query, conn);
                                         *              sda = new SqlDataAdapter(cmd);
                                         *              dt = new DataTable();
                                         *              sda.Fill(dt);
                                         *              query = ("Update appointment SET day = '" + day + "',app_date = '" + date + "' , app_time = '" + txttime.Text + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                                         *              cmd = new SqlCommand(query, conn);
                                         *              sda = new SqlDataAdapter(cmd);
                                         *              dt = new DataTable();
                                         *
                                         *              sda.Fill(dt);
                                         *
                                         *              query = ("UPDATE medicine_use SET medi_use_status = 2 where treatr_id = '" + id + "'");
                                         *              cmd = new SqlCommand(query, conn);
                                         *              sda = new SqlDataAdapter(cmd);
                                         *              dt = new DataTable();
                                         *              sda.Fill(dt);
                                         *
                                         *              clinic_app_ms doc1 = new clinic_app_ms();
                                         *              doc1.Show();
                                         *              clinic_app_ms clnlog = new clinic_app_ms();
                                         *              clnlog.Close();
                                         *              Visible = false;
                                         *              MessageBox.Show("นัดหมายเรียบร้อย ส่งคิวไปห้องจ่ายยาที่   " +value);
                                         *
                                         *          }
                                         *
                                         *
                                         *
                                         *
                                         *      }  */


                                        //}
                                    }
                                    else
                                    {
                                        MessageBox.Show("ไม่สามารถนัดได้");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(" มีข้อมูลการนัดหมายเต็มแล้ว");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("ตารางปฏิบัติงานว่าง");
                        }
                    }
                    else
                    {
                        MessageBox.Show(" มีข้อมูลการนัดหมายเต็มแล้ว");
                    }
                }
                else if (time >= 12.01)
                {
                    string query = ("select Count(*) from appointment where app_time = '13.00'");
                    cmd = new SqlCommand(query, conn);
                    sda = new SqlDataAdapter(cmd);
                    dt  = new DataTable();
                    sda.Fill(dt);
                    int count_app_1 = (int)cmd.ExecuteScalar();
                    if (count_app_1 <= 9)
                    {
                        query = ("select count(*) from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'บ่าย' AND swd_date_work = '" + date + "' ");
                        cmd   = new SqlCommand(query, conn);
                        sda   = new SqlDataAdapter(cmd);
                        dt    = new DataTable();
                        sda.Fill(dt);
                        int count_appswd = (int)cmd.ExecuteScalar();
                        if (count_appswd == 1)
                        {
                            // MessageBox.Show("เช้า" + day);
                            query = ("select schedule_work_doctor.swd_id,schedule_work_doctor.swd_timezone from schedule_work_doctor where emp_doc_id = '" + lbliddoc.Text + "' AND swd_timezone = 'บ่าย' AND swd_day_work = '" + day + "'");
                            cmd   = new SqlCommand(query, conn);
                            //    conn.Open();
                            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());
                                string timezone = sdr["swd_timezone"].ToString();
                                query = ("select count(*) from appointment where app_time = '" + txttime.Text + "' AND day = '" + day + "' AND swd_id = '" + swd_id + "'");
                                cmd   = new SqlCommand(query, conn);
                                sda   = new SqlDataAdapter(cmd);
                                dt    = new DataTable();
                                sda.Fill(dt);
                                int count_app = (int)cmd.ExecuteScalar();
                                if (count_app <= 9)
                                {
                                    //    MessageBox.Show("   " + swd_id + "    " + timezone + "   " + count_app + "    " + lbliddoc.Text);
                                    if (date_app_day > today_day)
                                    {
                                        /*     Queue<int> collection = new Queue<int>();
                                         *   query = ("select count(treatr_medi_queue) from treatment_record where treatr_status = 2");
                                         *   cmd = new SqlCommand(query, conn);
                                         *   sda = new SqlDataAdapter(cmd);
                                         *   dt = new DataTable();
                                         *   sda.Fill(dt);
                                         *
                                         *   int queue = (int)cmd.ExecuteScalar();
                                         *   int plus = queue + 1;
                                         *   collection.Enqueue(plus);
                                         *   foreach (int value in collection)
                                         *   {*/
                                        /*       query = ("select  count(*) from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where treatment_record.treatr_status = 2 AND opd.opd_name = '" + lb33.Text + "'");
                                         *     cmd = new SqlCommand(query, conn);
                                         *     sda = new SqlDataAdapter(cmd);
                                         *     dt = new DataTable();
                                         *     sda.Fill(dt);
                                         *
                                         *     int sent_count = (int)cmd.ExecuteScalar();
                                         *     if (sent_count < 1)
                                         *     {*/
                                        query = ("Update appointment SET day = '" + day + "',app_date = '" + date + "' , app_time = '" + txttime.Text + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                                        cmd   = new SqlCommand(query, conn);
                                        sda   = new SqlDataAdapter(cmd);
                                        dt    = new DataTable();

                                        sda.Fill(dt);



                                        clinic_app_ms doc1 = new clinic_app_ms();
                                        doc1.Show();
                                        clinic_app_ms clnlog = new clinic_app_ms();
                                        clnlog.Close();
                                        Visible = false;
                                        MessageBox.Show("นัดหมายเรียบร้อย");
                                        //    }

                                        /*     else
                                         *   {
                                         *
                                         *       query = ("select treatment_record.treatr_id from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where treatment_record.treatr_status = 2 AND opd.opd_name = '" + lb33.Text + "'");
                                         *       cmd = new SqlCommand(query, conn);
                                         *       sda = new SqlDataAdapter(cmd);
                                         *       dt = new DataTable();
                                         *       sda.Fill(dt);
                                         *       sdr = cmd.ExecuteReader();
                                         *       if (sdr.Read())
                                         *       {
                                         *
                                         *
                                         *           int id = Convert.ToInt32(sdr["treatr_id"].ToString());
                                         *           query = ("Update treatment_record set treatment_record.treatr_medi_queue = '" + value + "' from treatment_record inner join opd on opd.opd_id = treatment_record.opd_id where opd.opd_name = '" + lb33.Text + "'");
                                         *           //
                                         *           cmd = new SqlCommand(query, conn);
                                         *           sda = new SqlDataAdapter(cmd);
                                         *           dt = new DataTable();
                                         *           sda.Fill(dt);
                                         *           query = ("Update appointment SET day = '" + day + "',app_date = '" + date + "' , app_time = '" + txttime.Text + "',app_remark = '" + txtremark.Text + "',status_approve = 2,status_app = 1 , swd_id = '" + swd_id + "' where app_id = '" + lb11.Text + "' ");
                                         *           cmd = new SqlCommand(query, conn);
                                         *           sda = new SqlDataAdapter(cmd);
                                         *           dt = new DataTable();
                                         *
                                         *           sda.Fill(dt);
                                         *           query = ("UPDATE medicine_use SET medi_use_status = 2 where treatr_id = '" + id + "'");
                                         *           cmd = new SqlCommand(query, conn);
                                         *           sda = new SqlDataAdapter(cmd);
                                         *           dt = new DataTable();
                                         *           sda.Fill(dt);
                                         *
                                         *           clinic_app_ms doc1 = new clinic_app_ms();
                                         *           doc1.Show();
                                         *           clinic_app_ms clnlog = new clinic_app_ms();
                                         *           clnlog.Close();
                                         *           Visible = false;
                                         *           MessageBox.Show("นัดหมายเรียบร้อย ส่งคิวไปห้องจ่ายยาที่   " + value);
                                         *
                                         *       }
                                         *
                                         *
                                         *
                                         *
                                         *   }*/


                                        //   }
                                    }
                                    else
                                    {
                                        MessageBox.Show("ไม่สามารถนัดได้");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(" มีข้อมูลการนัดหมายเต็มแล้ว");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("ตารางปฏิบัติงานว่าง");
                        }
                    }
                    else
                    {
                        MessageBox.Show("ไม่สามารถนัดหมายได้");
                    }
                }
                else
                {
                    MessageBox.Show(" มีข้อมูลการนัดหมายเต็มแล้ว");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("ไม่มีข้อมูลการนัดหมาย");
            }



            /*
             *
             *    clinic_app_ms doc1 = new clinic_app_ms();
             * doc1.Show();
             * clinic_app_ms clnlog = new clinic_app_ms();
             * clnlog.Close();
             * Visible = false;
             * MessageBox.Show("นัดหมายเรียบร้อย");
             */
            conn.Close();
        }