Exemplo n.º 1
0
        //Constructor with useraction and patientdetail
        public FormPatientDetail(string userAction, Patient patient)
        {
            InitializeComponent();
            
            // Set useraction and patientdetail
            this.PatientDetail = patient;
            this.UserAction = userAction;

            // Set useraction and staff
            comboBoxGender.SelectedIndex = 0;
            comboBoxState.SelectedIndex = 0;

            // If useraction is edit then set patientdetail to patientdetail form
            if ("edit".Equals(userAction))
            {
                setPatientDetail(patient);
            }
        }
Exemplo n.º 2
0
        // Insert new patient
        public static int InsertPatient(Patient patient)
        {
            string sqlInsert = @"INSERT INTO PATIENT
                                (FIRSTNAME, LASTNAME, BIRTHDAY, GENDER, ICN, PROFESSION, ADDRESS, DEPOSIT, STATE)
                                VALUES 
                                (@FirstName, @LastName, @BirthDay, @Gender, @ICN, @Profession, @Address, @Deposit, @State)";

            SqlParameter[] sqlParameters = { new SqlParameter("@FirstName", patient.FirstName),
                                           new SqlParameter("@LastName", patient.LastName),
                                           new SqlParameter("@BirthDay", patient.BirthDay),
                                           new SqlParameter("@Gender", patient.Gender),
                                           new SqlParameter("@ICN", patient.ICN),
                                           new SqlParameter("@Profession", patient.Profession),
                                           new SqlParameter("@Address", patient.Address),
                                           new SqlParameter("@Deposit", patient.Deposit),
                                           new SqlParameter("@State", patient.State)};

            return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
        }
Exemplo n.º 3
0
        // Update patien by patientid
        public static int UpdatePatient(Patient patient)
        {
            string sqlUpdate = @"UPDATE PATIENT
                                SET FIRSTNAME = @FirstName, LASTNAME = @LastName, BIRTHDAY = @BirthDay, GENDER = @Gender,
                                    ICN = @ICN, PROFESSION = @Profession, ADDRESS = @Address, DEPOSIT = @Deposit, STATE = @State
                                WHERE (PATIENTID = @PatientID)";

            SqlParameter[] sqlParameters = { new SqlParameter("@PatientID", patient.PatientID), 
                                           new SqlParameter("@FirstName", patient.FirstName),
                                           new SqlParameter("@LastName", patient.LastName),
                                           new SqlParameter("@BirthDay", patient.BirthDay),
                                           new SqlParameter("@Gender", patient.Gender),
                                           new SqlParameter("@ICN", patient.ICN),
                                           new SqlParameter("@Profession", patient.Profession),
                                           new SqlParameter("@Address", patient.Address),
                                           new SqlParameter("@Deposit", patient.Deposit),
                                           new SqlParameter("@State", patient.State)};

            return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
        }
Exemplo n.º 4
0
        // Set value in patientdetail form with PatienDetail 
        public void setPatientDetail(Patient patient)
        {
            this.PatientDetail = patient;

            textBoxPatientID.Text = patient.PatientID.ToString();
            textBoxFirstName.Text = patient.FirstName;
            textBoxLastName.Text = patient.LastName;
            dateBirthday.Value = patient.BirthDay;

            if (patient.ICN != 0)
            {
                textBoxIdentityCard.Text = patient.ICN.ToString();
            }
            
            if (patient.Gender == Patient.GENDER_MALE)
            {
                comboBoxGender.Text = "Nam";
            }
            else
            {
                comboBoxGender.Text = "Nữ";
            }
            textBoxProfession.Text = patient.Profession;
            textBoxAddress.Text = patient.Address;

            if (patient.State == 0)
            {
                comboBoxState.Text = "Ngoại trú";
            }
            else
            {
                comboBoxState.Text = "Nội trú";
            }
        }
Exemplo n.º 5
0
        // Get patient by patientid
        public static Patient GetPatient(int patientID)
        {
            DataTable patientDataTable;
            Patient newPatient = new Patient();

            string sqlSelect = @"SELECT PATIENTID, FIRSTNAME, LASTNAME, BIRTHDAY, GENDER, ICN, PROFESSION, ADDRESS, DEPOSIT, STATE 
                                FROM PATIENT 
                                WHERE PATIENTID = @PatientID";

            SqlParameter[] sqlParameters = { new SqlParameter("@PatientID", patientID) };

            patientDataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters);            

            // If select query have row then set to new patient
            if (patientDataTable.Rows.Count > 0)
            {
                newPatient.PatientID = Convert.ToInt32(patientDataTable.Rows[0]["PATIENTID"].ToString());
                newPatient.FirstName = (string)patientDataTable.Rows[0]["FIRSTNAME"];
                newPatient.LastName = (string)patientDataTable.Rows[0]["LASTNAME"];
                newPatient.BirthDay = (DateTime)patientDataTable.Rows[0]["BIRTHDAY"];
                newPatient.Gender = (int)patientDataTable.Rows[0]["GENDER"];
                newPatient.ICN = (decimal)patientDataTable.Rows[0]["ICN"];
                newPatient.Profession = (string)patientDataTable.Rows[0]["PROFESSION"];
                newPatient.Address = (string)patientDataTable.Rows[0]["ADDRESS"];
                newPatient.Deposit = (decimal)patientDataTable.Rows[0]["DEPOSIT"];
                newPatient.State = (int)patientDataTable.Rows[0]["STATE"];
            }

            return newPatient;
        }