コード例 #1
0
ファイル: DAL_DrugResults.cs プロジェクト: tuga1975/SSK
        public void UpdateDrugSeal(string userId, bool COCA, bool BARB, bool LSD, bool METH, bool MTQL, bool PCP, bool KET, bool BUPRE, bool CAT, bool PPZ, bool NPS, string updatedBy)
        {
            string     NRIC      = new DAL_User().GetUserByUserId(userId).Data.NRIC;
            var        localRepo = _localUnitOfWork.GetRepository <DrugResult>();
            DateTime   today     = DateTime.Today;
            DrugResult drug      = _localUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC) && DbFunctions.TruncateTime(d.UploadedDate) == today);

            if (drug != null)
            {
                drug.COCA                  = COCA;
                drug.BARB                  = BARB;
                drug.LSD                   = LSD;
                drug.METH                  = METH;
                drug.MTQL                  = MTQL;
                drug.PCP                   = PCP;
                drug.KET                   = KET;
                drug.BUPRE                 = BUPRE;
                drug.CAT                   = CAT;
                drug.PPZ                   = PPZ;
                drug.NPS                   = NPS;
                drug.IsSealed              = true;
                drug.SealedOrDiscardedBy   = updatedBy;
                drug.SealedOrDiscardedDate = DateTime.Now;
                localRepo.Update(drug);
                _localUnitOfWork.Save();
            }
        }
コード例 #2
0
ファイル: DAL_DrugResults.cs プロジェクト: tuga1975/SSK
        public void UpdateDiscardDrugResult(string UserID, string UserDoID)
        {
            string   NRIC       = new DAL_User().GetUserByUserId(UserID).Data.NRIC;
            DateTime today      = DateTime.Today;
            var      drugResult = _localUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC == NRIC && DbFunctions.TruncateTime(d.UploadedDate) == today);

            drugResult.IsSealed              = false;
            drugResult.SealedOrDiscardedBy   = UserDoID;
            drugResult.SealedOrDiscardedDate = DateTime.Now;
            _localUnitOfWork.GetRepository <Trinity.DAL.DBContext.DrugResult>().Update(drugResult);
            _localUnitOfWork.Save();
        }
コード例 #3
0
ファイル: FormNewUser.cs プロジェクト: tuga1975/SSK
        private async void CreateUserAsync()
        {
            //if (string.IsNullOrEmpty(_currentUser.SmartCardId) || _currentUser.Fingerprint == null)
            //{
            //    MessageBox.Show("You have to scan your smart card and fingerprint");
            //    return;
            //}
            //
            // Prepare user information
            //

            _currentUser.Name = txtName.Text;
            _currentUser.NRIC = txtNRIC.Text;
            _currentUser.Role = String.IsNullOrEmpty(cboRoles.Text) ? EnumUserRoles.Supervisee : cboRoles.Text;

            ApplicationUser user = new ApplicationUser();

            user.UserName = _currentUser.NRIC;
            user.Name     = _currentUser.Name;
            user.Email    = txtPrimaryEmail.Text;
            user.RightThumbFingerprint = _currentUser.RightThumbFingerprint;
            user.LeftThumbFingerprint  = _currentUser.LeftThumbFingerprint;
            user.IsFirstAttempt        = _currentUser.IsFirstAttempt;
            user.NRIC        = _currentUser.NRIC;
            user.PhoneNumber = txtPrimaryPhone.Text;
            user.SmartCardId = _currentUser.SmartCardId;
            user.Status      = EnumUserStatuses.Enrolled;

            UserManager <ApplicationUser> userManager = ApplicationIdentityManager.GetUserManager();

            Trinity.DAL.DAL_User dalUser = new Trinity.DAL.DAL_User();
            IdentityResult       result  = await userManager.CreateAsync(user, txtPassword.Text.Trim());

            if (result.Succeeded)
            {
                RoleManager <IdentityRole> roleManager = ApplicationIdentityManager.GetRoleManager();
                userManager.AddToRole(user.Id, _currentUser.Role);
                // Save to the Centralized DB also
                //dalUser.CreateUser(_currentUser, false);

                Trinity.DAL.DAL_UserProfile dalUserProfile = new Trinity.DAL.DAL_UserProfile();
                Trinity.BE.UserProfile      userProfile    = new Trinity.BE.UserProfile();
                userProfile.UserId        = _currentUser.UserId;
                userProfile.Primary_Phone = txtPrimaryPhone.Text;
                userProfile.Primary_Email = txtPrimaryEmail.Text;
                userProfile.Nationality   = txtNationality.Text;
                userProfile.DOB           = dpDOB.Value;



                var updateUProfileResult = CallCentralized.Post <bool>("User", "UpdateUserProfile", userProfile);

                //dalUserProfile.UpdateUserProfile(userProfile, _currentUser.UserId, true);

                //// Save to the Centralized DB also
                //dalUserProfile.UpdateUserProfile(userProfile, _currentUser.UserId, false);

                Trinity.BE.IssueCard issuedCard = new Trinity.BE.IssueCard()
                {
                    CreatedDate   = DateTime.Now,
                    Date_Of_Issue = DateTime.Now,
                    Expired_Date  = DateTime.Now.AddYears(2),
                    Name          = _currentUser.Name,
                    NRIC          = _currentUser.NRIC,
                    Serial_Number = "123434",
                    SmartCardId   = _currentUser.SmartCardId,
                    Status        = "Active",
                    UserId        = user.Id
                };
                DAL_IssueCard dalIssuedCard = new DAL_IssueCard();
                dalIssuedCard.Insert(issuedCard);

                btnSave.Enabled = false;
                MessageBox.Show("Create user successfully!", "Create user", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form frmMain = (Form)this.MainForm;
                frmMain.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Could not create user.", "Create user", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }