Пример #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (ValidData())
        {
            UserObject user = new UserObject();
            user.Name.Value = tbName.Text;
            user.Password.Value = tbPassword.Text;
            user.LoginName.Value = tbLoginName.Text;
            user.IsActive.Value = cbActive.Checked;
            /*if (ddlClients.SelectedIndex > 0)
            {
                user.ClientId.Value = ddlClients.SelectedValue;
            }*/
            user.Answer.Value = tbAnswer.Text;
            user.SecretQuestionId.Value = SecretQuestions1.SecretQuestionId;
            user.ResetPassword.Value = cbResetPassword.Checked;
            /*if (ddlHospitals.SelectedIndex > 0)
            {
                user.HospitalId.Value = ddlHospitals.SelectedValue;
            }*/
            user.SendSMS.Value = cbSms.Checked;
            user.Mobile.Value = tbCellNumber.Text;
            if (ddlCarriers.SelectedValue != "0")
            {
                user.CarrierId.Value = ddlCarriers.SelectedValue;
            }

            user.Save(loggedInUserId);
            if (user.IsLoaded)
            {
                UserRoleObject userRole = new UserRoleObject();
                userRole.UserId.Value = user.UserId.Value;
                userRole.RoleId.Value = ddlRoles.SelectedValue;
                userRole.Save(loggedInUserId);
                UsersTableAdapters.tUsersTableAdapter userTA = new UsersTableAdapters.tUsersTableAdapter();
                userTA.AssignClientsToUser(int.Parse(user.UserId.Value.ToString()),loggedInUserId);
                /*
                UsersTableAdapters.tUsersTableAdapter userTA = new UsersTableAdapters.tUsersTableAdapter();
                if (user.HospitalId.Value != null)
                {
                    Nullable<int> userId = int.Parse(user.UserId.Value.ToString());
                    Nullable<int> hospitalId = int.Parse(user.HospitalId.Value.ToString());
                    userTA.AssignHospitalToUser(userId, hospitalId, false, loggedInUserId);
                }
                else
                {
                    userTA.AssignHospitalToUser((Nullable<int>)user.UserId.Value, null, false, loggedInUserId);
                }
                */
                Response.Redirect("~/Admin/AddUser.aspx?userId=" + user.UserId.Value);
            }

            SetInfoMessage("User saved successfully");
        }
    }
Пример #2
0
 //not using this funciton. for the latest client hospital code will be passed on instead of ref phy
 private bool SetReferringPhysician(DICOMStudyObject dicomStudy,StudyObject risStudy)
 {
     //As our system is not being used to entrer work lists we can not pick up Referrring Physicians from our own worklist
     //therrefore the worklist code has been commented for now and we just create a user
     bool isSet = false;
     /*WorkListObject workList = new WorkListObject();
     workList.WorkListId.Value = dicomStudy.AccessionNumber.Value;
     workList.Load(GenericDataMigrator.AdminUserId);
     if (workList.IsLoaded)
     {
         risStudy.ReferringPhysicianId.Value = workList.RequestingPhysicianId.Value;
         isSet = true;
     }
     else*/
     if(dicomStudy.ReferringPhysician.Value != null)
     {
         UserObject user = new UserObject();
         user.Name.Value = dicomStudy.ReferringPhysician.Value;
         user.Load();
         if (!user.IsLoaded)
         {
             user = DatabaseUtility.CreateUser((string)dicomStudy.ReferringPhysician.Value);
             UserRoleObject userRole = new UserRoleObject();
             userRole.UserId.Value = user.GetPrimaryKey().Value;
             userRole.RoleId.Value = Constants.Roles.ReferringPhysician;
             userRole.Save();
         }
         risStudy.ReferringPhysicianId.Value = user.UserId.Value;
         //risStudy.ReferringPhysician.Value = dicomStudy.ReferringPhysician.Value;
         isSet = true;
     }
     return isSet;
 }
Пример #3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        UserObject user = new UserObject();
        if (tbPassword.Text.Trim().Equals(tbConfirmPassword.Text.Trim()) == false)
        {
            ((Main)this.Master).ErrorMessage = Messages.Error.PasswordsDoNotMatch;
            return;
        }
        if (lbUserId.Text.Length == 0)
        {
            user.LoginName.Value = tbLoginName.Text.Trim();
            user.Load();
            if (user.IsLoaded)
            {
                ((Main)this.Master).ErrorMessage = Messages.Error.LoginNameAlreadyExists;
                return;
            }
        }
        else
        {
            user.UserId.Value = int.Parse(lbUserId.Text.Trim());
            user.Load();
            if (user.IsLoaded == false)
            {
                Session[ParameterNames.Session.ExceptionString] = Messages.Exception.UserIdNotFound;
                PagesFactory.Transfer(PagesFactory.Pages.ErrorPage);
            }

        }
        user.Password.Value = tbPassword.Text.Trim();
        user.Name.Value = RISUtility.GetFullName(tbFirstName.Text.Trim(), tbLastName.Text.Trim());
        user.IsActive.Value = cbIsActive.Checked;
        //user.ClientId.Value = loggedInUserClientId;
        if (lbUserId.Text.Length == 0)
            user.Save();
        else
            user.Update((int)user.UserId.Value);

        foreach (ListItem item in lbUserRoles.Items)
        {
            UserRoleObject userRole = new UserRoleObject();
            userRole.UserId.Value = user.UserId.Value;
            userRole.RoleId.Value = int.Parse(item.Value);
            if (lbUserId.Text.Length > 0)
            {
                userRole.Load();
                if (userRole.IsLoaded == false)
                {
                    userRole.Save();
                }
            }
            else
            {
                userRole.Save();
            }
        }

        //if (lbUserId.Text.Length > 0)
        //{
        //    foreach (ListItem item in lbOtherRoles.Items)
        //    {
        //        UserRoleObject userRole = new UserRoleObject();
        //        userRole.UserId.Value = user.UserId.Value;
        //        userRole.RoleId.Value = int.Parse(item.Value);
        //        userRole.Load();
        //        if (userRole.IsLoaded == true)
        //        {
        //            userRole.Remove(0);
        //        }
        //    }
        //}
        if (lbUserId.Text.Length == 0)
        {
            ((Main)this.Master).InformationMessage = Messages.Information.DataSaved;
        }
        else
        {
            ((Main)this.Master).InformationMessage = Messages.Information.DataUpdated ;
        }
        lbUserId.Text = "";
        tbLoginName.Text = "";
        tbLoginName.Enabled = true;
        tbPassword.Text = "";
        tbConfirmPassword.Text = "";
        tbFirstName.Text = "";
        tbLastName.Text = "";
        lbOtherRoles.Items.Clear();
        lbUserRoles.Items.Clear();
        fillAllRolesList();
        //int count = lbUserRoles.Items.Count;
        //for(int i=0;i<count;i++)
        //    lbUserRoles.Items.RemoveAt(0);
        cbIsActive.Checked = false;
    }