Esempio n. 1
0
 public bool DeleteExt(Mes_Plan_SaleOrder obj)
 {
     //作废订单
     obj.OrderStatus = OrderStatus.ZF;
     this.CurDbSession.Update <Mes_Plan_SaleOrder>(obj);
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// 生成订单行号
        /// </summary>
        /// <returns></returns>
        public int GenOrderResNum(Mes_Plan_SaleOrder order)
        {
            string sql = "SELECT ISNULL(MAX(ResNum),0) FROM Mes_Plan_SaleOrderItem T1 WITH(NOLOCK) WHERE OrderType = '{0}' AND OrderNo='{1}'";

            sql = string.Format(sql, order.OrderType, order.OrderNo);
            int resNo = this.CurDbSession.FromSql(sql).ToScalar <int>();

            return(resNo + 1);
        }
Esempio n. 3
0
        public ActionResult SaleOrderItemMgt_Save(Mes_Plan_SaleOrderItem obj)
        {
            if (obj.OrderID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "请先选择一个订单进行操作!" }));
            }
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【产品编码】不能为空!" }));
            }
            //if (string.IsNullOrEmpty(obj.Version))
            //{
            //    return Json(new { IsSuccess = false, Message = "【产品版本】不能为空!" });
            //}
            Mes_Plan_SaleOrder order = MesPlanSaleOrderDao.Instance.Find <Mes_Plan_SaleOrder, int>(obj.OrderID);

            if (order == null)
            {
                return(Json(new { IsSuccess = false, Message = "选择的主订单信息有误!" }));
            }

            Mes_Plan_SaleOrderItem itemObj = null;

            if (obj.ID > 0)
            {
                itemObj = MesPlanSaleOrderDao.Instance.Find <Mes_Plan_SaleOrderItem, int>(obj.ID);
            }
            else
            {
                itemObj             = new Mes_Plan_SaleOrderItem();
                itemObj.OrderType   = order.OrderType;
                itemObj.OrderNo     = order.OrderNo;
                itemObj.Creater     = base.CurUser.UserId;
                itemObj.CreatedTime = DateTime.Now;
                //生成订单行号
                itemObj.ResNum = MesPlanSaleOrderDao.Instance.GenOrderResNum(order);
            }
            if (itemObj == null)
            {
                return(Json(new { IsSuccess = false, Message = "订单明细信息有误,请刷新后重试!" }));
            }

            itemObj.MaterialProNo = obj.MaterialProNo;
            itemObj.MaterialCode  = obj.MaterialCode;
            itemObj.MaterialSize  = obj.MaterialSize;
            itemObj.Unit          = obj.Unit;
            itemObj.Num           = obj.Num;
            itemObj.Price         = obj.Price;
            itemObj.Amount        = obj.Amount;
            itemObj.ShipDate      = obj.ShipDate;
            itemObj.AlNum         = obj.AlNum;
            itemObj.Memo          = obj.Memo;

            int id = MesPlanSaleOrderDao.Instance.Save <Mes_Plan_SaleOrderItem>(itemObj);

            return(Json(new { IsSuccess = true, Message = id.ToString() }));
        }
Esempio n. 4
0
        public ActionResult SaleOrderMgt_FindByPage(Mes_Plan_SaleOrder obj, int page, int rows)
        {
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };
            var list = MesPlanSaleOrderDao.Instance.FindByPage(obj, ref pager);

            return(Json(new { total = pager.TotalItemCount, rows = list }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public List <Mes_Plan_SaleOrder> FindByPage(Mes_Plan_SaleOrder obj, ref PagerBase pager)
        {
            string sql = @"SELECT T1.*,T2.CustomerName FROM Mes_Plan_SaleOrder T1 WITH(NOLOCK)
                        LEFT JOIN dbo.Mes_Sys_Customer T2 WITH(NOLOCK) ON T1.CustomerID = T2.ID
                        WHERE OrderStatus<>20 ";

            if (TConvertHelper.FormatDBInt(obj.OrderType) > 0)
            {
                sql += string.Format(" AND T1.OrderType = '{0}'", obj.OrderType);
            }
            if (!string.IsNullOrEmpty(obj.OrderNo))
            {
                sql += string.Format(" AND T1.OrderNo Like '%{0}%'", obj.OrderNo);
            }
            if (!string.IsNullOrEmpty(obj.OrderDateStart))
            {
                sql += string.Format(" AND T1.OrderDate >='{0}'", obj.OrderDateStart);
            }
            if (!string.IsNullOrEmpty(obj.OrderDateEnd))
            {
                sql += string.Format(" AND T1.OrderDate <'{0}'", TConvertHelper.FormatDBDate(obj.OrderDateEnd).AddDays(1));
            }
            if (obj.OrderStatus > 0)
            {
                sql += string.Format(" AND T1.OrderStatus = {0}", obj.OrderStatus);
            }
            if (!string.IsNullOrEmpty(obj.CustomerName))
            {
                sql += string.Format(" AND T1.CustomerName Like '%{0}%'", obj.CustomerName);
            }
            if (!string.IsNullOrEmpty(obj.CreatedTimeStart))
            {
                sql += string.Format(" AND T1.CreatedTime >='{0}'", obj.CreatedTimeStart);
            }
            if (!string.IsNullOrEmpty(obj.CreatedTimeEnd))
            {
                sql += string.Format(" AND T1.CreatedTime <'{0}'", TConvertHelper.FormatDBDate(obj.CreatedTimeEnd).AddDays(1));
            }

            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_Plan_SaleOrder>());
        }
Esempio n. 6
0
        public ActionResult SaleOrderMgt_Save(Mes_Plan_SaleOrder obj)
        {
            if (string.IsNullOrEmpty(obj.OrderType))
            {
                return(Json(new { IsSuccess = false, Message = "【订单单别】不能为空!" }));
            }
            if (obj.OrderDate <= TConvertHelper.SYS_MINDATE)
            {
                return(Json(new { IsSuccess = false, Message = "【下单日期】不能为空!" }));
            }
            if (obj.CustomerID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "【下单客户】不能为空!" }));
            }

            Mes_Plan_SaleOrder order = null;

            if (obj.ID > 0)
            {
                order = MesPlanSaleOrderDao.Instance.Find <Mes_Plan_SaleOrder, int>(obj.ID);
            }
            else
            {
                order             = new Mes_Plan_SaleOrder();
                order.OrderStatus = OrderStatus.YXD;
                order.Creater     = base.CurUser.UserId;
                order.CreatedTime = DateTime.Now;
                //生成订单号
                order.OrderNo = MesPlanSaleOrderDao.Instance.GenOrderNo();
            }
            if (order == null)
            {
                return(Json(new { IsSuccess = false, Message = "订单信息有误,请刷新后重试!" }));
            }

            order.OrderType   = obj.OrderType;
            order.OrderDate   = obj.OrderDate;
            order.OrderAmount = obj.OrderAmount;
            order.CustomerID  = obj.CustomerID;
            order.PaymentType = obj.PaymentType;
            order.Memo        = obj.Memo;
            int id = MesPlanSaleOrderDao.Instance.Save(order);

            return(Json(new { IsSuccess = true, Message = id.ToString() }));
        }
Esempio n. 7
0
        public ActionResult SaleOrderMgt_Find(int ID)
        {
            if (ID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "选择的记录有误,请刷新后重试!" }));
            }
            Mes_Plan_SaleOrder searchObj = new Mes_Plan_SaleOrder();

            searchObj.ID = ID;
            Mes_Plan_SaleOrder obj = MesPlanSaleOrderDao.Instance.FindEntity(searchObj);

            if (obj == null)
            {
                return(Json(new { IsSuccess = false, Message = "订单信息不存在,请刷新后重试!" }));
            }

            return(Json(new { IsSuccess = true, Message = JsonHelper.SerializeObject(obj) }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 8
0
        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ActionResult SaleOrderMgt_Delete(int ID)
        {
            if (ID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "选择的记录有误,请刷新后重试!" }));
            }
            Mes_Plan_SaleOrder obj = MesPlanSaleOrderDao.Instance.Find <Mes_Plan_SaleOrder, int>(ID);

            if (obj == null)
            {
                return(Json(new { IsSuccess = false, Message = "订单信息不存在,请刷新后重试!" }));
            }
            if (obj.OrderStatus != OrderStatus.YXD)
            {
                return(Json(new { IsSuccess = false, Message = "订单已在流程中,不允许作废!" }));
            }

            MesPlanSaleOrderDao.Instance.DeleteExt(obj);
            return(Json(new { IsSuccess = true, Message = "" }));
        }
Esempio n. 9
0
        public List <Mes_Plan_SaleOrderItem> FindItemByPage(Mes_Plan_SaleOrderItem obj, ref PagerBase pager)
        {
            Mes_Plan_SaleOrder order = null;

            if (obj.OrderID > 0)
            {
                order = this.Find <Mes_Plan_SaleOrder, int>(obj.OrderID);
            }
            if (order == null)
            {
                order = new Mes_Plan_SaleOrder();
            }

            string sql = @"SELECT T1.* FROM Mes_Plan_SaleOrderItem T1 WITH(NOLOCK) WHERE 1=1";

            if (!string.IsNullOrEmpty(order.OrderType))
            {
                sql += string.Format(" AND T1.OrderType = '{0}'", order.OrderType);
            }
            if (!string.IsNullOrEmpty(order.OrderNo))
            {
                sql += string.Format(" AND T1.OrderNo = '{0}'", order.OrderNo);
            }
            if (!string.IsNullOrEmpty(obj.OrderNoLike))
            {
                sql += string.Format(" AND T1.OrderNoLike LIKE '%{0}%'", obj.OrderNoLike);
            }
            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_Plan_SaleOrderItem>());
        }
Esempio n. 10
0
        public Mes_Plan_SaleOrder FindEntity(Mes_Plan_SaleOrder obj)
        {
            string sql = @"SELECT TOP 1 T1.*,T2.CustomerName FROM Mes_Plan_SaleOrder T1 WITH(NOLOCK)
                        LEFT JOIN dbo.Mes_Sys_Customer T2 WITH(NOLOCK) ON T1.CustomerID = T2.ID
                        WHERE OrderStatus<>20 ";

            if (obj.ID > 0)
            {
                sql += string.Format(" AND T1.ID = {0}", obj.ID);
            }
            if (TConvertHelper.FormatDBInt(obj.OrderType) > 0)
            {
                sql += string.Format(" AND T1.OrderType = '{0}'", obj.OrderType);
            }
            if (!string.IsNullOrEmpty(obj.OrderNo))
            {
                sql += string.Format(" AND T1.OrderNo = '{0}'", obj.OrderNo);
            }

            return(this.CurDbSession.FromSql(sql).ToFirst <Mes_Plan_SaleOrder>());
        }