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; } }
private void loginBtn_Click(object sender, RoutedEventArgs e) { var vm = this.DataContext as HISGUILoginVM; this.loginResult.Text = ""; if (string.IsNullOrEmpty(UserNameBox.Text.Trim())) { this.loginResult.Text = "用户名不能为空"; return; } if (string.IsNullOrEmpty(this.passbox.Password.Trim())) { this.loginResult.Text = "密码不能为空"; return; } byte[] result = Encoding.Default.GetBytes(this.passbox.Password.Trim()); MD5 md5 = new MD5CryptoServiceProvider(); byte[] output = md5.ComputeHash(result); string strPassWrod = BitConverter.ToString(output); bool? loginResult = vm?.Login(UserNameBox.Text.Trim(), strPassWrod); if (!(loginResult.HasValue && loginResult.Value)) { this.loginResult.Text = "用户名或者密码错误"; return; } else { string json_out = JsonConvert.SerializeObject(vm.CurrentUser); vm?.MainData.SetToken("LoginUser", json_out); CommClient.Employee employeeColient = new CommClient.Employee(); var job = employeeColient.GetCurrentJob(vm.CurrentUser.ID); if (job == null) { return; } switch (job.PowerEnum) { case CommContracts.PowerEnum.设置模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUISetView"); break; } case CommContracts.PowerEnum.医生模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUIDoctorView"); break; } case CommContracts.PowerEnum.库存管理模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUIMedicineView"); break; } case CommContracts.PowerEnum.护士模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUINurseView"); break; } case CommContracts.PowerEnum.综合收费模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUIFeeView"); break; } case CommContracts.PowerEnum.就诊卡模块: { vm?.RegionManager.RequestNavigate("DownRegion", "HISGUIPatientCardView"); break; } default: break; } } }
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(); } }