示例#1
0
        protected override void ListDataBinding()
        {
            DataTable source;
                switch (EntityName)
                {
                    case "User":
                        using (var manager = new UserManager())
                        {
                            source = manager.GetSource(new Dictionary<IAttributeDefinition, object>(), PagingSetting);
                        }
                        break;
                    case "Application":
                        using (var manager = new ApplicationManager())
                        {
                            var criterias = new Dictionary<IAttributeDefinition, object>();
                            if(this.Current.IsLogon)
                                criterias.Add(AppCore.AppSingleton.FindObjDef<UserObjDef>().Role,this.Current.LogonUser.Role.GetValueOrDefault(UserRole.Client));
                            source = manager.GetSource(criterias, PagingSetting);
                        }
                        break;
                    case "Customer":
                        using (var manager = new CustomerManager())
                        {
                            source = manager.GetSource(new Dictionary<IAttributeDefinition, object>(), PagingSetting);
                        }
                        break;
                    default:
                        source = new DataTable("NoValue");
                        break;
                }

                ObjectList.MasterTableView.DataSource = source;
                ObjectList.MasterTableView.CurrentPageIndex = PagingSetting.PageNum;
                ObjectList.MasterTableView.VirtualItemCount = PagingSetting.ItemCount;
        }
示例#2
0
        protected void Login(string name, string password)
        {
            try
            {
                using (var userMgr = new UserManager())
                {
                    IUser user;

                    if (name == "Admin" && password == "123")
                        user = userMgr.CreateSuperUser(name);
                    else
                        user = userMgr.Authenticate(name, password);

                    if (user == null)
                        Dialog.Error(this,"用户名或密码错误,请联系管理员.");
                    else
                    {
                        Current.Login(user);

                        Dialog.Info(this, "登录成功");
                        AjaxManager.ResponseScripts.Add(string.Format("ChangeUserInfo(\"{0}\");", user.Name));
                        AjaxManager.ResponseScripts.Add("CloseLoginDialog(null,null);");
                        AjaxManager.ResponseScripts.Add("CleanUpDialogInput();");
                    }
                }
            }
            catch(Exception ex )
            {
                MessageBuilder msgBuilder=new MessageBuilder().AppendLine(ex);
                Dialog.Error(this,msgBuilder.Message);
            }
        }
示例#3
0
        protected override bool ListDeleteItem(object sender, GridCommandEventArgs e)
        {
            try
            {
                var item = e.Item as GridDataItem;

                string id = (item.DataItem as DataRowView)["ID"].ToString();
                object result = null;

                switch (EntityName)
                {
                    case "User":
                        using (var manager = new UserManager())
                        {
                            result = manager.Delete(id);
                        }
                        break;
                    case "Application":
                        using (var manager = new ApplicationManager())
                        {
                            result = manager.Delete(id);
                        }
                        break;
                    default:
                        break;
                }

                if (result != null)
                {
                    ObjectList.DataBind();
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }