public void loginUser(String username, String password) { ConnectDatabase connectBase = new ConnectDatabase(); SqlCommand selectUser = new SqlCommand(); selectUser.CommandText = "Select p.Patient_id, p.Firstname, p.Lastname, p.Nickname, p.Birth, p.Gender, p.Address, p.Email, p.Tel, p.Id_card," + "p.ChronicD, p.Bloodtype, p.Rh, p.Allergydrug, p.Cousin, p.Cousintell, p.username, p.password From PATIENT p " + "Where username = @TextBoxUN and password = @TextBoxPW"; selectUser.Parameters.AddWithValue("@TextBoxUN", username); selectUser.Parameters.AddWithValue("@TextBoxPW", password); selectUser.Connection = connectBase.getConnectDatabase(); connectBase.OpenDatabase(); SqlDataReader dataUser = selectUser.ExecuteReader(); Model_Login modelLogin = new Model_Login(); if (dataUser.HasRows) { modelLogin.return_code = Return.RETURN_CODE_SUCCESS; modelLogin.return_description = Return.RETURN_DESCRIPTION_SUCCESS; modelLogin.user_profile = new Model_User(); while (dataUser.Read()) { modelLogin.user_profile.Patient_id = Int32.Parse(dataUser[0].ToString()); modelLogin.user_profile.Firstname = (dataUser[1].ToString()); modelLogin.user_profile.Lastname = (dataUser[2].ToString()); modelLogin.user_profile.Nickname = (dataUser[3].ToString()); modelLogin.user_profile.Birth = (dataUser[4].ToString()); modelLogin.user_profile.Gender = (dataUser[5].ToString()); modelLogin.user_profile.Address = (dataUser[6].ToString()); modelLogin.user_profile.Email = (dataUser[7].ToString()); modelLogin.user_profile.Tel = (dataUser[8].ToString()); modelLogin.user_profile.Id_card = Int64.Parse(dataUser[9].ToString()); modelLogin.user_profile.ChronicD = (dataUser[10].ToString()); modelLogin.user_profile.Bloodtype = (dataUser[11].ToString()); modelLogin.user_profile.Rh = (dataUser[12].ToString()); modelLogin.user_profile.Allergydrug = (dataUser[13].ToString()); modelLogin.user_profile.Cousin = (dataUser[14].ToString()); modelLogin.user_profile.Cousintell = (dataUser[15].ToString()); modelLogin.user_profile.username = (dataUser[16].ToString()); modelLogin.user_profile.password = (dataUser[17].ToString()); } dataUser.Close(); } else { modelLogin.return_code = Return.RETURN_CODE_ERROR; modelLogin.return_description = Return.RETURN_DESCRIPTION_ERROR; } connectBase.CloseDatabase(); Context.Response.Write(JsonConvert.SerializeObject(modelLogin)); Context.Response.End(); }
public void Treatment(String patient_id) { ConnectDatabase connectBase = new ConnectDatabase(); SqlCommand selectTreat = new SqlCommand(); selectTreat.CommandText = "Select t.Treat_id, p.Patient_id, p.Firstname , t.Treatdate,t.Weight, t.Height, t.Pulse, t.Respiratory_rate, t.Bloodpressure, t.Condition, t.Treatdetail From PATIENT p , TREATMENT t Where p.Patient_id = t.Patient_id AND p.Patient_id = @TextBoxid"; selectTreat.Parameters.AddWithValue("@TextBoxid", patient_id); selectTreat.Connection = connectBase.getConnectDatabase(); connectBase.OpenDatabase(); SqlDataReader dataUser = selectTreat.ExecuteReader(); Model_Treatlist ModelTreatlist = new Model_Treatlist(); if (dataUser.HasRows) { ModelTreatlist.return_code = Return.RETURN_CODE_SUCCESS; ModelTreatlist.return_description = Return.RETURN_DESCRIPTION_SUCCESS; while (dataUser.Read()) { Model_Treat model_Treat = new Model_Treat(); model_Treat.Treat_id = Int32.Parse(dataUser[0].ToString()); model_Treat.Patient_id = Int32.Parse(dataUser[1].ToString()); model_Treat.Firstname = (dataUser[2].ToString()); model_Treat.Treatdate = (dataUser[3].ToString()); model_Treat.Weight = Double.Parse(dataUser[4].ToString()); model_Treat.height = Double.Parse(dataUser[5].ToString()); model_Treat.Pulse = Int32.Parse(dataUser[6].ToString()); model_Treat.Respiratory = Int32.Parse(dataUser[7].ToString()); model_Treat.Bloodpressure = (dataUser[8].ToString()); model_Treat.Condition = (dataUser[9].ToString()); model_Treat.Treatdetail = (dataUser[10].ToString()); ModelTreatlist.treatlist.Add(model_Treat); } dataUser.Close(); } else { ModelTreatlist.return_code = Return.RETURN_CODE_ERROR; ModelTreatlist.return_description = Return.RETURN_DESCRIPTION_ERROR; } connectBase.CloseDatabase(); Context.Response.Write(JsonConvert.SerializeObject(ModelTreatlist)); Context.Response.End(); }
public void appointment(String patient_id) { ConnectDatabase connectBase = new ConnectDatabase(); SqlCommand selectAppoint = new SqlCommand(); selectAppoint.CommandText = "Select a.Appoint_id,p.Patient_id,p.Firstname,d.Doctor_id,d.DFirstname,a.AppointDate,a.Status from PATIENT p, DOCTOR d, APPOINTMENT a where a.Patient_id = p.Patient_id AND a.Doctor_id = d.Doctor_id AND p.Patient_id = @TextBoxid AND (a.Status = 'รอตรวจ' OR a.Status = 'รอยืนยัน' )"; selectAppoint.Parameters.AddWithValue("@TextBoxid", patient_id); selectAppoint.Connection = connectBase.getConnectDatabase(); connectBase.OpenDatabase(); SqlDataReader dataUser = selectAppoint.ExecuteReader(); Model_Appointlist ModelAppointlist = new Model_Appointlist(); if (dataUser.HasRows) { ModelAppointlist.return_code = Return.RETURN_CODE_SUCCESS; ModelAppointlist.return_description = Return.RETURN_DESCRIPTION_SUCCESS; while (dataUser.Read()) { Model_Appoint model_Appoint = new Model_Appoint(); model_Appoint.Appoint_id = Int32.Parse(dataUser[0].ToString()); model_Appoint.Patient_id = Int32.Parse(dataUser[1].ToString()); model_Appoint.Firstname = (dataUser[2].ToString()); model_Appoint.Doctor_id = Int32.Parse(dataUser[3].ToString()); model_Appoint.DFirstname = (dataUser[4].ToString()); model_Appoint.AppointDate = (dataUser[5].ToString()); model_Appoint.Status = (dataUser[6].ToString()); ModelAppointlist.appointlist.Add(model_Appoint); } dataUser.Close(); } else { ModelAppointlist.return_code = Return.RETURN_CODE_ERROR; ModelAppointlist.return_description = Return.RETURN_DESCRIPTION_ERROR; } connectBase.CloseDatabase(); Context.Response.Write(JsonConvert.SerializeObject(ModelAppointlist)); Context.Response.End(); }
public void loginUser(String username, String password) { ConnectDatabase connectBase = new ConnectDatabase(); SqlCommand selectUser = new SqlCommand(); selectUser.CommandText = "Select Patient_id,username,password" + "From PATIENT Where username = @TextBoxUN and password = @TextBoxPW"; selectUser.Parameters.AddWithValue("@TextBoxUN", username); selectUser.Parameters.AddWithValue("@TextBoxPW", password); selectUser.Connection = connectBase.getConnectDatabase(); connectBase.OpenDatabase(); SqlDataReader dataUser = selectUser.ExecuteReader(); Model_Login modelLogin = new Model_Login(); if (dataUser.HasRows) { //modelLogin.return_code = Return.RETURN_CODE_SUCCESS; //modelLogin.return_description = Return.RETURN_DESCRIPTION_SUCCESS; modelLogin.user_profile = new Model_User(); while (dataUser.Read()) { modelLogin.user_profile.Patient_id = Int32.Parse(dataUser[0].ToString()); modelLogin.user_profile.username = (dataUser[1].ToString()); modelLogin.user_profile.password = (dataUser[2].ToString()); } dataUser.Close(); } else { //modelLogin.return_code = Return.RETURN.CODE_ERROR; //modelLogin.return_description = Return.RETURN_DESCRIPTION_ERROR; } connectBase.CloseDatabase(); Context.Response.Write(JsonConvert.SerializeObject(modelLogin)); Context.Response.End(); }