Пример #1
0
        public void SetData(tb_person _patient)
        {
            person                  = _patient;
            txtMaSo.Text            = person.PersonID;
            txtHoTen.Text           = person.FullName;
            cbGioiTinh.SelectedText = person.Gender;
            txtDiDong.Text          = person.MobilePhone;
            if (person.Birthday != null)
            {
                this.dtpNgaySinh.Checked = true;
                dtpNgaySinh.Value        = (DateTime)person.Birthday;
            }
            else
            {
                this.dtpNgaySinh.Checked = false;
            }
            txtHomThu.Text = person.Email;
            if (person.Marital != null)
            {
                cbHonNhan.SelectedValue = person.Marital;
            }
            if (person.ProfessionID != null && !person.ProfessionID.Equals(""))
            {
                cbNgheNghiep.SelectedValue = person.ProfessionID;
            }
            txtDiaChi.Text = person.Address;
            txtGhiChu.Text = person.Note;

            SetEnableComponents(false);
        }
Пример #2
0
        private bool CheckDataInput()
        {
            // Thêm mới thông tin
            if (person == null)
            {
                // Kiểm tra có trùng mã ID
                tb_person _patient = PatientModelManage.Instance.FindPatientByCode(txtMaSo.Text);
                if (_patient != null)
                {
                    MessageBoxEX.DialogMessageBox("Thông báo", "Mã bệnh nhân đã tồn tại", "Vui lòng kiểm tra mã bệnh nhân. Mã này đã tồn tại trong hệ thống");
                    return(false);
                }
            }
            // Sửa lại thông tin
            else
            {
                return(true);
            }

            // Kiểm tra nhập tên khác rỗng
            if (txtHoTen.Text.Equals(""))
            {
                MessageBoxEX.DialogMessageBox("Thông báo", "Tên bệnh nhân không được để trống", "Trường tên không được để trống. Yêu cầu phải nhập tên bệnh nhân");
                return(false);
            }

            return(true);
        }
Пример #3
0
 void DisplayPanel(object _child)
 {
     if (_child != null && _child is tb_person)
     {
         panelHome.Show();
         panelListPatient.Hide();
         panelMain.Name = typeof(PanelHome).Name;
         tb_person person = (tb_person)_child;
         panelHome.Person    = person;
         lblNaviBar2.Visible = true;
         lblNaviBar2.Text    = person.FullName;
     }
     else
     {
         if (_child != null && _child is string)
         {
             foreach (UserControl c in panelMain.Controls)
             {
                 ((IFormPanelChild)c).Hide();
             }
             if (_child.ToString().Equals(typeof(PanelListPatient).Name))
             {
                 panelListPatient.RefeshDataTable(null);
                 panelListPatient.Show();
                 lblNaviBar2.Visible = false;
                 lblNaviBar2.Text    = "Empty";
             }
         }
     }
 }
Пример #4
0
 public bool CreatePerson(tb_person _person)
 {
     using (database = new ModelEntities())
     {
         database.tb_person.Add(_person);
         database.SaveChanges();
         return(true);
     }
 }
Пример #5
0
 public bool CreatePerson(tb_person _person)
 {
     using (database = new ModelEntities())
     {
         database.tb_person.Add(_person);
         database.SaveChanges();
         return true;
     }
 }
Пример #6
0
 public void ResetGui()
 {
     person                   = null;
     txtMaSo.Text             = "";
     txtHoTen.Text            = "";
     dtpNgaySinh.Checked      = false;
     txtDiaChi.Text           = "";
     cbGioiTinh.SelectedIndex = 0;
     txtDiDong.Text           = "";
     txtHomThu.Text           = "";
     txtGhiChu.Text           = "";
 }
Пример #7
0
        public bool UpdatePerson(tb_person _person)
        {
            using (database = new ModelEntities())
            {
                tb_person patient = database.tb_person.SingleOrDefault(p => p.PersonID == _person.PersonID);
                patient.FullName    = _person.FullName;
                patient.Birthday    = _person.Birthday;
                patient.Address     = _person.Address;
                patient.Gender      = _person.Gender;
                patient.MobilePhone = _person.MobilePhone;
                patient.Email       = _person.Email;
                patient.Marital     = _person.Marital;
                patient.Note        = _person.Note;

                database.SaveChanges();
                return(true);
            }
        }
Пример #8
0
        private tb_person GetData()
        {
            person          = new tb_person();
            person.PersonID = txtMaSo.Text;
            person.FullName = txtHoTen.Text;
            if (dtpNgaySinh.Checked)
            {
                person.Birthday = new DateTime(dtpNgaySinh.Value.Year, dtpNgaySinh.Value.Month, dtpNgaySinh.Value.Day);
            }
            person.Address     = txtDiaChi.Text;
            person.Gender      = ((CustomControl.Item)cbGioiTinh.SelectedItem).Value;
            person.MobilePhone = txtDiDong.Text;
            person.Marital     = ((CustomControl.Item)cbHonNhan.SelectedItem).Value;
            person.Email       = txtHomThu.Text;
            person.Note        = txtGhiChu.Text;

            return(person);
        }
Пример #9
0
        public void finish()
        {
            string filePath = txtPathFile.Text;

            if (filePath != null && !filePath.Equals(""))
            {
                string extension = System.IO.Path.GetExtension(filePath);
                string header = "YES";
                string conStr, sheetName;

                conStr = string.Empty;
                switch (extension)
                {
                case ".xls":     //Excel 97-03
                    conStr = string.Format(Excel03ConString, filePath, header);
                    break;

                case ".xlsx":     //Excel 07
                    conStr = string.Format(Excel07ConString, filePath, header);
                    break;

                default:
                {
                    MessageBoxEX.DialogMessageBox("Thông báo", "File chọn không tồn tại hoặc hợp lệ", "Bạn hãy kiểm tra lại file chọn cho phù hợp");
                    return;
                }
                }

                //Get the name of the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        cmd.Connection = con;
                        con.Open();
                        DataTable dtExcelSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                        sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                        con.Close();
                    }
                }

                List <tb_person> patients;

                //Read Data from the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        using (OleDbDataAdapter oda = new OleDbDataAdapter())
                        {
                            bool flagIdIsNull = false;
                            patients = new List <tb_person>();

                            DataTable dt = new DataTable();
                            cmd.CommandText = "SELECT * From [" + sheetName + "]";
                            cmd.Connection  = con;
                            con.Open();
                            oda.SelectCommand = cmd;
                            oda.Fill(dt);
                            con.Close();

                            foreach (DataRow row in dt.Rows)
                            {
                                Console.WriteLine("------ROW NEXT-----");

                                tb_person patient = new tb_person();

                                foreach (DataColumn column in dt.Columns)
                                {
                                    Console.Write("Item: ");
                                    Console.Write(column.ColumnName);
                                    Console.Write(" ");
                                    Console.WriteLine(row[column]);

                                    switch (column.ColumnName)
                                    {
                                    case "ID": patient.PersonID = row[column].ToString();
                                        break;

                                    case "FullName": patient.FullName = row[column].ToString();
                                        break;

                                    case "Birthday":
                                    {
                                        if (row[column] != null && !row[column].ToString().Equals(""))
                                        {
                                            patient.Birthday = DateTime.Parse(row[column].ToString(), new CultureInfo("en-CA"));
                                        }
                                    }
                                    break;

                                    case "Gender": patient.Gender = (row[column].ToString().Equals("Nam")?"Male":(row[column].ToString().Equals("Nữ")?"Female":"Khác"));
                                        break;

                                    case "Mobile": patient.MobilePhone = row[column].ToString();
                                        break;

                                    case "Phone": patient.Tel = row[column].ToString();
                                        break;

                                    case "Email": patient.Email = row[column].ToString();
                                        break;

                                    case "Address": patient.Address = row[column].ToString();
                                        break;

                                    case "Note": patient.Note = row[column].ToString();
                                        break;

                                    default: break;
                                    }
                                }

                                if (patient.PersonID != null && !patient.PersonID.Equals(""))
                                {
                                    patients.Add(patient);
                                    flagIdIsNull = false;
                                }
                                else
                                {
                                    if (flagIdIsNull)
                                    {
                                        break;
                                    }
                                    flagIdIsNull = true;
                                }
                            }
                        }
                    }
                }

                if (patients != null && patients.Count != 0)
                {
                    ManageSoftware.CustomControl.FormLoad f = new ManageSoftware.CustomControl.FormLoad();
                    f.Visible = true;
                    int num = 0;
                    foreach (tb_person p in patients)
                    {
                        bool flagSave = PatientModelManage.Instance.CreatePerson(p);
                        if (flagSave)
                        {
                            num += 1;
                        }
                    }
                    f.Close();
                    DialogResult dialogResult = MessageBoxEX.DialogMessageBox("Thông báo", "Đã hoàn thành thêm " + num + " bản ghi vào hệ thống", "");
                    if (dialogResult.Equals(DialogResult.OK))
                    {
                        this.ParentForm.Close();
                    }
                    return;
                }
                else
                {
                    MessageBoxEX.DialogMessageBox("Thông báo", "Dữ liệu trong file excel trống.", "Bạn hãy kiểm tra lại");
                    return;
                }
            }
            else
            {
                MessageBoxEX.DialogMessageBox("Thông báo", "Vui lòng chọn file phục hồi phù hợp", "Bạn hãy kiểm tra lại file chọn cho phù hợp");
                return;
            }
        }
Пример #10
0
        public void finish()
        {
            string filePath = txtPathFile.Text;
            if (filePath != null && !filePath.Equals(""))
            {
                string extension = System.IO.Path.GetExtension(filePath);
                string header = "YES";
                string conStr, sheetName;

                conStr = string.Empty;
                switch (extension)
                {

                    case ".xls": //Excel 97-03
                        conStr = string.Format(Excel03ConString, filePath, header);
                        break;

                    case ".xlsx": //Excel 07
                        conStr = string.Format(Excel07ConString, filePath, header);
                        break;

                    default:
                        {
                            MessageBoxEX.DialogMessageBox("Thông báo", "File chọn không tồn tại hoặc hợp lệ", "Bạn hãy kiểm tra lại file chọn cho phù hợp");
                            return;
                        }
                }

                //Get the name of the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        cmd.Connection = con;
                        con.Open();
                        DataTable dtExcelSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                        sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                        con.Close();
                    }
                }

                List<tb_person> patients;

                //Read Data from the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        using (OleDbDataAdapter oda = new OleDbDataAdapter())
                        {
                            bool flagIdIsNull = false;
                            patients = new List<tb_person>();

                            DataTable dt = new DataTable();
                            cmd.CommandText = "SELECT * From [" + sheetName + "]";
                            cmd.Connection = con;
                            con.Open();
                            oda.SelectCommand = cmd;
                            oda.Fill(dt);
                            con.Close();

                            foreach (DataRow row in dt.Rows)
                            {
                                Console.WriteLine("------ROW NEXT-----");

                                tb_person patient = new tb_person();

                                foreach (DataColumn column in dt.Columns)
                                {
                                    Console.Write("Item: ");
                                    Console.Write(column.ColumnName);
                                    Console.Write(" ");
                                    Console.WriteLine(row[column]);

                                    switch (column.ColumnName)
                                    {
                                        case "ID": patient.PersonID = row[column].ToString();
                                            break;
                                        case "FullName": patient.FullName = row[column].ToString();
                                            break;
                                        case "Birthday":
                                            {
                                                if (row[column] != null && !row[column].ToString().Equals(""))
                                                    patient.Birthday = DateTime.Parse(row[column].ToString(), new CultureInfo("en-CA"));
                                            }
                                            break;
                                        case "Gender": patient.Gender = (row[column].ToString().Equals("Nam")?"Male":(row[column].ToString().Equals("Nữ")?"Female":"Khác"));
                                            break;
                                        case "Mobile": patient.MobilePhone = row[column].ToString();
                                            break;
                                        case "Phone": patient.Tel = row[column].ToString();
                                            break;
                                        case "Email": patient.Email = row[column].ToString();
                                            break;
                                        case "Address": patient.Address = row[column].ToString();
                                            break;
                                        case "Note": patient.Note = row[column].ToString();
                                            break;
                                        default: break;
                                    }
                                }

                                if (patient.PersonID != null && !patient.PersonID.Equals(""))
                                {
                                    patients.Add(patient);
                                    flagIdIsNull = false;
                                }
                                else
                                {
                                    if (flagIdIsNull)
                                    {
                                        break;
                                    }
                                    flagIdIsNull = true;
                                }
                            }
                        }
                    }
                }

                if(patients != null && patients.Count != 0)
                {
                    ManageSoftware.CustomControl.FormLoad f = new ManageSoftware.CustomControl.FormLoad();
                    f.Visible = true;
                    int num = 0;
                    foreach(tb_person p in patients)
                    {
                        bool flagSave = PatientModelManage.Instance.CreatePerson(p);
                        if (flagSave) num += 1;
                    }
                    f.Close();
                    DialogResult dialogResult = MessageBoxEX.DialogMessageBox("Thông báo", "Đã hoàn thành thêm " + num + " bản ghi vào hệ thống", "");
                    if (dialogResult.Equals(DialogResult.OK))
                        this.ParentForm.Close();
                    return;
                }
                else
                {
                    MessageBoxEX.DialogMessageBox("Thông báo", "Dữ liệu trong file excel trống.", "Bạn hãy kiểm tra lại");
                    return;
                }
            }
            else
            {
                MessageBoxEX.DialogMessageBox("Thông báo", "Vui lòng chọn file phục hồi phù hợp", "Bạn hãy kiểm tra lại file chọn cho phù hợp");
                return;
            }
        }
Пример #11
0
        public bool UpdatePerson(tb_person _person)
        {
            using (database = new ModelEntities())
            {
                tb_person patient = database.tb_person.SingleOrDefault(p => p.PersonID == _person.PersonID);
                patient.FullName = _person.FullName;
                patient.Birthday = _person.Birthday;
                patient.Address = _person.Address;
                patient.Gender = _person.Gender;
                patient.MobilePhone = _person.MobilePhone;
                patient.Email = _person.Email;
                patient.Marital = _person.Marital;
                patient.Note = _person.Note;

                database.SaveChanges();
                return true;
            }
        }