コード例 #1
0
ファイル: Customer.cs プロジェクト: johden2/Demo0603
        /// <summary>
        /// 保存记录
        /// </summary>
        /// <returns></returns>
        public ActionResult Customer_Save(Mes_Sys_Customer obj)
        {
            string sMessage = string.Empty;

            //判断数据有效性
            if (string.IsNullOrEmpty(obj.CustomerCode))
            {
                sMessage = "客户编码不可为空";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(obj.CustomerName))
            {
                sMessage = "客户名称不可为空";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            if (obj.ID > 0)
            {
                obj.Modifier     = base.CurUser.UserId;
                obj.ModifiedTime = DateTime.Now;
            }
            else
            {
                obj.Creater     = base.CurUser.UserId;
                obj.CreatedTime = DateTime.Now;
            }
            bool result = MesSysCustomerDao.Instance.Save(obj);

            if (!result)
            {
                sMessage = "保存失败";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { IsSuccess = true, Message = sMessage }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="pager"></param>
        /// <returns></returns>
        public List <Mes_Sys_Customer> FindByPage(Mes_Sys_Customer obj, ref PagerBase pager)
        {
            string sql = @"select * from Mes_Sys_Customer WHERE   1=1 ";

            if (!string.IsNullOrEmpty(obj.CustomerCode))
            {
                sql = sql + string.Format(" AND CustomerCode='{0}'", obj.CustomerCode);
            }
            if (!string.IsNullOrEmpty(obj.CustomerName))
            {
                sql = sql + string.Format(" AND CustomerName='{0}'", obj.CustomerName);
            }
            string orderBy = pager.OrderBy;

            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "CreatedTime DESC";
            }
            string cmdPageSql  = string.Format(BaseDao.PageSql, orderBy, sql, pager.StartNo, pager.EndNo);
            string cmdCountSql = string.Format(BaseDao.CountSql, sql.Substring(sql.ToLower().IndexOf("from", StringComparison.Ordinal)));

            //查询总记录数
            pager.TotalItemCount = this.CurDbSession.FromSql(cmdCountSql).ToScalar <int>();
            //返回当前页的记录数
            return(this.CurDbSession.FromSql(cmdPageSql).ToList <Mes_Sys_Customer>());
        }
コード例 #3
0
ファイル: Customer.cs プロジェクト: johden2/Demo0603
        public ActionResult Customer_FindByPage(Mes_Sys_Customer obj, int page, int rows)
        {
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };
            var list = MesSysCustomerDao.Instance.FindByPage(obj, ref pager);

            return(Json(new { total = pager.TotalItemCount, rows = list }));
        }
コード例 #4
0
        /// <summary>
        /// 获取单个用户实体
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public Mes_Sys_Customer GetCustomer(Mes_Sys_Customer obj)
        {
            List <SqlParameter> list = new List <SqlParameter>();
            string sql = "select top 1 * from Mes_Sys_Customer where 1=1 ";

            if (!string.IsNullOrEmpty(obj.CustomerCode))
            {
                sql = sql + string.Format(" AND CustomerCode='{0}'", obj.CustomerCode);
            }
            if (!string.IsNullOrEmpty(obj.CustomerName))
            {
                sql = sql + string.Format(" AND CustomerName='{0}'", obj.CustomerName);
            }
            return(this.CurDbSession.FromSql(sql.ToString()).ToFirstDefault <Mes_Sys_Customer>());
        }
コード例 #5
0
        /// <summary>
        /// 保存用户
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool Save(Mes_Sys_Customer obj)
        {
            int result = -1;

            if (obj.ID > 0)
            {
                //修改
                result = this.CurDbSession.Update <Mes_Sys_Customer>(obj);
            }
            else
            {
                result = this.CurDbSession.Insert <Mes_Sys_Customer>(obj);
            }
            if (result < 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #6
0
ファイル: Customer.cs プロジェクト: johden2/Demo0603
        public ActionResult Customer_Select(int page, int rows, string q)
        {
            List <Mes_Sys_Customer> list = null;
            Mes_Sys_Customer        obj  = new Mes_Sys_Customer();

            if (!string.IsNullOrEmpty(q))
            {
                obj.CustomerName = q;
            }
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };

            list = MesSysCustomerDao.Instance.FindByPage(obj, ref pager);
            if (list == null)
            {
                list = new List <Mes_Sys_Customer>();
            }

            return(Json(new { total = pager.TotalItemCount, rows = list, JsonRequestBehavior.AllowGet }));
        }