예제 #1
0
        private void ButtonApply_OnClick(object sender, RoutedEventArgs e)
        {
            if (isNew)
            {
                try
                {
                    if (this.NameTextBox.Text.Equals("") || !CheckNameIsExist(this.NameTextBox.Text))
                    {
                        var a = new RemindMessageBox1();
                        a.remindText.Text = (string)FindResource("Message1001");;
                        a.ShowDialog();
                        return;
                    }

                    using (var bedDao = new BedDao())
                    {
                        var bed = new DAOModule.Bed();
                        bed.Name = this.NameTextBox.Text;

                        var condition = new Dictionary <string, object>();
                        //using (var machianTypeDao = new MachineTypeDao())
                        //{
                        //    condition.Clear();
                        //    condition["Name"] = MachineTypeComboBox.Text;
                        //    var arealist = machianTypeDao.SelectMachineType(condition);
                        //    if (arealist.Count == 1)
                        //    {
                        //        bed.MachineTypeId = arealist[0].Id;
                        //    }
                        //}
                        if ((bool)(this.RadioButton1.IsChecked))
                        {
                            bed.MachineTypeId = 0;
                        }
                        else if ((bool)(this.RadioButton2.IsChecked))
                        {
                            bed.MachineTypeId = 1;
                        }
                        using (var patientAreaDao = new PatientAreaDao())
                        {
                            condition.Clear();
                            condition["Name"] = ComboBoxPatientArea.Text;
                            var arealist = patientAreaDao.SelectPatientArea(condition);
                            if (arealist.Count == 1)
                            {
                                bed.PatientAreaId = arealist[0].Id;
                            }
                        }

                        if ((bool)(RadioButton3.IsChecked))
                        {
                            bed.IsAvailable = true;
                        }
                        else if ((bool)(RadioButton4.IsChecked))
                        {
                            bed.IsAvailable = false;
                        }

                        if ((bool)(RadioButton5.IsChecked))
                        {
                            bed.IsTemp = true;
                        }
                        else if ((bool)(RadioButton6.IsChecked))
                        {
                            bed.IsTemp = false;
                        }

                        bed.IsOccupy    = false;
                        bed.Description = this.DescriptionTextBox.Text;
                        int lastInsertId = -1;
                        bedDao.InsertBed(bed, ref lastInsertId);
                        //UI
                        BedData bedData = new BedData();
                        bedData.Id          = lastInsertId;
                        bedData.Name        = bed.Name;
                        bedData.PatientArea = ComboBoxPatientArea.Text;
                        bedData.TreatType   = "";
                        bedData.IsTemp      = bed.IsTemp;
                        if (bed.MachineTypeId == 0)
                        {
                            bedData.MachineType = "单泵机";
                        }
                        else if (bed.MachineTypeId == 1)
                        {
                            bedData.MachineType = "双泵机";
                        }
                        bedData.InfectType  = "";
                        bedData.IsAvailable = bed.IsAvailable;
                        bedData.IsOccupy    = bed.IsOccupy;
                        bedData.Description = bed.Description;
                        int temp = this.ListViewBed.SelectedIndex;
                        RefreshData();
                        this.ListViewBed.SelectedIndex = temp;
                    }
                }
                catch (Exception ex)
                {
                    MainWindow.Log.WriteInfoConsole("In CBed.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
                }
                this.ButtonNew.IsEnabled    = true;
                this.ButtonDelete.IsEnabled = true;
                this.ButtonApply.IsEnabled  = true;
                this.ButtonCancel.IsEnabled = true;
            }
            else
            {
                if (ListViewBed.SelectedIndex == -1)
                {
                    return;
                }

                if (this.NameTextBox.Text.Equals(""))
                {
                    var a = new RemindMessageBox1();
                    a.remindText.Text = (string)FindResource("Message1001");;
                    a.ShowDialog();
                    return;
                }
                //throw new NotImplementedException();
                using (var bedDao = new BedDao())
                {
                    var condition = new Dictionary <string, object>();
                    condition["ID"] = Datalist[ListViewBed.SelectedIndex].Id;

                    var fileds = new Dictionary <string, object>();
                    fileds["NAME"] = NameTextBox.Text;

                    var condition2 = new Dictionary <string, object>();

                    //using (var machianTypeDao = new MachineTypeDao())
                    //{
                    //    condition2.Clear();
                    //    condition2["Name"] = MachineTypeComboBox.Text;
                    //    var arealist = machianTypeDao.SelectMachineType(condition2);
                    //    if (arealist.Count == 1)
                    //    {
                    //        fileds["MachineTypeId"] = arealist[0].Id;
                    //    }
                    //}

                    if ((bool)(this.RadioButton1.IsChecked))
                    {
                        fileds["MachineTypeId"] = 0;
                    }
                    else if ((bool)(this.RadioButton2.IsChecked))
                    {
                        fileds["MachineTypeId"] = 1;
                    }

                    using (var patientAreaDao = new PatientAreaDao())
                    {
                        condition2.Clear();
                        condition2["Name"] = ComboBoxPatientArea.Text;
                        var arealist = patientAreaDao.SelectPatientArea(condition2);
                        if (arealist.Count == 1)
                        {
                            fileds["PATIENTAREAID"] = arealist[0].Id;
                        }
                    }
                    if ((bool)(this.RadioButton3.IsChecked))
                    {
                        fileds["ISAVAILABLE"] = true;
                    }
                    else if ((bool)(this.RadioButton4.IsChecked))
                    {
                        fileds["ISAVAILABLE"] = false;
                    }

                    if ((bool)(this.RadioButton5.IsChecked))
                    {
                        fileds["ISTEMP"] = true;
                    }
                    else if ((bool)(this.RadioButton6.IsChecked))
                    {
                        fileds["ISTEMP"] = false;
                    }

                    //fileds["ISOCCUPY"] = CheckBoxIsOccupy.IsChecked;
                    fileds["DESCRIPTION"] = DescriptionTextBox.Text;
                    bedDao.UpdateBed(fileds, condition);
                    if ((bool)(this.RadioButton4.IsChecked))
                    {
                        using (ScheduleTemplateDao scheduleDao = new ScheduleTemplateDao())
                        {
                            scheduleDao.UpdateScheduleTemplate1("-1", Datalist[ListViewBed.SelectedIndex].Id.ToString(), DateTime.Now.Date);
                        }
                    }
                    int temp = this.ListViewBed.SelectedIndex;
                    RefreshData();
                    this.ListViewBed.SelectedIndex = temp;
                }
                isNew = false;
            }
            this.ButtonApply.IsEnabled = false;
        }
예제 #2
0
        private void ListViewCBed_OnLoaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            #region refresh data list
            try
            {
                using (var bedDao = new BedDao())
                {
                    Datalist.Clear();
                    var condition = new Dictionary <string, object>();
                    var list      = bedDao.SelectBed(condition);
                    foreach (var pa in list)
                    {
                        var bedData = new BedData();
                        bedData.Id   = pa.Id;
                        bedData.Name = pa.Name;
                        {
                            using (var patientAreaDao = new PatientAreaDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.PatientAreaId;
                                var arealist = patientAreaDao.SelectPatientArea(condition);
                                if (arealist.Count == 1)
                                {
                                    bedData.PatientArea = arealist[0].Name;
                                }
                            }
                        }

                        //{
                        //    using (var machineTypeDao = new MachineTypeDao())
                        //    {
                        //        condition.Clear();
                        //        condition["ID"] = pa.MachineTypeId;
                        //        var arealist = machineTypeDao.SelectMachineType(condition);
                        //        if (arealist.Count == 1)
                        //        {
                        //            bedData.MachineType = arealist[0].Name;
                        //        }
                        //    }

                        //}

                        if (pa.MachineTypeId == 0)
                        {
                            bedData.MachineType = "单泵机";
                        }
                        else if (pa.MachineTypeId == 1)
                        {
                            bedData.MachineType = "双泵机";
                        }

                        {
                            using (var treatMethodDao = new TreatTypeDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.TreatTypeId;
                                var arealist = treatMethodDao.SelectTreatType(condition);
                                if (arealist.Count == 1)
                                {
                                    bedData.TreatType = arealist[0].Name;
                                }
                            }
                            using (var infectTypeDao = new InfectTypeDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.InfectTypeId;
                                var arealist = infectTypeDao.SelectInfectType(condition);
                                if (arealist.Count == 1)
                                {
                                    bedData.InfectType = arealist[0].Name;
                                }
                            }
                        }
                        bedData.IsAvailable = pa.IsAvailable;
                        bedData.IsOccupy    = pa.IsOccupy;
                        bedData.IsTemp      = pa.IsTemp;
                        bedData.Description = pa.Description;
                        Datalist.Add(bedData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CBed.xaml.cs:ListViewCPatientRoom_OnLoaded 3 exception messsage: " + ex.Message);
            }
            #endregion
        }
예제 #3
0
        private void RefreshData()
        {
            try
            {
                using (var bedDao = new BedDao())
                {
                    Datalist.Clear();
                    var condition = new Dictionary <string, object>();
                    var list      = bedDao.SelectBed(condition);
                    foreach (DAOModule.Bed pa in list)
                    {
                        var bedData = new BedData();
                        bedData.Id   = pa.Id;
                        bedData.Name = pa.Name;
                        {
                            /* using (var patientRoomDao = new PatientRoomDao())
                             * {
                             *   condition.Clear();
                             *   condition["ID"] = pa.PatientRoomId;
                             *   var arealist = patientRoomDao.SelectPatientRoom(condition);
                             *   if (arealist.Count == 1)
                             *   {
                             *       bedData.PatientRoom = arealist[0].Name;
                             *   }
                             * }*/

                            using (var patientAreaDao = new PatientAreaDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.PatientAreaId;
                                var arealist = patientAreaDao.SelectPatientArea(condition);
                                if (arealist.Count == 1)
                                {
                                    bedData.PatientArea = arealist[0].Name;
                                }
                            }

                            using (var infectTypeDao = new InfectTypeDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.InfectTypeId;
                                var arealist = infectTypeDao.SelectInfectType(condition);
                                if (arealist.Count == 1)
                                {
                                    bedData.InfectType = arealist[0].Name;
                                }
                            }
                        }
                        //{
                        //    using (var machineTypeDao = new MachineTypeDao())
                        //    {
                        //        condition.Clear();
                        //        condition["ID"] = pa.MachineTypeId;
                        //        var arealist = machineTypeDao.SelectMachineType(condition);
                        //        if (arealist.Count == 1)
                        //        {
                        //            bedData.MachineType = arealist[0].Name;
                        //        }
                        //    }
                        //}
                        if (pa.MachineTypeId == 0)
                        {
                            bedData.MachineType = "单泵机";
                        }
                        else if (pa.MachineTypeId == 1)
                        {
                            bedData.MachineType = "双泵机";
                        }
                        bedData.IsAvailable = pa.IsAvailable;
                        bedData.IsOccupy    = pa.IsOccupy;
                        bedData.IsTemp      = pa.IsTemp;
                        bedData.Description = pa.Description;
                        Datalist.Add(bedData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CBed.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
            }
        }