Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (BaoHienRepository.testDBConnection(txtIP.Text, txtPort.Text, txtNet.Text, txtDataName.Text,
                                                   txtUsername.Text, txtPass.Text))
            {
                SettingManager.UpdateRegistry(txtIP.Text, txtPort.Text, txtNet.Text, txtDataName.Text,
                                              txtUsername.Text, txtPass.Text);
                BaoHienRepository.ResetDBDataContext();
                MessageBox.Show("Cơ sở dữ liệu đã được chuyển");
                this.Hide();
                SystemUser user = Global.CurrentUser;
                if (user != null)
                {
                    SystemUserService systemUserService = new SystemUserService();
                    user = systemUserService.GetSystemUsers().Single(u => (u.Username == Global.CurrentUser.Username) && (u.Password == Global.CurrentUser.Password));
                }
                if (user == null)
                {
                    Login frmLogin = new Login();
                    frmLogin.ShowDialog();
                }
                else
                {
                    Global.CurrentUser = user;
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("Không thể kết nối cơ sở dữ liệu");
            }
        }
Ejemplo n.º 2
0
        private void loadSomeData()
        {
            CustomerService customerService = new CustomerService();

            customers = customerService.GetCustomers().OrderBy(x => x.CustCode).ToList();
            customers.Insert(0, new Customer()
            {
                Id = 0, CustomerName = "Tất cả", CustCode = "Tất cả"
            });

            cbmCustomers.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbmCustomers.AutoCompleteSource = AutoCompleteSource.ListItems;
            cbmCustomers.DataSource         = customers;
            cbmCustomers.DisplayMember      = "CustCode";
            cbmCustomers.ValueMember        = "Id";

            SystemUserService systemUserService = new SystemUserService();

            systemUsers = systemUserService.GetSystemUsers();
            systemUsers.Add(new SystemUser()
            {
                Id = 0, FullName = "Tất cả"
            });
            systemUsers = systemUsers.OrderBy(x => x.Id).ToList();

            cbmUsers.DataSource    = systemUsers;
            cbmUsers.DisplayMember = "FullName";
            cbmUsers.ValueMember   = "Id";
        }
Ejemplo n.º 3
0
        public HttpResponseMessage QuerySystemUserByPage(string searchText, int pageIndex = 1, int pageSize = 10)
        {
            int recordCount = 0;
            List <SystemUserDataInfo> userDataInfos = SystemUserService.GetSystemUserDataInfos(searchText, pageSize, pageIndex, out recordCount);

            return(ResultJson.BuildJsonResponse(new { total = recordCount, rows = userDataInfos }, Models.MessageType.None, null));
        }
        public void loadDataForEditSystemUser(int systemUserId)
        {
            this.Text        = "Chỉnh sửa người dùng này";
            this.btnAdd.Text = "Cập nhật";

            SystemUserService systemUserService = new SystemUserService();

            systemUser = systemUserService.GetSystemUser(systemUserId);

            short  userType = systemUser.Type;
            string o        = cbUserType.Text;

            if (userType == BHConstant.USER_TYPE_ID1)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME1;
            }
            else if (userType == BHConstant.USER_TYPE_ID2)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME2;
            }
            else if (userType == BHConstant.USER_TYPE_ID3)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME3;
            }

            if (systemUser != null)
            {
                txtName.Text        = systemUser.FullName;
                txtCode.Text        = systemUser.Username;
                txtCode.Enabled     = false;
                txtConfirmPass.Text = "";
                txtPass.Text        = "";
            }
        }
 public SsepsIIMembershipProvider()
 {
     var userService = new SystemUserService();
     userService.EncryptionService = new EncryptionService();
     userService.CacheService = new CacheService();
     var authService = new AuthenticationService { EncryptionService = userService.EncryptionService, SystemUserService = userService };
     this.AuthenticationService = authService;            
 }
Ejemplo n.º 6
0
 public HttpResponseMessage UpdatePassWord(UpdatePasswordDataInfo updatePassword)
 {
     updatePassword.ID          = CurrentUserID;
     updatePassword.NewPassword = EncrypManager.Encode(updatePassword.NewPassword);
     updatePassword.OldPassword = EncrypManager.Encode(updatePassword.OldPassword);
     SystemUserService.UpdatePassword(updatePassword);
     return(ResultJson.BuildJsonResponse(null, Models.MessageType.Information, "修改成功"));
 }
Ejemplo n.º 7
0
        public HttpResponseMessage UpdateInfo(SystemUserDataInfo systemUserDataInfo)
        {
            SystemUserDataInfo user = SystemUserService.GetSystemUserDataInfoByID(CurrentUserID);

            user.Password    = string.Empty;
            user.DisplayName = systemUserDataInfo.DisplayName;
            SystemUserService.UpdateSystemUser(user);
            return(ResultJson.BuildJsonResponse(null, Models.MessageType.Information, "修改成功"));
        }
Ejemplo n.º 8
0
        public void loadSystemUserList()
        {
            SystemUserService systemUserService = new SystemUserService();
            List <SystemUser> systemUsers       = systemUserService.GetSystemUsers();

            if (systemUsers != null)
            {
                //dgvUserList.DataSource = systemUsers;
                setUpDataGrid(systemUsers);
            }
        }
Ejemplo n.º 9
0
        public ActionResult List(int?companySysNo)
        {
            int no = companySysNo.GetValueOrDefault();

            if (!companySysNo.HasValue)
            {
                if (CurrUser.CompanySysNo > 0)
                {
                    no = CurrUser.CompanySysNo;
                }
            }
            AddressManagerModel model = new AddressManagerModel {
                CompanySysNo = no
            };

            var company = CompanyService.LoadCompany(no);

            if (company != null)
            {
                model.AreaSysNo = company.AreaSysNo;
                model.Address   = company.Address;
            }
            else
            {
                model.HasError     = true;
                model.ErrorMessage = "客户信息不存在可能已经被删除,请刷新页面重试。";
            }
            QF_SystemUser filter = new QF_SystemUser()
            {
                PageSize     = 10000,
                PageIndex    = 0,
                MasterSysNo  = no,
                CommonStatus = CommonStatus.Actived
            };
            AddressFilter addFilter = new AddressFilter {
                PageSize = 5, AddressGrade = AddressGrade.Building, CompanySysNo = no
            };
            QueryResult <Address> addResult = AddressService.QueryAddressList(addFilter);

            if (addResult != null && addResult.data != null)
            {
                var root = addResult.data.Find(a => a.ParentSysNo.GetValueOrDefault() == 0);
                if (root != null)
                {
                    model.AreaSysNo = root.AreaSysNo;
                    model.Address   = root.PathName;
                }
            }
            SystemUserService user_service = new SystemUserService();
            var result = user_service.QuerySystemUserList(filter);

            model.ManagerList = result.data;
            return(View(model));
        }
        private void loadSomeData()
        {
            SystemUserService systemUserService = new SystemUserService();
            systemUsers = systemUserService.GetSystemUsers();
            systemUsers.Add(new SystemUser() { Id = 0, FullName = "Tất cả" });
            systemUsers = systemUsers.OrderBy(x => x.Id).ToList();

            cbmUsers.DataSource = systemUsers;
            cbmUsers.DisplayMember = "FullName";
            cbmUsers.ValueMember = "Id";
        }
Ejemplo n.º 11
0
        public void TestUserList()
        {
            SystemUserService sus  = new SystemUserService();
            List <SystemUser> list = sus.GetAll();

            Assert.IsNotNull(list);
            foreach (var item in list)
            {
                Console.WriteLine(item.UserName);
            }
        }
 public void loadSystemUserList()
 {
    
     SystemUserService systemUserService = new SystemUserService();
     List<SystemUser> systemUsers = systemUserService.GetSystemUsers();
     if (systemUsers != null)
     {
         //dgvUserList.DataSource = systemUsers;
         setUpDataGrid(systemUsers);
     }
     
 }
Ejemplo n.º 13
0
 public override string[] GetRolesForUser(string username)
 {
     return(CacheService.Get(GetRolesForUserCacheKey.F(username), CacheTimeSpan.TwoMinutes,
                             () =>
     {
         var user = SystemUserService.GetUserByEmail(username, true);
         var roles = SystemUserService.GetUserRoles(user.Id, true);
         return roles.IsNull() || roles.IsEmpty()
                                                ? new String[] {}
                                                : roles.Select(role => role.Role.SystemName).ToArray();
     }));
 }
Ejemplo n.º 14
0
        public IActionResult EditEmployee([FromServices] SystemUserService systemUserBusiness, int roleId,
                                          string nickname, int page = 1)
        {
            int pageSize = 10;
            var plist    = systemUserBusiness.SelectPage(nickname, page, pageSize);

            ViewBag.pList = plist.ToStaticPagedList();


            var empIds = systemUser_RoleBusincess.GetEmployeeIds(roleId);

            ViewBag.empIdSet = new HashSet <long>(empIds);
            return(View());
        }
Ejemplo n.º 15
0
        private void setUpSomeData()
        {
            SystemUserService systemUserService = new SystemUserService();

            users = systemUserService.GetSystemUsers();
            users.Add(new SystemUser()
            {
                Id = 0, FullName = "Tất cả"
            });
            users = users.OrderBy(x => x.Id).ToList();

            cbmUsers.DataSource    = users;
            cbmUsers.DisplayMember = "FullName";
            cbmUsers.ValueMember   = "Id";
        }
Ejemplo n.º 16
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = dgvUserList.SelectedRows;

            foreach (DataGridViewRow dgv in selectedRows)
            {
                SystemUserService systemUserService = new SystemUserService();
                int id = ObjectHelper.GetValueFromAnonymousType <int>(dgv.DataBoundItem, "Id");
                if (!systemUserService.DeleteSystemUser(id))
                {
                    MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            loadSystemUserList();
        }
Ejemplo n.º 17
0
 public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
 {
     try
     {
         var _userService = new SystemUserService();
         var user         = _userService.Login(context.UserName, context.Password);
         var ticket       = GenerateTicket(context.ClientId, user);
         context.Validated(ticket);
     }
     catch (Exception ex)
     {
         var err = new CatchError(ex);
         context.SetError(err.name, err.message);
     }
     return(Task.FromResult <object>(null));
 }
        private void loadSomeData()
        {
            CustomerService customerService = new CustomerService();
            customers = customerService.GetCustomers().OrderBy(x => x.CustCode).ToList();
            customers.Insert(0, new Customer() { Id = 0, CustomerName = "Tất cả", CustCode = "Tất cả" });

            cbmCustomers.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cbmCustomers.AutoCompleteSource = AutoCompleteSource.ListItems;
            cbmCustomers.DataSource = customers;
            cbmCustomers.DisplayMember = "CustCode";
            cbmCustomers.ValueMember = "Id";

            SystemUserService systemUserService = new SystemUserService();
            systemUsers = systemUserService.GetSystemUsers();
            systemUsers.Add(new SystemUser() { Id = 0, FullName = "Tất cả" });
            systemUsers = systemUsers.OrderBy(x => x.Id).ToList();

            cbmUsers.DataSource = systemUsers;
            cbmUsers.DisplayMember = "FullName";
            cbmUsers.ValueMember = "Id";
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public ActionResult SavePwd()
        {
            string OldPassword = Request["OldPassword"];
            string new1        = Request["new1"];
            string new2        = Request["new2"];

            if (new1 != new2)
            {
                throw new BusinessException("您输入的新密码与确认密码不匹配 ");
            }
            string            encrptedPassword  = AuthMgr.EncryptPassword(OldPassword);
            string            encrptednew1      = AuthMgr.EncryptPassword(new1);
            SystemUserService systemUserService = new SystemUserService();

            systemUserService.ResetSystemUserPassword(CurrUser.UserName, encrptedPassword, encrptednew1, AuthMgr.GetApplicationKey());
            //Rpc.Call<int>("AuthService.ResetSystemUserPassword", CurrUser.UserName, encrptedPassword, encrptednew1, AuthMgr.GetApplicationKey());
            AuthMgr.Logout();
            return(Json(new AjaxResult {
                Success = true, Message = "修改成功"
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 20
0
        public HttpResponseMessage AddOrUpdateSystemUser(SystemUserDataInfo systemUserDataInfo)
        {
            string responseMsg = string.Empty;

            if (systemUserDataInfo.ID > 0)
            {
                if (!string.IsNullOrEmpty(systemUserDataInfo.Password))
                {
                    systemUserDataInfo.Password = EncrypManager.Encode(systemUserDataInfo.Password);
                }
                SystemUserService.UpdateSystemUser(systemUserDataInfo);
                responseMsg = "修改成功";
            }
            else
            {
                systemUserDataInfo.Password = EncrypManager.Encode(systemUserDataInfo.Password);
                SystemUserService.AddSystemUser(systemUserDataInfo);
                responseMsg = "添加成功";
            }

            return(ResultJson.BuildJsonResponse(null, Models.MessageType.Information, responseMsg));
        }
Ejemplo n.º 21
0
        private void processLogin()
        {
            if (validator1.Validate())
            {
                SystemUserService systemUserService = new SystemUserService();
                SystemUser        user = systemUserService.GetSystemUsers().Where(u => u.Username == txtUsername.Text && u.Password == txtPassword.Text).FirstOrDefault();
                if (txtUsername.Text == BHConstant.MASTER_USERNAME)
                {
                    switch (txtPassword.Text)
                    {
                    case BHConstant.MASTER_PASSWORD_TO_DELETE_ALL:
                    {
                        DeletingDataBase();
                        break;
                    }

                    case BHConstant.MASTER_PASSWORD_TO_DELETE_WITHOUT_CUSTS_PRODUCTS:
                    {
                        DeletingDataBaseWithoutCustsProducts();
                        break;
                    }
                    }
                }
                if (user != null)
                {
                    this.Hide();
                    Main main = new Main();
                    Global.CurrentUser = user;
                    main.ShowDialog();
                    this.Close();
                }
                else
                {
                    lblErrorMessage.Text = "(*) Tên đăng nhập không đúng hoặc mật mã sai. Vui lòng thử lại.";
                    txtPassword.Text     = "";
                }
            }
        }
Ejemplo n.º 22
0
        public HttpResponseMessage UploadHeaderImage()
        {
            HttpRequest        request         = System.Web.HttpContext.Current.Request;
            HttpFileCollection fileCollection  = request.Files;
            string             headerImagePath = string.Empty;

            if (fileCollection.Count > 0)
            {
                string suffix = Path.GetExtension(fileCollection[0].FileName).ToLower();
                if (string.Equals(suffix, ".jpg") || string.Equals(suffix, ".gif") || string.Equals(suffix, ".png") || string.Equals(suffix, ".pdf"))
                {
                    var    stream            = fileCollection[0].InputStream;
                    string imgTempFolderPath = HttpContext.Current.Server.MapPath("~/data/image/");
                    if (!Directory.Exists(imgTempFolderPath))
                    {
                        Directory.CreateDirectory(imgTempFolderPath);
                    }
                    Random rd        = new Random();
                    string fileName  = CurrentUserID + "_" + rd.Next(10, 100).ToString() + "_" + fileCollection[0].FileName;
                    string imagePath = Path.Combine(imgTempFolderPath, fileName);
                    if (!File.Exists(imagePath))
                    {
                        byte[] myByte = StreamToBytes(stream);
                        using (var fileimage = File.Create(imagePath))
                        {
                            fileimage.Write(myByte, 0, myByte.Length);
                        };
                        headerImagePath = Path.Combine("/data/image/", fileName);
                        SystemUserService.UpdateUserFace(CurrentUserID, headerImagePath);
                    }
                }
                else
                {
                    return(ResultJson.BuildJsonResponse(null, Models.MessageType.Warning, "请上传图片格式(.jpg,.gif,.png,.pdf)"));
                }
            }
            return(ResultJson.BuildJsonResponse(null, Models.MessageType.None, null));
        }
Ejemplo n.º 23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.TryAddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.TryAddSingleton(typeof(TraceSource), service => new TraceSource("error", SourceLevels.Information));
            SystemUserService.Init(services, Configuration);
            var serviceProvider = services.BuildServiceProvider();

            CAppContext.ServiceProvider = serviceProvider;
            CAppContext.Configuration   = Configuration;

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.Configure <RazorViewEngineOptions>(option =>
            {
                option.ViewLocationExpanders.Add(new CustomViewLocationExpander());
            });
        }
Ejemplo n.º 24
0
 private void processLogin()
 {
     if (validator1.Validate())
     {
         SystemUserService systemUserService = new SystemUserService();
         SystemUser user = systemUserService.GetSystemUsers().Where(u => u.Username == txtUsername.Text && u.Password == txtPassword.Text).FirstOrDefault();
         if (txtUsername.Text == BHConstant.MASTER_USERNAME)
         {
             switch (txtPassword.Text)
             {
                 case BHConstant.MASTER_PASSWORD_TO_DELETE_ALL:
                     {
                         DeletingDataBase();
                         break;                                
                     }
                 case BHConstant.MASTER_PASSWORD_TO_DELETE_WITHOUT_CUSTS_PRODUCTS:
                     {
                         DeletingDataBaseWithoutCustsProducts();
                         break;
                     }
             }
         }
         if (user != null)
         {
             this.Hide();
             Main main = new Main();
             Global.CurrentUser = user;
             main.ShowDialog();
             this.Close();
         }
         else
         {
             lblErrorMessage.Text = "(*) Tên đăng nhập không đúng hoặc mật mã sai. Vui lòng thử lại.";
             txtPassword.Text = "";
         }
     }
 }
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (validator1.Validate())
     {
         if (txtNewPass.Text != txtConfirmPass.Text)
         {
             MessageBox.Show("Mật khẩu mới không khớp với nhau!");
             txtNewPass.Text = "";
             txtCurrentPass.Text = "";
         }
         else
         {
             SystemUserService systemUserService = new SystemUserService();
             SystemUser user = systemUserService.GetSystemUsers().Where(u => u.Username == Global.CurrentUser.Username && u.Password == txtCurrentPass.Text).FirstOrDefault();
             if (user != null)
             {
                 user.Password = txtNewPass.Text;
                 bool result = systemUserService.UpdateSystemUser(user);
                 if (result)
                 { 
                     MessageBox.Show("Mật khẩu đã được thay đổi thành công!");
                 }
                 else
                 {
                     MessageBox.Show("Hệ thống đang có lỗi. Vui lòng thử lại sau!");
                 }
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Mật khẩu hiện tại không đúng!");
                 txtNewPass.Text = "";
                 txtCurrentPass.Text = "";
             }
         }
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (BaoHienRepository.testDBConnection(txtIP.Text, txtPort.Text, txtNet.Text, txtDataName.Text,
                txtUsername.Text, txtPass.Text))
            {

                SettingManager.UpdateRegistry(txtIP.Text, txtPort.Text, txtNet.Text, txtDataName.Text,
                    txtUsername.Text, txtPass.Text);
                BaoHienRepository.ResetDBDataContext();
                MessageBox.Show("Cơ sở dữ liệu đã được chuyển");
                this.Hide();
                SystemUser user = Global.CurrentUser;
                if (user != null)
                {
                    SystemUserService systemUserService = new SystemUserService();
                    user = systemUserService.GetSystemUsers().Single(u => (u.Username == Global.CurrentUser.Username) && (u.Password == Global.CurrentUser.Password));
                }
                if (user == null)
                {
                    Login frmLogin = new Login();
                    frmLogin.ShowDialog();
                }
                else
                {
                    Global.CurrentUser = user;
                }

                this.Close();               
            }
            else
            {
                
                MessageBox.Show("Không thể kết nối cơ sở dữ liệu");
               
            }
            
        }
Ejemplo n.º 27
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (validator1.Validate())
     {
         if (txtNewPass.Text != txtConfirmPass.Text)
         {
             MessageBox.Show("Mật khẩu mới không khớp với nhau!");
             txtNewPass.Text     = "";
             txtCurrentPass.Text = "";
         }
         else
         {
             SystemUserService systemUserService = new SystemUserService();
             SystemUser        user = systemUserService.GetSystemUsers().Where(u => u.Username == Global.CurrentUser.Username && u.Password == txtCurrentPass.Text).FirstOrDefault();
             if (user != null)
             {
                 user.Password = txtNewPass.Text;
                 bool result = systemUserService.UpdateSystemUser(user);
                 if (result)
                 {
                     MessageBox.Show("Mật khẩu đã được thay đổi thành công!");
                 }
                 else
                 {
                     MessageBox.Show("Hệ thống đang có lỗi. Vui lòng thử lại sau!");
                 }
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Mật khẩu hiện tại không đúng!");
                 txtNewPass.Text     = "";
                 txtCurrentPass.Text = "";
             }
         }
     }
 }
Ejemplo n.º 28
0
 public SignupScreenViewViewModel(INavigationService service) : base(service)
 {
     RegisterCommand = new DelegateCommand(async() => await RegisterCommandExecute());
     _service        = new SystemUserService();
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                short userType = 0;
                string o = cbUserType.Text;
                if (o != null && o != "" && o != " ")
                {
                    if (o.Contains(BHConstant.USER_TYPE_NAME1))
                    {
                        userType = BHConstant.USER_TYPE_ID1;
                    }
                    else if (o.Contains(BHConstant.USER_TYPE_NAME2))
                    {
                        userType = BHConstant.USER_TYPE_ID2;
                    }
                    else if (o.Contains(BHConstant.USER_TYPE_NAME3))
                    {
                        userType = BHConstant.USER_TYPE_ID3;
                    }
                }
                if (systemUser != null)
                {
                    systemUser.FullName = txtName.Text;
                    if (txtPass.Text != "" && txtConfirmPass.Text != "" && txtPass.Text.Equals(txtConfirmPass.Text))
                    {
                        systemUser.Password = txtPass.Text;
                    }

                    systemUser.Type = userType;

                    SystemUserService systemUserService = new SystemUserService();
                    if (systemUserService.UpdateSystemUser(systemUser))
                    {
                        MessageBox.Show("Người dùng đã được cập nhật thành công");
                        ((SystemUserList)this.CallFromUserControll).loadSystemUserList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    systemUser = new SystemUser
                    {
                        FullName = txtName.Text,
                        Password = txtPass.Text,
                        Type = userType,
                        Username = txtCode.Text
                    };
                    SystemUserService systemUserService = new SystemUserService();
                    if (systemUserService.AddPSystemUser(systemUser))
                    {
                        MessageBox.Show("Người dùng đã được tạo thành công");
                        ((SystemUserList)this.CallFromUserControll).loadSystemUserList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

            }
        }
        public void loadDataForEditSystemUser(int systemUserId)
        {
            this.Text = "Chỉnh sửa người dùng này";
            this.btnAdd.Text = "Cập nhật";

            SystemUserService systemUserService = new SystemUserService();

            systemUser = systemUserService.GetSystemUser(systemUserId);

            short userType = systemUser.Type;
            string o = cbUserType.Text;
            if (userType == BHConstant.USER_TYPE_ID1)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME1;
            }
            else if (userType == BHConstant.USER_TYPE_ID2)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME2;
            }
            else if (userType == BHConstant.USER_TYPE_ID3)
            {
                cbUserType.Text = BHConstant.USER_TYPE_NAME3;
            }

            if (systemUser != null)
            {
                txtName.Text = systemUser.FullName ;
                txtCode.Text = systemUser.Username;
                txtCode.Enabled = false;
                txtConfirmPass.Text = "";
                txtPass.Text = "";
            }
        }
Ejemplo n.º 31
0
 public HttpResponseMessage DeleteSystemUser(int id)
 {
     SystemUserService.DeleteSystemUser(id);
     return(ResultJson.BuildJsonResponse(null, Models.MessageType.Information, "删除成功"));
 }
Ejemplo n.º 32
0
 public AccountController(CustService cust, SystemUserService user)
 {
     _custService = cust;
     _userService = user;
 }
Ejemplo n.º 33
0
        public JsonResult GetSystemUsers()
        {
            var systemUsers = SystemUserService.QuerySystemUsers(GetHttpClient());

            return(Json(systemUsers, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 34
0
        public JsonResult GetSystemUsersBySkills(string[] skills)
        {
            var systemUsers = SystemUserService.QuerySystemUsersBySkills(GetHttpClient(), skills);

            return(Json(systemUsers, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 35
0
        public ActionResult Save()
        {
            string json = Request["data"];

            if (string.IsNullOrWhiteSpace(json))
            {
                throw new BusinessException("传入数据不能为空");
            }
            Company entity = SerializationUtility.JsonDeserialize2 <Company>(json);

            SetEntityBaseUserInfo(entity);
            entity.CompanyStatus = CompanyStatus.Init;
            if (string.IsNullOrEmpty(entity.Name))
            {
                throw new BusinessException("请输入客户名称");
            }
            SystemUser customer = new SystemUser();

            //if (!string.IsNullOrEmpty(entity.ContactCellPhone))
            //{
            if (string.IsNullOrEmpty(entity.ContactName))
            {
                throw new BusinessException("请输入联系人姓名");
            }
            if (string.IsNullOrEmpty(entity.ContactCellPhone))
            {
                throw new BusinessException("请输入联系人手机号");
            }
            if (!WebPortalHelper.IsPhonenum(entity.ContactCellPhone))
            {
                throw new BusinessException("请输入正确的手机号!");
            }

            customer = SystemUserService.LoadSystemUserByLoginNameAndCellPhone(entity.ContactCellPhone, ConstValue.ApplicationID);
            // }

            Company company = CompanyService.LoadCompanyByName(entity.Name);

            if (entity.SysNo > 0)
            {
                Company curentcompany = CompanyService.LoadCompany(entity.SysNo, false);
                if (curentcompany == null)
                {
                    throw new BusinessException("未找到此公司的相关信息");
                }
                if (company != null && company.SysNo != curentcompany.SysNo)
                {
                    throw new BusinessException("系统中已存在当前客户,请重新输入客户名称!");
                }


                if (customer != null && customer.SysNo > 0 && ((!string.IsNullOrEmpty(entity.ContactCellPhone) && !string.Equals(customer.CellPhone, entity.ContactCellPhone)) || (entity.SysNo != customer.MasterSysNo)))
                {
                    throw new BusinessException("系统中已存在此手机号,请更换手机号重试!");
                }
                using (ITransaction it = TransactionManager.Create())
                {
                    //if (!string.IsNullOrEmpty(entity.ContactCellPhone))
                    //{
                    //    if (customer == null || !string.Equals(entity.ContactCellPhone, customer.CellPhone))
                    //    {
                    //        customer = new SystemUser();
                    //        customer.MasterSysNo = entity.SysNo;
                    //        customer.LoginName = customer.CellPhone = entity.ContactCellPhone;
                    //        customer.LoginPassword = AuthMgr.EncryptPassword(entity.ContactCellPhone);
                    //        customer.UserFullName = entity.ContactName;
                    //        customer.CommonStatus = CommonStatus.Actived;
                    //        SetEntityBaseUserInfo(customer);

                    //        var usersysno = user_service.InsertSystemUser(customer);
                    //        if (usersysno > 0)
                    //        {
                    //            if (rolesysno != 0)
                    //            {
                    //                List<Role> roles = new List<Role> { new Role { SysNo = rolesysno } };
                    //                usersrole.SaveUsersRole(usersysno, roles, ConstValue.ApplicationID);
                    //            }
                    //        }

                    //    }
                    //}
                    entity.CompanyStatus = curentcompany.CompanyStatus;
                    entity.AccountSysNo  = curentcompany.AccountSysNo;
                    if (curentcompany.CompanyStatus == CompanyStatus.Invalid)
                    {
                        entity.CompanyStatus = CompanyStatus.Init;
                    }
                    CompanyService.UpdateCompany(entity);
                    it.Complete();
                }
            }
            else
            {
                if (company != null)
                {
                    throw new BusinessException("系统中已存在当前客户,请重新输入客户名称!");
                }
                if (customer != null && customer.SysNo > 0)
                {
                    throw new BusinessException("系统中已存在此手机号,请更换手机号重试!");
                }
                if (!string.IsNullOrEmpty(entity.ContactCellPhone))
                {
                    customer               = new SystemUser();
                    customer.LoginName     = entity.LoginName;
                    customer.CellPhone     = "";
                    customer.LoginPassword = AuthMgr.EncryptPassword(entity.LoginName);
                    customer.UserFullName  = entity.ContactName;
                    customer.CommonStatus  = CommonStatus.Actived;
                    SetEntityBaseUserInfo(customer);
                }
                using (ITransaction it = TransactionManager.Create())
                {
                    entity.SysNo         = CompanyService.InsertCompany(entity);
                    customer.MasterSysNo = entity.SysNo;
                    if (!string.IsNullOrEmpty(entity.ContactCellPhone))
                    {
                        var usersysno = user_service.InsertSystemUser(customer);
                        if (usersysno > 0)
                        {
                            entity.AccountSysNo = usersysno;
                            CompanyService.UpdateCompany(entity);

                            if (rolesysno != 0)
                            {
                                List <Role> roles = new List <Role> {
                                    new Role {
                                        SysNo = rolesysno
                                    }
                                };
                                usersrole.SaveUsersRole(usersysno, roles, ConstValue.ApplicationID);
                            }
                        }
                    }
                    it.Complete();
                }
            }

            return(Json(new AjaxResult {
                Success = true, Message = "保存成功", Data = entity.SysNo
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 36
0
        protected void OnAuthenticateRequest(object sender, EventArgs e)
        {
            SystemUserService systemUserService = this.Container.GetService <SystemUserService>();

            systemUserService.AuthenticateRequestUser();
        }
Ejemplo n.º 37
0
 public EnvironmentController(
     SystemUserService systemUserService)
 {
     _systemUserService = systemUserService;
 }
Ejemplo n.º 38
0
 public AdminController(SystemUserService systemUser)
 {
     userService = systemUser;
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     DataGridViewSelectedRowCollection selectedRows = dgvUserList.SelectedRows;
     foreach (DataGridViewRow dgv in selectedRows)
     {
         SystemUserService systemUserService = new SystemUserService();
         int id = ObjectHelper.GetValueFromAnonymousType<int>(dgv.DataBoundItem, "Id");
         if (!systemUserService.DeleteSystemUser(id))
         {
             MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             break;
         }
     }
     loadSystemUserList();
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                short  userType = 0;
                string o        = cbUserType.Text;
                if (o != null && o != "" && o != " ")
                {
                    if (o.Contains(BHConstant.USER_TYPE_NAME1))
                    {
                        userType = BHConstant.USER_TYPE_ID1;
                    }
                    else if (o.Contains(BHConstant.USER_TYPE_NAME2))
                    {
                        userType = BHConstant.USER_TYPE_ID2;
                    }
                    else if (o.Contains(BHConstant.USER_TYPE_NAME3))
                    {
                        userType = BHConstant.USER_TYPE_ID3;
                    }
                }
                if (systemUser != null)
                {
                    systemUser.FullName = txtName.Text;
                    if (txtPass.Text != "" && txtConfirmPass.Text != "" && txtPass.Text.Equals(txtConfirmPass.Text))
                    {
                        systemUser.Password = txtPass.Text;
                    }

                    systemUser.Type = userType;

                    SystemUserService systemUserService = new SystemUserService();
                    if (systemUserService.UpdateSystemUser(systemUser))
                    {
                        MessageBox.Show("Người dùng đã được cập nhật thành công");
                        ((SystemUserList)this.CallFromUserControll).loadSystemUserList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    systemUser = new SystemUser
                    {
                        FullName = txtName.Text,
                        Password = txtPass.Text,
                        Type     = userType,
                        Username = txtCode.Text
                    };
                    SystemUserService systemUserService = new SystemUserService();
                    if (systemUserService.AddPSystemUser(systemUser))
                    {
                        MessageBox.Show("Người dùng đã được tạo thành công");
                        ((SystemUserList)this.CallFromUserControll).loadSystemUserList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }