Exemple #1
0
        public ActionResult DemoIndex(Page <DemoModel> model)
        {
            if (model.CurrentPage <= 0)
            {
                model.CurrentPage = 1;
            }
            StringBuilder where = new StringBuilder("where 1=1");
            if (model.Item != null)
            {
                if (!string.IsNullOrEmpty(model.Item.Name))
                {
                    where.AppendFormat(" and Name like '%{0}%' ", model.Item.Name.Trim());
                }
                if (model.Item.DemoRedioButton != null)
                {
                    where.AppendFormat(" and DemoRedioButton = {0} ", model.Item.DemoRedioButton.Value);
                }
                if (!string.IsNullOrEmpty(model.Item.DemoCheckBox))
                {
                    where.AppendFormat(" and DemoCheckBox like '%{0}%' ", model.Item.DemoCheckBox.Trim());
                }
                if (model.Item.DemoSelected != null)
                {
                    where.AppendFormat(" and DemoSelected = {0} ", model.Item.DemoSelected.Value);
                }
                if (!string.IsNullOrEmpty(model.Item.DemoTextArea))
                {
                    where.AppendFormat(" and DemoTextArea like '%{0}%' ", model.Item.DemoTextArea.Trim());
                }
                if (!string.IsNullOrEmpty(model.Item.DemoText))
                {
                    where.AppendFormat(" and DemoText like '%{0}%' ", model.Item.DemoText.Trim());
                }
                if (!string.IsNullOrEmpty(model.Item.Phone))
                {
                    where.AppendFormat(" and Phone like '%{0}%' ", model.Item.Phone.Trim());
                }
                if (!string.IsNullOrEmpty(model.Item.IDCard))
                {
                    where.AppendFormat(" and IDCard like '%{0}%' ", model.Item.IDCard.Trim());
                }
                if (model.Item.DelFlag != null)
                {
                    where.AppendFormat(" and DelFlag = {0} ", model.Item.DelFlag.Value);
                }
            }
            var page = DemoModel.Page(model.CurrentPage, MTConfig.ItemsPerPage, where.ToString(), model.Item);

            page.Item = model.Item;
            LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(DemoModel));
            return(View(page));
        }