Exemple #1
0
        public List <MPatient> GetPatientList()
        {
            sqlCon = con.openConnection();
            List <MPatient> patientList = new List <MPatient>();

            {
                con.openConnection();
                sqlCom = new SqlCommand("select * from Patient.Patient", sqlCon);
                sqlDa  = new SqlDataAdapter(sqlCom);
                DataTable dt = new DataTable();
                sqlDa.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        MPatient patientData = new MPatient();
                        patientData.IdPatient   = dt.Rows[i]["Id_Patient"].ToString();
                        patientData.PatientName = dt.Rows[i]["Patient_Name"].ToString();
                        patientData.DOB         = dt.Rows[i]["DateOfBirth"].ToString();
                        patientData.Address     = dt.Rows[i]["Address"].ToString();
                        patientData.Gender      = dt.Rows[i]["GenderPatient"].ToString();
                        patientList.Add(patientData);
                    }
                }
                sqlCon.Close();
            }
            return(patientList);
        }
Exemple #2
0
        public MPatient doLogin(string username, string password)
        {
            MPatient mpat = new MPatient();

            sqlCon = con.openConnection();
            sqlCom = new SqlCommand("select * from Patient.Patient where Id_Patient = @username and DateOfBirth = @password", sqlCon);
            sqlCom.Parameters.AddWithValue("@username", username);
            sqlCom.Parameters.AddWithValue("@password", password);
            sqlDa = new SqlDataAdapter(sqlCom);
            DataTable dt = new DataTable();

            sqlDa.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                mpat.IdPatient   = dt.Rows[0]["Id_Patient"].ToString();
                mpat.PatientName = dt.Rows[0]["Patient_Name"].ToString();
                mpat.DOB         = dt.Rows[0]["DateOfBirth"].ToString();
                mpat.Address     = dt.Rows[0]["Address"].ToString();
                mpat.Gender      = dt.Rows[0]["GenderPatient"].ToString();
            }
            else
            {
                mpat.IdPatient = "404";
            }
            sqlCon.Close();
            return(mpat);
        }
Exemple #3
0
        public MPatient AddPatient(string patientname, string dob, string address, string gender)
        {
            sqlCon = con.openConnection();
            using (sqlCon)
            {
                sqlCon.Open();
                string sql = "exec pcdPatient @name,@dob,@address,@gender";
                sqlCom = new SqlCommand(sql, sqlCon);
                using (sqlCom)
                {
                    sqlCom.Parameters.Add(new SqlParameter("@name", patientname));
                    sqlCom.Parameters.Add(new SqlParameter("@dob", dob));
                    sqlCom.Parameters.Add(new SqlParameter("@address", address));
                    sqlCom.Parameters.Add(new SqlParameter("@gender", gender));

                    sqlCom.ExecuteNonQuery();
                }
                sqlCon.Close();
            }


            MPatient mpat = new MPatient();

            sqlCon = con.openConnection();
            sqlCom = new SqlCommand("select * from Patient.Patient where Patient_Name = @patientName and DateOfBirth = @dob and Address = @address", sqlCon);
            sqlCom.Parameters.AddWithValue("@patientName", patientname);
            sqlCom.Parameters.AddWithValue("@dob", dob);
            sqlCom.Parameters.AddWithValue("@address", address);
            sqlDa = new SqlDataAdapter(sqlCom);
            DataTable dt = new DataTable();

            sqlDa.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                mpat.IdPatient   = dt.Rows[0]["Id_Patient"].ToString();
                mpat.PatientName = dt.Rows[0]["Patient_Name"].ToString();
                mpat.DOB         = dt.Rows[0]["DateOfBirth"].ToString();
                mpat.Address     = dt.Rows[0]["Address"].ToString();
                mpat.Gender      = dt.Rows[0]["GenderPatient"].ToString();
            }
            else
            {
                mpat.IdPatient = "404";
            }
            sqlCon.Close();
            return(mpat);
        }