Ejemplo n.º 1
0
        public int GetCount(PanelContext data)
        {
            ModelDBHelper helper = ModelDBHelper.Create(data.ModelName);
            Criteria      ct     = CreateQueryCriteria(data.QueryFields, data);

            return(helper.Count(ct));
        }
Ejemplo n.º 2
0
        public System.Data.DataRow Get(PanelContext data)
        {
            ModelDBHelper helper = ModelDBHelper.Create(data.ModelName);
            DataTable     dt     = helper.Query(CreatePKCriteria(data.DataKey), CreateOrders(data.Orders), 0, 0);

            return(dt.Rows.Count > 0 ? dt.Rows[0] : dt.NewRow());
        }
Ejemplo n.º 3
0
        public bool Delete(PanelContext data)
        {
            ModelDBHelper helper = ModelDBHelper.Create(data.ModelName);

            helper.Delete(CreatePKCriteria(data.DataKey));
            return(true);
        }
Ejemplo n.º 4
0
        public bool Insert(PanelContext data)
        {
            ModelDBHelper helper = ModelDBHelper.Create(data.ModelName);

            if (data.Row.IndexByMapping("AccountID") == null)
            {
                data.Row["AccountID"] = Security.CurrentAccountID;
            }
            helper.Insert(data.Row);
            return(true);
        }
Ejemplo n.º 5
0
        public System.Data.DataTable Query(PanelContext data, out int recordcount, ref int pageindex)
        {
            ModelDBHelper helper = ModelDBHelper.Create(data.ModelName);
            Criteria      ct     = CreateQueryCriteria(data.QueryFields, data);

            recordcount = helper.Count(ct);

            int startindex, itemscount;

            Utils.BuidlPagerParam(recordcount, data.PageSize, ref pageindex, out startindex, out itemscount);

            return(helper.Query(ct, CreateOrders(data.Orders), startindex, itemscount));
        }
Ejemplo n.º 6
0
        Criteria CreateQueryCriteria(QueryFieldCollection qfc, PanelContext data)
        {
            Criteria ct = new Criteria(CriteriaType.None);

            //if (data.Model.Type == ModelType.ARTICLE && !data.Model.AuthorityType &&
            //    Security.CurrentAccountID != We7Helper.EmptyGUID)
            ////if (!GeneralConfigs.GetConfig().ShowAllInfo && Security.CurrentAccountID != We7Helper.EmptyGUID && !String.IsNullOrEmpty(Security.CurrentAccountID))
            //{
            //    ct.Add(CriteriaType.Equals, "AccountID", Security.CurrentAccountID);
            //}

            foreach (QueryField qf in qfc)
            {
                if (qf.Operator == OperationType.LIKE)
                {
                    ct.Add(ModelDBHelper.ConvertOperationType(qf.Operator), qf.Column.Name, "%" + qf.Value + "%");
                }
                else
                {
                    ct.Add(ModelDBHelper.ConvertOperationType(qf.Operator), qf.Column.Name, qf.Value);
                }
            }
            return(ct);
        }