Exemple #1
0
        public bool UpdateSickRoom(CommContracts.SickRoom sickRoom)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var temp = ctx.SickRooms.FirstOrDefault(m => m.ID == sickRoom.ID);
                if (temp != null)
                {
                    temp.Name         = sickRoom.Name;
                    temp.SickRoomEnum = (DAL.SickRoomEnum)sickRoom.SickRoomEnum;
                    temp.DepartmentID = sickRoom.DepartmentID;
                    temp.Address      = sickRoom.Address;
                }
                else
                {
                    return(false);
                }

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        public bool SaveSickRoom(CommContracts.SickRoom sickRoom)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.SickRoom, DAL.SickRoom>();
                });
                var mapper = config.CreateMapper();

                DAL.SickRoom temp = new DAL.SickRoom();
                temp = mapper.Map <DAL.SickRoom>(sickRoom);

                ctx.SickRooms.Add(temp);
                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #3
0
        public List <CommContracts.SickRoom> GetAllSickRoom(string strName = "")
        {
            List <CommContracts.SickRoom> list = new List <CommContracts.SickRoom>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from a in ctx.SickRooms
                            where a.Name.StartsWith(strName)
                            select a;
                foreach (DAL.SickRoom ass in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.SickRoom, CommContracts.SickRoom>();
                    });
                    var mapper = config.CreateMapper();
                    //CommContracts.Department department = new CommContracts.Department();
                    //department.ID = ass.Department.ID;
                    //department.Name = ass.Department.Name;
                    //department.ParentID = ass.Department.ParentID;
                    //department.IsDoctorDepartment = (ass.Department.DepartmentEnum == DAL.DepartmentEnum.临床科室);

                    CommContracts.SickRoom temp = mapper.Map <CommContracts.SickRoom>(ass);
                    //temp.Department = department;
                    list.Add(temp);
                }
            }
            return(list);
        }
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.NameEdit.Text.Trim()))
            {
                return;
            }

            if (this.SickRoomCombo.SelectedItem == null)
            {
                return;
            }

            if (this.DepartmentCombo.SelectedItem == null)
            {
                return;
            }

            if (bIsEdit)
            {
                SickRoom.Name         = this.NameEdit.Text.Trim();
                SickRoom.SickRoomEnum = (CommContracts.SickRoomEnum) this.SickRoomCombo.SelectedItem;
                var department = (CommContracts.Department) this.DepartmentCombo.SelectedItem;
                SickRoom.DepartmentID = department.ID;
                SickRoom.Address      = this.AddressEdit.Text.Trim();

                CommClient.SickRoom myd = new CommClient.SickRoom();
                if (myd.UpdateSickRoom(SickRoom))
                {
                    (this.Parent as Window).DialogResult = true;
                    (this.Parent as Window).Close();
                }
            }
            else
            {
                CommContracts.SickRoom sickroom = new CommContracts.SickRoom();
                sickroom.Name         = this.NameEdit.Text.Trim();
                sickroom.SickRoomEnum = (CommContracts.SickRoomEnum) this.SickRoomCombo.SelectedItem;
                var department = (CommContracts.Department) this.DepartmentCombo.SelectedItem;
                sickroom.DepartmentID = department.ID;
                sickroom.Address      = this.AddressEdit.Text.Trim();

                CommClient.SickRoom myd = new CommClient.SickRoom();
                if (myd.SaveSickRoom(sickroom))
                {
                    (this.Parent as Window).DialogResult = true;
                    (this.Parent as Window).Close();
                }
            }
        }
        public EditSickRoomView(CommContracts.SickRoom sickroom = null)
        {
            InitializeComponent();
            SickRoomCombo.ItemsSource  = Enum.GetValues(typeof(CommContracts.SickRoomEnum));
            SickRoomCombo.SelectedItem = CommContracts.SickRoomEnum.普通病房;

            CommClient.Department myd = new CommClient.Department();
            DepartmentCombo.ItemsSource = myd.getALLDepartment("");

            bIsEdit = false;
            if (sickroom != null)
            {
                this.SickRoom      = sickroom;
                this.NameEdit.Text = sickroom.Name;
                this.SickRoomCombo.SelectedItem   = sickroom.SickRoomEnum;
                this.DepartmentCombo.SelectedItem = sickroom.Department;
                this.AddressEdit.Text             = sickroom.Address;
                bIsEdit = true;
            }
        }