public static appointment_swd show_app(string name) { string query = string.Format("select opd.opd_name from appointment inner join employee_doctor on employee_doctor.emp_doc_id = appointment.emp_doc_id inner join opd on appointment.opd_id = opd.opd_id where opd.opd_name LIKE '%{0}%' AND appointment.status_app = 1", name); // string query = string.Format("select schedule_work_doctor.emp_doc_id from schedule_work_doctor where swd_date_work = '{0}' AND schedule_work_doctor.swd_start_time LIKE '%{1}%'", app_date, time); try { conn.Open(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string name_1 = reader.GetString(0); appointment_swd app = new appointment_swd(name_1); return(app); } } finally { conn.Close(); } return(null); }
public static appointment_swd show_swd_app_doctor_id(string app_date, string time) { string query = string.Format("select schedule_work_doctor.emp_doc_id from schedule_work_doctor where swd_date_work = '{0}' AND swd_note = 'ทำงานแทน' AND schedule_work_doctor.swd_start_time LIKE '%{1}%'", app_date, time); // string query = string.Format("select schedule_work_doctor.emp_doc_id from schedule_work_doctor where swd_date_work = '{0}' AND schedule_work_doctor.swd_start_time LIKE '%{1}%'", app_date, time); try { conn.Open(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int employee_doctor_id = reader.GetInt32(0); appointment_swd app = new appointment_swd(employee_doctor_id); return(app); } } finally { conn.Close(); } return(null); }
public static string update_app_doctor_swd(appointment_swd app) { // string query = String.Format("select count(*) from schedule_work_doctor where emp_doc_id = '{0}' AND swd_timezone = '{1}' AND swd_day_work = '{2}' AND swd_date_work = '{3}'", app.emp_doc_id, app.swd_timezone, app.app_day,app.swd_date_work); try { // conn.Open(); // command.CommandText = query; //int count_swd = (int)command.ExecuteScalar(); // if (count_swd == 1) // { string query = String.Format("Update appointment set emp_doc_id = '{0}' , day = '{1}' , app_date = '{2}',app_time = '{3}',status_approve = 2,swd_id = '{4}' from appointment inner join opd On opd.opd_id = appointment.opd_id where appointment.app_remark = '{5}' AND opd.opd_name = '{6}'", app.emp_doc_id, app.app_day, app.app_date, app.app_time, app.swd_id, app.app_remark, app.opd_name); // conn.Open(); conn.Open(); command.CommandText = query; command.ExecuteNonQuery(); return("เลื่อนนัดหมายเรียบร้อยแล้ว"); // }else // { // return "แพทย์ไม่ได้มาปฏิบัติงาน"; // } } finally { conn.Close(); } }
protected void Button1_Click(object sender, EventArgs e) { try { string name = "" + Session["opd_name_app"]; string remark = "" + Session["remark_app"]; appointment app = appointment.show_app_next_opd(name); if (app != null) { DateTime date = app.date_app; string date_app = date.ToString("yyyy-MM-dd"); int emp_doc_id = app.emp_doc_id; string time = app.app_time; double time_app = Convert.ToDouble(time); appointment_swd app1 = appointment_swd.show_swd_app_doctor_id(date_app, time); if (app1 != null) { int id = app1.emp_doc_id; appointment_swd app3 = new appointment_swd(id, remark, name); appointment_swd.confirm_app(app3); Response.Redirect("../page/appointment_management_index.aspx"); } } } catch (Exception) { } /* appointment app = appointment.show_app_next_opd(name); * if (app != null) * { * DateTime date = app.date_app; * string date_app = date.ToString("yyyy-MM-dd"); * int emp_doc_id = app.emp_doc_id; * * string time = app.app_time; * double time_app = Convert.ToDouble(time); * * // ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('" + time_app + "');", true); * appointment_swd app1 = appointment_swd.show_swd_app_doctor_id(date_app, time); * if (app1 != null) * { * int id = app1.emp_doc_id; * * appointment_swd app3 = new appointment_swd(id, remark, name); * appointment_swd.confirm_app(app3); * Response.Redirect("../page/appointment.aspx"); * * // ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('" + id + "');", true); * } * * }*/ }
public static string confirm_app(appointment_swd app) { try { string query = String.Format("Update appointment set status_approve = 2 , status_app = 1 ,emp_doc_id = {0} from appointment inner join opd On opd.opd_id = appointment.opd_id where appointment.app_remark = '{1}' AND opd.opd_name = '{2}'", app.emp_doc_id, app.app_remark, app.opd_name); conn.Open(); command.CommandText = query; command.ExecuteNonQuery(); return(null); } finally { conn.Close(); } }