Exemple #1
0
        public ActionResult GetListForAjax(string userName, string userPwd)
        {
            OrderUserInfo orderUserInfo = OrderUserService.Get(userName, userPwd);

            if (orderUserInfo.Id == 0)
            {
                return(Json(new { login = false, orders = new List <OrderInfo>() }));
            }

            var orders = OrderService.List(new OrderSearchSetting()
            {
                PageIndex   = 0,
                PageSize    = 1000,
                ShowDeleted = false,
                OrderUserId = orderUserInfo.Id
            }).Select((m, index) => new {
                OrderNumber  = m.OrderNumber,
                ProductName  = m.ProductName,
                Amount       = m.Amount,
                DeliveryDate = m.DeliveryDate.ToString("yyyy-MM-dd"),
                Status       = EnumHelper.GetEnumDescription(m.Status),
                Remark       = m.Remark,
                Index        = index
            });

            return(Json(new { login = true, orders = orders }));
        }
Exemple #2
0
        public static IPageOfList <OrderUserInfo> List(int pageIndex, int pageSize)
        {
            FastPaging fp = new FastPaging();

            fp.PageIndex   = pageIndex;
            fp.PageSize    = pageSize;
            fp.TableName   = "OrderUsers";
            fp.TableReName = "p";
            fp.PrimaryKey  = "ID";
            fp.QueryFields = "p.*";
            fp.OverOrderBy = " CreateDateTime DESC";


            IList <OrderUserInfo> list  = new List <OrderUserInfo>();
            OrderUserInfo         model = null;
            DataTable             dt    = Goodspeed.Library.Data.SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005());

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    model = Get(dr);
                    if (model != null)
                    {
                        list.Add(model);
                    }
                }
            }
            int count = Count();

            return(new PageOfList <OrderUserInfo>(list, pageIndex, pageSize, count));
        }
Exemple #3
0
        public static int Add(OrderUserInfo model)
        {
            string strSQL = "INSERT INTO OrderUsers(UserName,UserPwd,CompanyName,CreateDateTime) VALUES(@UserName,@UserPwd,@CompanyName,GETDATE());SELECT @@IDENTITY;";

            SqlParameter[] parms = ParameterHelper.GetClassSqlParameters(model);
            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms)));
        }
Exemple #4
0
        public static OrderUserInfo Get(DataRow dr)
        {
            OrderUserInfo model = new OrderUserInfo();

            ReflectionHelper.Fill(dr, model);
            return(model);
        }
Exemple #5
0
        public static void Update(OrderUserInfo model)
        {
            //同时更新Orders表中OrderCompanyName字段
            string strSQL = "UPDATE OrderUsers SET UserName = @UserName,UserPwd = @UserPwd,CompanyName = @CompanyName WHERE Id = @ID;UPDATE Orders SET OrderCompanyName = @CompanyName WHERE OrderUserId = @ID";

            SqlParameter[] parms = ParameterHelper.GetClassSqlParameters(model);
            SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms);
        }
Exemple #6
0
 public static OrderUserInfo Update(OrderUserInfo model)
 {
     if (model.Id == 0)
     {
         //Add
         int id = OrderUserManage.Add(model);
         model.Id = id;
     }
     else
     {
         OrderUserManage.Update(model);
     }
     return(model);
 }
Exemple #7
0
        public ActionResult Edit(OrderUserInfo model)
        {
            bool error = false;

            if (OrderUserService.ExistsUserName(model.Id, model.UserName))
            {
                ModelState.AddModelError("UserNameExists", "用户名存在");
                error = true;
            }
            if (OrderUserService.ExistsCompanyName(model.Id, model.CompanyName))
            {
                ModelState.AddModelError("CompanyNameExists", "公司名已存在");
            }
            if (!error && ModelState.IsValid)
            {
                OrderUserService.Update(model);
                ModelState.AddModelError("Success", "保存成功!");
            }

            return(View());
        }