示例#1
0
        //public static void UpdateUserPassword(SystemUser user)
        //{
        //    string sql = string.Format(SQLCommands.UpdateUser, user.UserPassword, user.UserId);
        //    DBCommand dbc = new DBCommand(DBCommand.TransactionType.WithoutTransaction);
        //    dbc.ExecuteCommand(sql);
        //    dbc.CloseConnection();
        //}

        public void CreateUser(SystemUser user)
        {
            if (CheckIfUserExists(user))
            {
                throw new Exception("User '" + user.UserName + "' exists");
            }

            CommonFunctions.UpdateApostrophe(user);
            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO SystemUser(FirstName,LastName,UserName, Email, UserPassword,StaffId) VALUES(");
            sb.Append("'" + user.FirstName + "'");
            sb.Append(",'" + user.LastName + "'");
            sb.Append(",'" + user.UserName + "'");
            sb.Append(",'" + user.Email + "'");
            sb.Append(",'" + user.UserPassword + "'");
            if (user.PersonId != 0)
            {
                sb.Append("," + user.PersonId);
            }
            else
            {
                sb.Append(",null");
            }

            sb.Append(")");

            string sql = sb.ToString();

            dbc.ExecuteCommand(sql);
            dbc.CloseConnection();
        }
示例#2
0
        public List <AppointmentBase> GetList(string sql)
        {
            List <AppointmentBase> appointments = new List <AppointmentBase>();
            DataTable dt = dbc.GetDataTable(sql);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                appointments.Add(GetAppointment(dr));
            }
            return(appointments);
        }
示例#3
0
        public List <Incident> GetList()
        {
            List <Incident> Incidents = new List <Incident>();
            DataTable       dt        = dbc.GetDataTable("SELECT * FROM vw_Incidents");

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                Incidents.Add(GetIncident(dr));
            }
            return(Incidents);
        }
        public List <MedicalCondition> GetList(int PersonId)
        {
            List <MedicalCondition> mecicalConditions = new List <MedicalCondition>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentMedicalConditions WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                MedicalCondition mc = new MedicalCondition();
                mc.StudentMedicalConditionId = (int)dr["StudentMedicalConditionId"];
                mc.StudentId            = (int)dr["StudentId"];
                mc.MedicalConditionName = dr["MedicalCondition"].ToString();
                if (dr["Description"].ToString() != string.Empty)
                {
                    mc.Description = dr["Description"].ToString();
                }
                else
                {
                    mc.Description = "** please update **";
                }
                if (dr["DegreeOfDisability"].ToString() != string.Empty)
                {
                    mc.DegreeOfDisability = dr["DegreeOfDisability"].ToString();
                }
                else
                {
                    mc.DegreeOfDisability = "** please update **";
                }

                mc.Comments = dr["Comments"].ToString();
                mecicalConditions.Add(mc);
            }
            return(mecicalConditions);
        }
        public List <MedicationAndTreatment> GetList(int PersonId)
        {
            List <MedicationAndTreatment> medicationAndTreatment = new List <MedicationAndTreatment>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentMedicationAndTreatment WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                MedicationAndTreatment at = new MedicationAndTreatment();
                at.StudentMedicationAndTreatmentId = (int)dr["StudentMedicationAndTreatmentId"];
                at.StudentId  = (int)dr["StudentId"];
                at.Frequency  = dr["Frequency"].ToString();
                at.Medication = dr["Medication"].ToString();
                if (dr["Description"].ToString() != string.Empty)
                {
                    at.Description = dr["Description"].ToString();
                }
                else
                {
                    at.Description = "** please update **";
                }
                at.Comments = dr["Comments"].ToString();
                medicationAndTreatment.Add(at);
            }
            return(medicationAndTreatment);
        }
        public static void UpdateUserPassword(SystemUser user)
        {
            string    sql = string.Format(SQLCommands.UpdateUser, user.UserPassword, user.UserId);
            DBCommand dbc = new DBCommand(DBCommand.TransactionType.WithoutTransaction);

            dbc.ExecuteCommand(sql);
            dbc.CloseConnection();
        }
        public static SystemUser GetSystemUser(string UserName, string Password)
        {
            DataTable dt;
            DBCommand dbc = new DBCommand(DBCommand.TransactionType.WithoutTransaction);

            dt = dbc.GetDataTable(string.Format(SQLCommands.User, UserName, Password));
            dbc.CloseConnection();
            return(CreateUser(dt));
        }
示例#8
0
        public override void Remove(Person person, int StudentId)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("DELETE FROM StudentNextOfKin WHERE NextOfKinId=" + person.PersonId + " AND StudentId=" + StudentId);

            string sql = sb.ToString();

            DBCommand db             = new DBCommand(DBCommand.TransactionType.WithTransaction);
            int       returnDoctorId = db.ExecuteCommand(sql);

            db.CommitTransactions();
            db.CloseConnection();
        }
        public static void CreateUser(SystemUser user)
        {
            // Create Person
            DBCommand dbc          = new DBCommand(DBCommand.TransactionType.WithoutTransaction);
            string    sql          = string.Format(SQLCommands.CreatePerson, user.PersonFirstName, user.PersonLastName);
            int       lastPersonId = dbc.ExecuteCommand(sql);

            sql = string.Format(SQLCommands.CreateUser, user.UserName, user.UserPassword, lastPersonId);
            int lastUserId = dbc.ExecuteCommand(sql);

            foreach (string role in user.Roles)
            {
                sql = string.Format(SQLCommands.CreateRole, lastUserId, role);
                dbc.ExecuteCommand(sql);
            }
            dbc.CloseConnection();
        }
示例#10
0
        public List <StudentNote> GetList(int PersonId)
        {
            List <StudentNote> studentNotes = new List <StudentNote>();
            DataTable          dt           = dbc.GetDataTable("SELECT * FROM vw_StudentNotes WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                StudentNote sn = new StudentNote();
                sn.StudentNoteId   = (int)dr["StudentNoteId"];
                sn.StudentId       = (int)dr["StudentId"];
                sn.StudentNoteName = dr["StudentNote"].ToString();
                sn.NoteDate        = (DateTime)dr["NoteDate"];
                studentNotes.Add(sn);
            }
            return(studentNotes);
        }
        public List <StudentMedicalConditionAlertBase> GetList(int PersonId)
        {
            List <StudentMedicalConditionAlertBase> mecicalConditionsAlerts = new List <StudentMedicalConditionAlertBase>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentMedicalConditionAlerts WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                StudentMedicalConditionAlertBase smca;
                int medicationAlertTypeId = (int)dr["MedicalTypeAlertTypeId"];
                switch (medicationAlertTypeId)
                {
                case 1:
                    smca = new Asthma();
                    break;

                case 2:
                    smca = new Allergy();
                    break;

                default:
                    smca = new Epilepsy();
                    break;
                }
                smca.StudentMedicalConditionAlertId = (int)dr["StudentMedicalConditionAlertId"];
                smca.MedicalTypeAlertTypeId         = medicationAlertTypeId;
                smca.Definition = dr["Definition"].ToString();

                if (dr["Description"].ToString() != string.Empty)
                {
                    smca.Description = dr["Description"].ToString();
                }
                else
                {
                    smca.Description = "** please update **";
                }


                smca.Comments = dr["Comments"].ToString();
                mecicalConditionsAlerts.Add(smca);
            }
            return(mecicalConditionsAlerts);
        }
        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            mrm = new ModelRekamMedis(0, " ", " ", " ", " ", " ", " ", " ", " ", " ", DateTime.Now.ToShortDateString(),
                                      " ", " ", " ");
            var cmd = new DBCommand(conn);

            var no_rm            = txtRekamMedis.Text;
            var riwayat_penyakit = txtRiwayat.Text;
            var berat_badan      = txtBeratBadan.Text;
            var alergi           = txtAlergi.Text;
            var keluhan          = textKeluhan.Text;
            var diagnosa         = textDiagnosa.Text;
            var tindakan         = textTindakan.Text;
            var id_dokter        = Settings.Default.KodeDokter;
            var kode_poli        = cmd.GetKodePoli();

            cmd.CloseConnection();

            if (CheckTextBox())
            {
                if (cmd.UpdateDataRekamMedis(no_rm, riwayat_penyakit, alergi, berat_badan, keluhan, diagnosa, tindakan,
                                             id_dokter, kode_poli))
                {
                    MessageBox.Show("Rekam medis berhasil di update.", "Informasi", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                    DataContext = mrm;
                    vrm.DisplayDataPasien(no_rm);
                    Close();
                }
                else
                {
                    MessageBox.Show("Rekam medis gagal di update.", "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Pastikan data yang diinputkan sudah benar.", "Perhatian", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }

            e.Handled = true;
        }
        public void Update(Location location)
        {
            DBCommand     db = new DBCommand();
            StringBuilder sb = new StringBuilder();

            sb.Append("UPDATE Location SET ");
            sb.Append("LocationName = '" + location.LocationNameWithoutAbbreviation + "'");
            sb.Append(",Abbreviation = '" + location.Abbreviation + "' ");
            if (location.FullAddress != null && location.Telephone != string.Empty)
            {
                sb.Append(",FullAddress='" + location.FullAddress + "'");
            }
            else
            {
                sb.Append(",FullAddress=null");
            }
            if (location.Telephone != null && location.Telephone != string.Empty)
            {
                sb.Append(",Telephone='" + location.Telephone + "'");
            }
            else
            {
                sb.Append(",Telephone=null");
            }
            sb.Append(",IsResidence=" + location.IsResidence);
            sb.Append(",IsStudentCentre=" + location.IsStudentCentre);
            sb.Append(",IsRollCall=" + location.IsRollCall);
            if (location.RollReference != null && location.RollReference != string.Empty)
            {
                sb.Append(",RollReference='" + location.RollReference + "'");
            }
            else
            {
                sb.Append(",RollReference=null");
            }
            sb.Append(" WHERE LocationId = " + location.LocationId);

            string sql = sb.ToString();

            db.ExecuteCommand(sql);
            db.CloseConnection();
        }
        public List <StudentPersonalCare> GetList(int PersonId)
        {
            List <StudentPersonalCare> personalCate = new List <StudentPersonalCare>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentPersonalCare WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                StudentPersonalCare pc = new StudentPersonalCare();
                pc.StudentPersonalCareId = (int)dr["StudentPersonalCareId"];
                pc.StudentId             = (int)dr["StudentId"];
                pc.Item       = dr["Item"].ToString();
                pc.Assistance = dr["Assistance"].ToString();
                pc.Comments   = dr["Comments"].ToString();
                pc.Frequency  = dr["Frequency"].ToString();
                personalCate.Add(pc);
            }
            return(personalCate);
        }
        public List <PhysicalAbility> GetList(int PersonId)
        {
            List <PhysicalAbility> list = new List <PhysicalAbility>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentPhysicalAbility WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                PhysicalAbility pc = new PhysicalAbility();
                pc.StudentPhysicalAbilityId = (int)dr["StudentPhysicalAbilityId"];
                pc.StudentId   = (int)dr["StudentId"];
                pc.Item        = dr["Item"].ToString();
                pc.Description = dr["Description"].ToString();
                pc.Comments    = dr["Comments"].ToString();

                list.Add(pc);
            }
            return(list);
        }
示例#16
0
        public override void Save()
        {
            DBCommand dbc = new DBCommand(DBCommand.TransactionType.WithTransaction);

            try
            {
                DataBase db = new StudentData(dbc);
                if (Student.PersonId == 0)
                {
                    int studentId = db.Add(Student);
                    if (Student.Doctors.Count > 0)
                    {
                        db = new DoctorData(dbc);
                        foreach (Doctor doctor in Student.Doctors)
                        {
                            db.Allocate(doctor, studentId);
                        }
                    }

                    if (Student.NextOfKin.Count > 0)
                    {
                        db = new NextOfKinData(dbc);
                        foreach (NextOfKin nok in Student.NextOfKin)
                        {
                            if (nok.PersonId == 0)
                            {
                                nok.PersonId = db.Add(nok, studentId);
                            }
                            else
                            {
                                db.Allocate(nok, studentId);
                            }
                        }
                    }

                    if (Student.EmergencyContacts.Count > 0)
                    {
                        db = new EmergencyContactData(dbc);
                        foreach (EmergencyContact ec in Student.EmergencyContacts)
                        {
                            //if (ec.PersonId == 0)
                            //{
                            ec.PersonId = db.Add(ec, studentId);
                            //}
                            //db.Allocate(ec, studentId);
                        }
                    }

                    if (Student.MedicalConditions.Count > 0)
                    {
                        MedicalConditionData mdc = new MedicalConditionData(dbc);
                        foreach (MedicalCondition mc in Student.MedicalConditions)
                        {
                            mdc.Add(mc, studentId);
                        }
                    }
                }
                else
                {
                    db.Update(Student);
                }
                dbc.CommitTransactions();
                dbc.CloseConnection();
                Student.RemovedObjects.Clear();
            }
            catch (Exception ex)
            {
                dbc.rollbackTransactions();
                dbc.CloseConnection();
                throw new Exception(ex.Message);
            }
        }
        private void AddRekamMedis_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            mrm = new ModelRekamMedis(0, " ", " ", " ", " ", " ", " ", " ", " ", " ", DateTime.Now.ToShortDateString(),
                                      " ", " ", " ");
            var cmd = new DBCommand(conn);

            var lstDiagnosa = txtKodeDiagnosis.Text.Split(';').ToArray();
            var lstTindakan = txtKodeTindakan.Text.Split(';').ToArray();

            var riwayat_penyakit = "";

            if (txtRiwayat.Text == string.Empty)
            {
                riwayat_penyakit = "-";
            }
            else
            {
                riwayat_penyakit = txtRiwayat.Text;
            }

            var no_rm       = txtRekamMedis.Text;
            var berat_badan = txtBeratBadan.Text;
            var alergi      = txtAlergi.Text;
            var keluhan     = textKeluhan.Text;
            var diagnosa    = "";
            var tindakan    = "";
            var id_dokter   = Settings.Default.KodeDokter;
            var kode_poli   = cmd.GetKodePoli();

            cmd.CloseConnection();

            var res = false;

            if (CheckTextBox())
            {
                if (!Regex.IsMatch(berat_badan, "^[A-Za-z]+$"))
                {
                    for (var i = 0; i < lstDiagnosa.Length - 1; i++)
                    {
                        diagnosa = lstDiagnosa[i];
                        for (var j = 0; j < lstTindakan.Length - 1; j++)
                        {
                            if (string.IsNullOrEmpty(alergi))
                            {
                                alergi = "-";
                            }

                            tindakan = lstTindakan[j];
                            if (cmd.InsertDataRekamMedis(no_rm, riwayat_penyakit, alergi, berat_badan, keluhan,
                                                         diagnosa, tindakan, id_dokter, kode_poli))
                            {
                                res = true;
                            }
                            else
                            {
                                res = false;
                                break;
                            }
                        }
                    }

                    if (res)
                    {
                        MessageBox.Show("Rekam medis berhasil di tambahkan.", "Informasi", MessageBoxButton.OK,
                                        MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Rekam medis gagal di tambahkan.", "Error", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }

                    DataContext = mrm;
                    vmr.DisplayDataPasien(no_rm);
                    Close();
                }
                else
                {
                    MessageBox.Show("Berat badan harus berupa angka.", "Perhatian", MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Pastikan data yang diinputkan sudah benar.", "Perhatian", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }

            e.Handled = true;
        }