Пример #1
0
        public bool SaveEmployee(CommContracts.Employee employee, ref int employeeID)
        {
            employee.ModifiedDate = DateTime.Now;

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.Employee, DAL.Employee>();
                });
                var mapper = config.CreateMapper();

                DAL.Employee temp = new DAL.Employee();
                temp = mapper.Map <DAL.Employee>(employee);

                ctx.Employees.Add(temp);
                try
                {
                    ctx.SaveChanges();
                    employeeID = temp.ID;
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
        public List <CommContracts.Employee> GetAllEmployee(string strName = "")
        {
            List <CommContracts.Employee> list = new List <CommContracts.Employee>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from a in ctx.Employees
                            join b in ctx.EmployeeDepartmentHistorys
                            on a.ID equals b.EmployeeID into tt
                            from b in tt.DefaultIfEmpty()
                            where !b.EndDate.HasValue &&
                            a.Name.StartsWith(strName)
                            select new { a, b.Department };
                foreach (var ass in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.Employee, CommContracts.Employee>();
                    });
                    var mapper = config.CreateMapper();

                    CommContracts.Employee temp = mapper.Map <CommContracts.Employee>(ass.a);
                    list.Add(temp);
                }
            }
            return(list);
        }
Пример #3
0
        public bool UpdateEmployee(CommContracts.Employee employee)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var temp = ctx.Employees.FirstOrDefault(m => m.ID == employee.ID);
                if (temp != null)
                {
                    temp.Name         = employee.Name;
                    temp.Gender       = (DAL.GenderEnum)employee.Gender;
                    temp.LoginName    = employee.LoginName;
                    temp.Password     = employee.Password;
                    temp.ModifiedDate = DateTime.Now;
                }
                else
                {
                    return(false);
                }

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #4
0
 private void listView1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     CommContracts.Employee aa = this.listView1.SelectedItem as CommContracts.Employee;
     SelectDoctor = aa;
     (this.Parent as Window).DialogResult = true;
     (this.Parent as Window).Close();
 }
Пример #5
0
        public EditEmployeeView(CommContracts.Employee employee = null)
        {
            InitializeComponent();

            CommClient.Department myd  = new CommClient.Department();
            CommClient.Job        myd1 = new CommClient.Job();
            CommClient.Employee   myd2 = new CommClient.Employee();

            GenderCombo.ItemsSource    = Enum.GetValues(typeof(CommContracts.GenderEnum));
            GenderCombo.SelectedItem   = CommContracts.GenderEnum.男;
            DeparmentCombo.ItemsSource = myd.getALLDepartment("");
            JobCombo.ItemsSource       = myd1.GetAllJob();
            bIsEdit = false;
            if (employee != null)
            {
                this.Employee                    = employee;
                this.NameEdit.Text               = employee.Name;
                this.GenderCombo.SelectedItem    = employee.Gender;
                this.DeparmentCombo.SelectedItem = myd2.GetCurrentDepartment(employee.ID);
                this.JobCombo.SelectedItem       = myd2.GetCurrentJob(employee.ID);
                this.LoginNameEdit.Text          = employee.LoginName;
                this.PasswordEdit.Password       = "";
                bIsEdit = true;
            }
        }
Пример #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CommClient.Employee myd = new CommClient.Employee();
            // 得到医生
            CommClient.EmployeeDepartmentHistory historyClient      = new CommClient.EmployeeDepartmentHistory();
            List <CommContracts.Employee>        listOfSignalSource = historyClient.GetAllDepartmentEmployee(0);

            this.listView1.ItemsSource = listOfSignalSource;
            SelectDoctor = new CommContracts.Employee();
        }
Пример #7
0
        private void Triage_Loaded(object sender, RoutedEventArgs e)
        {
            var vm     = this.DataContext as HISGUINurseVM;
            var jsons1 = vm?.MainData.SelectToken("LoginUser") + "";

            CommContracts.Employee user = new CommContracts.Employee();
            user = JsonConvert.DeserializeObject <CommContracts.Employee>(jsons1);

            vm.CurrentUser = user;
            vm?.TriageManage();
        }
Пример #8
0
 public bool Logout(CommContracts.Employee employee)
 {
     //配合检查重复登录的,编码期间暂时不用,等上线时候再开通
     //using (DAL.HisContext ctx = new DAL.HisContext())
     //{
     //    var queryResult = from u in ctx.EmployeeLoginHistorys
     //                      where u.EmployeeID == employee.ID &&
     //                            !u.LoginOutTime.HasValue
     //                      select u;
     //    if (queryResult.Count() == 1)
     //    {
     //        var u = queryResult.First();
     //        u.LoginOutTime = DateTime.Now;
     //        u.ModifiedDate = DateTime.Now;
     //        ctx.SaveChanges();
     //        return true;
     //    }
     //    return false;
     //}
     return(true);
 }
Пример #9
0
        public CommContracts.Employee Authenticate(string LoginName, string Password, string MachineCode)
        {
            CommContracts.Employee temp = new CommContracts.Employee();
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var queryResult = from u in ctx.Employees
                                  where u.LoginName == LoginName &&
                                  u.Password == Password
                                  select u;

                if (queryResult.Count() == 1)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.Employee, CommContracts.Employee>();
                    });
                    var mapper = config.CreateMapper();

                    temp = mapper.Map <CommContracts.Employee>(queryResult.First());


                    //检查重复登录的,暂时隐藏,以便开发调试
                    //var queryLoginHistory = from h in ctx.EmployeeLoginHistorys
                    //                        where h.EmployeeID == temp.ID &&
                    //                        !h.LoginOutTime.HasValue
                    //                        select h;
                    //if (queryLoginHistory.Count() == 0)
                    //{
                    //    DAL.EmployeeLoginHistory employeeLogin = new DAL.EmployeeLoginHistory();
                    //    employeeLogin.EmployeeID = temp.ID;
                    //    employeeLogin.LoginTime = DateTime.Now;
                    //    employeeLogin.ModifiedDate = DateTime.Now;
                    //    employeeLogin.LoginMachineCode = MachineCode;
                    //    ctx.EmployeeLoginHistorys.Add(employeeLogin);
                    //}
                    //else
                    //{
                    //    return null;
                    //}


                    try
                    {
                        ctx.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        string str = ex.Message;
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }

            if (temp.ID == 0)
            {
                return(null);
            }
            return(temp);
        }
Пример #10
0
 public bool Logout(CommContracts.Employee user)
 {
     CommClient.Employee myd = new CommClient.Employee();
     return(myd.Logout(user, MachineCode.GetMachineCodeString()));
 }
Пример #11
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.NameEdit.Text.Trim()))
            {
                return;
            }

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

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

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

            int nCurrentSelectDepartment = ((CommContracts.Department) this.DeparmentCombo.SelectedItem).ID;
            int nCurrentSelectJob        = ((CommContracts.Job) this.JobCombo.SelectedItem).ID;

            bool bIsOk      = true;
            int  employeeID = 0;

            if (bIsEdit)
            {
                employeeID         = Employee.ID;
                Employee.Name      = this.NameEdit.Text.Trim();
                Employee.Gender    = (CommContracts.GenderEnum) this.GenderCombo.SelectedItem;
                Employee.LoginName = this.LoginNameEdit.Text;

                if (this.IsEditPassword.IsChecked.Value)
                {
                    Employee.Password = MyMD5.strToMD5Str(this.PasswordEdit.Password.Trim());
                }

                CommClient.Employee myd = new CommClient.Employee();
                if (!myd.UpdateEmployee(Employee))
                {
                    bIsOk = false;
                }

                if (bIsOk)
                {
                    if (nCurrentSelectDepartment != myd.GetCurrentDepartment(employeeID).ID)
                    {
                        bIsOk = UpdateEmployeeDepartmentHistory(employeeID, nCurrentSelectDepartment);
                    }
                }

                if (bIsOk)
                {
                    if (nCurrentSelectJob != myd.GetCurrentJob(employeeID).ID)
                    {
                        bIsOk = UpdateEmployeeJobHistory(employeeID, nCurrentSelectJob);
                    }
                }
            }
            else
            {
                CommContracts.Employee employee = new CommContracts.Employee();
                employee.Name      = this.NameEdit.Text.Trim();
                employee.Gender    = (CommContracts.GenderEnum) this.GenderCombo.SelectedItem;
                employee.LoginName = this.LoginNameEdit.Text;

                if (this.IsEditPassword.IsChecked.Value)
                {
                    employee.Password = MyMD5.strToMD5Str(this.PasswordEdit.Password.Trim());
                }

                CommClient.Employee myd = new CommClient.Employee();

                if (!myd.SaveEmployee(employee, ref employeeID))
                {
                    bIsOk = false;
                }

                if (bIsOk)
                {
                    bIsOk = UpdateEmployeeDepartmentHistory(employeeID, nCurrentSelectDepartment);
                }

                if (bIsOk)
                {
                    bIsOk = UpdateEmployeeJobHistory(employeeID, nCurrentSelectJob);
                }
            }


            if (bIsOk)
            {
                (this.Parent as Window).DialogResult = true;
                (this.Parent as Window).Close();
            }
        }
Пример #12
0
        private List <PaiBan> updateDateClinicMsgGrid()
        {
            var vm = this.DataContext as HISGUIDoctorVM;

            CommClient.Employee employeeClient = new CommClient.Employee();

            var department = employeeClient.GetCurrentDepartment(vm.CurrentUser.ID);

            if (department == null)
            {
                return(null);
            }
            if (department.ID < 0)
            {
                return(null);
            }

            CommClient.EmployeeDepartmentHistory historyClient = new CommClient.EmployeeDepartmentHistory();
            List <CommContracts.Employee>        DoctorList    = historyClient.GetAllDepartmentDoctor(department.ID);

            if (DoctorList == null)
            {
                return(null);
            }

            CommClient.Shift           vistTimeClient = new CommClient.Shift();
            List <CommContracts.Shift> shiftList      = vistTimeClient.GetAllShift();

            if (shiftList == null)
            {
                return(null);
            }

            DateTime monday = getMonday(currentManageDate);

            List <PaiBan> data = new List <PaiBan>();

            for (int i = 0; i < DoctorList.Count(); i++)
            {
                CommContracts.Employee employee = DoctorList.ElementAt(i);
                if (employee == null)
                {
                    continue;
                }

                List <CommContracts.WorkPlan> sourceList = vm?.GetSignalSourceList(department.ID, employee.ID, monday, monday.AddDays(6), 0);
                if (sourceList == null || sourceList.Count <= 0)
                {
                    foreach (var shift in shiftList)
                    {
                        PaiBan paiBan = new PaiBan();
                        paiBan.EmployeeID = employee.ID;
                        paiBan.Name       = employee.Name;
                        paiBan.ShiftID    = shift.ID;
                        paiBan.ShiftName  = shift.Name;
                        paiBan.MaxVistNum = 0;
                        data.Add(paiBan);
                    }
                }
                else
                {
                    foreach (var vistTime in shiftList)
                    {
                        PaiBan paiBan = new PaiBan();
                        paiBan.EmployeeID = employee.ID;
                        paiBan.Name       = employee.Name;

                        paiBan.ShiftID   = vistTime.ID;
                        paiBan.ShiftName = vistTime.Name;

                        foreach (var tem in sourceList)
                        {
                            if (tem == null)
                            {
                                continue;
                            }
                            if (tem.ShiftID != vistTime.ID)
                            {
                                continue;
                            }

                            DayOfWeek dayOfWeek = tem.WorkPlanDate.Value.DayOfWeek;

                            paiBan.WorkPlanIDList[(int)dayOfWeek]       = tem.ID;
                            paiBan.WorkPlanWorkTypeList[(int)dayOfWeek] = tem.WorkType;

                            paiBan.MaxVistNum = tem.MaxNum;
                        }
                        data.Add(paiBan);
                    }
                }
            }
            return(data);
        }