Exemple #1
0
        private DataTable GetSource()
        {
            string sortField            = Grid1.SortField;
            string sortDirection        = Grid1.SortDirection;
            IInfobasisDataSource db     = InfobasisDataSource.Create();
            DataTable            table2 = db.ExecuteTable("SELECT ID, 'test' AS DeptName, ChineseName, Gender FROM SYtbUser WHERE CompanyID = @CompanyID", UserInfo.Current.CompanyID);

            DataView view2 = table2.DefaultView;

            view2.Sort = String.Format("{0} {1}", sortField, sortDirection);

            List <string> filters = new List <string>();

            string searchKeyword = ttbSearch.Text.Trim();

            if (!String.IsNullOrEmpty(searchKeyword) && ttbSearch.ShowTrigger1)
            {
                // RowFilter的用法:http://www.csharp-examples.net/dataview-rowfilter/
                filters.Add(String.Format("ChineseName LIKE '*{0}*'", EscapeLikeValue(searchKeyword)));
            }

            if (filters.Count > 0)
            {
                view2.RowFilter = String.Join(" AND ", filters.ToArray());
            }

            return(view2.ToTable());
        }
Exemple #2
0
        private void BindGrid()
        {
            IInfobasisDataSource db    = InfobasisDataSource.Create();
            DataTable            table = db.ExecuteTable("SELECT * FROM SYtbModule ORDER BY DisplayOrder");

            ModuleGrid.DataSource = table;
            ModuleGrid.DataBind();
        }
Exemple #3
0
        private void InitDropDownMainMaterialType()
        {
            IInfobasisDataSource db = InfobasisDataSource.Create();
            int       companyID     = UserInfo.Current.CompanyID;
            DataTable table         = db.ExecuteTable("SELECT * FROM SYtbEntityList WHERE GroupCode = 'Material' AND CompanyID = @CompanyID ORDER BY DisplayOrder", companyID);

            DropDownMainMaterialType.DataSource     = table;
            DropDownMainMaterialType.DataTextField  = "Name";
            DropDownMainMaterialType.DataValueField = "ID";
            DropDownMainMaterialType.DataBind();

            DropDownMainMaterialType.Items.Insert(0, new FineUIPro.ListItem("", "-1"));
            //DropDownMainMaterialType.Items[0].Selected = true;
        }
        private void InitUserDept()
        {
            int provinceID = 0;

            if (DropDownProvince.SelectedValue != null)
            {
                provinceID = Infobasis.Web.Util.Change.ToInt(DropDownProvince.SelectedValue);
            }

            IInfobasisDataSource db    = InfobasisDataSource.Create();
            DataTable            table = db.ExecuteTable("EXEC usp_SY_GetDeptByType @CompanyID, @DepartmentControlType, @ProvinceID", UserInfo.Current.CompanyID,
                                                         Infobasis.Data.DataEntity.DepartmentControlType.Design, provinceID);

            gridDept.DataSource = table;
            gridDept.DataBind();
        }
        private void InitDesigner()
        {
            int deptID = Infobasis.Web.Util.Change.ToInt(ddbDesignerDept.Value);

            if (deptID > 0)
            {
                IInfobasisDataSource db    = InfobasisDataSource.Create();
                DataTable            table = db.ExecuteTable("EXEC usp_SY_GetEmployeeByDept @CompanyID, @DeptID", UserInfo.Current.CompanyID,
                                                             deptID);

                gridDesigner.DataSource = table;
                gridDesigner.DataBind();
                ddbDesigner.Enabled = true;
            }
            else
            {
                ddbDesigner.Enabled = false;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            String term      = context.Request.QueryString["term"];
            int    companyID = UserInfo.Current.CompanyID;

            IInfobasisDataSource db = InfobasisDataSource.Create();
            DataTable            _t = db.ExecuteTable("SELECT [Name] FROM [SYtbUser] Where CompanyID = @companyID AND [Name] like '%' + @ke + '%'", companyID, term);

            DataRow[] list = new DataRow[_t.Rows.Count];
            _t.Rows.CopyTo(list, 0);

            var wapper = new
            {
                query       = term,
                suggestions = (from row in list select row["Name"].ToString()).ToArray()
                              //, data = new[] { "LR", "LY", "LI", "LT" }
            };
            var suggestions = (from row in list select row["Name"].ToString()).ToArray();

            context.Response.Write(JsonConvert.SerializeObject(suggestions));
        }
Exemple #7
0
        protected void ProcessEntityFieldPermission <T>(T entity, string entityCode)
        {
            int companyID                 = UserInfo.GetCurrentCompanyID();
            IInfobasisDataSource db       = InfobasisDataSource.Create();
            DataTable            dtFields = db.ExecuteTable("EXEC usp_EasyHR_GetFieldPermission @CompanyID, @EntityCode", companyID, entityCode);
            List <string>        columns  = dtFields.AsEnumerable().Select(r => Change.ToString(r["ColumnName"])).Distinct().ToList();

            Type type = entity.GetType();

            foreach (PropertyInfo pi in type.GetProperties())
            {
                string name = pi.Name;
                if (columns.Contains(name))
                {
                    continue;
                }

                Type valueType = pi.PropertyType;
                if (pi.CanWrite)
                {
                    if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable <>))
                    {
                        // If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
                        //columnType = p.PropertyType.GetGenericArguments()[0];
                        pi.SetValue(entity, null, null);
                        continue;
                    }

                    switch (valueType.ToString())
                    {
                    case "System.Nullable":
                        pi.SetValue(entity, null, null);
                        break;

                    case "System.String":
                        pi.SetValue(entity, "", null);
                        break;

                    case "System.Boolean":
                        pi.SetValue(entity, null, null);
                        break;

                    case "System.Int32":
                        pi.SetValue(entity, 0, null);
                        break;

                    case "System.Decimal":
                        pi.SetValue(entity, 0, null);
                        break;

                    case "System.DateTime":
                        pi.SetValue(entity, DateTime.MinValue, null);
                        break;

                    default:
                        pi.SetValue(entity, null, null);
                        break;
                    }
                }
            }
        }