Пример #1
0
        private void SaveItem()
        {
            Infobasis.Data.DataEntity.Company item = new Infobasis.Data.DataEntity.Company();
            item.Name        = tbxName.Text.Trim();
            item.CompanyCode = tbxCompanyCode.Text.Trim();
            item.Notes       = tbxRemark.Text;
            if (tbxExpiredDatetime.SelectedDate.HasValue)
            {
                item.ExpiredDatetime = tbxExpiredDatetime.SelectedDate.Value;
            }
            item.MaxUsers           = Infobasis.Web.Util.Change.ToInt(tbxMaxUsers.Text);
            item.ClientAdminAccount = tbxClientAdminAccount.Text;
            item.CompanyStatus      = CompanyStatus.Enabled;
            item.CreateDatetime     = DateTime.Now;
            item.CreateByID         = UserInfo.Current.ID;
            item.CreateByName       = UserInfo.Current.ChineseName;

            string clientAdminPwd = tbxClientAdminAccountPwd.Text.Trim();

            // 添加管理员
            item.Users = new List <Infobasis.Data.DataEntity.User>();
            item.Users.Add(new Infobasis.Data.DataEntity.User()
            {
                CompanyID       = item.ID,
                Name            = item.ClientAdminAccount,
                ChineseName     = "系统管理员",
                IsClientAdmin   = true,
                Password        = PasswordUtil.CreateDbPassword(clientAdminPwd),
                DefaultPageSize = 20,
                Enabled         = true,
                CreateByID      = UserInfo.Current.ID,
                CreateByName    = UserInfo.Current.ChineseName,
                CreateDatetime  = DateTime.Now
            });

            DB.Companys.Add(item);
            DB.SaveChanges();

            int companyID           = item.ID;
            IInfobasisDataSource db = InfobasisDataSource.Create();
            int userID = item.Users.FirstOrDefault().ID;

            //需要手动更新,因为CompanyID被直接赋为当前登录人
            db.ExecuteNonQuery("UPDATE SYtbUser SET CompanyID = @CompanyID WHERE ID = @UserID", companyID, userID);
            db.ExecuteNonQuery("EXEC usp_SY_CreateNewComanyDefaultData @CompanyID, @UserID", companyID, userID);

            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
Пример #2
0
        // 超级管理员(admin)不可编辑,也不会检索出来
        protected void Grid1_PreRowDataBound(object sender, FineUIPro.GridPreRowEventArgs e)
        {
            Infobasis.Data.DataEntity.Company company = e.DataItem as Infobasis.Data.DataEntity.Company;

            FineUIPro.LinkButtonField deleteField = Grid1.FindColumn("deleteField") as FineUIPro.LinkButtonField;

            // 不能删除超级管理员
            if (company.IsSystemAdminCompany.HasValue && company.IsSystemAdminCompany.Value)
            {
                deleteField.Enabled = false;
                deleteField.ToolTip = "不能删除此数据!";
            }
            else
            {
                deleteField.Enabled = true;
                deleteField.ToolTip = "删除";
            }
        }
Пример #3
0
        protected void Grid1_RowDataBound(object sender, FineUIPro.GridRowEventArgs e)
        {
            // e.DataItem  -> System.Data.DataRowView or custom class.
            // e.RowIndex -> Current row index.
            // e.Values -> Rendered html for each column of this row.

            Infobasis.Data.DataEntity.Company company = e.DataItem as Infobasis.Data.DataEntity.Company;

            CompanyStatus companyStatus  = (CompanyStatus)company.CompanyStatus;
            RenderField   rfCompnyStatus = Grid1.FindColumn("CompanyStatus") as RenderField;

            if (companyStatus == CompanyStatus.Expired)
            {
                //e.RowCssClass = "Expired-Company";
                e.CellAttributes[rfCompnyStatus.ColumnIndex]["data-color"] = "Expired-Company";
            }
            else if (companyStatus == CompanyStatus.Disabled)
            {
                //e.RowCssClass = "Disabled-Company";
                e.CellAttributes[rfCompnyStatus.ColumnIndex]["data-color"] = "Disabled-Company";
            }
        }