Beispiel #1
0
 public JsonResult DoAudit(int Id)
 {
     try
     {
         StockInType obj = GetById(Id);
         obj.IsAudit = 1;
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
         IList <WarehouseStockType> list = NSession.CreateQuery(" from WarehouseStockType where WId=:p1 and SKU=:p2").SetInt32("p1", obj.WId).SetString("p2", obj.SKU).List <WarehouseStockType>();
         if (list.Count > 0)
         {
             WarehouseStockType ws = list[0];
             ws.Qty = ws.Qty + obj.Qty;
             NSession.SaveOrUpdate(ws);
             NSession.Flush();
             Utilities.SetComposeStock(obj.SKU, NSession);
             Utilities.CreateSKUCode(obj.SKU, obj.Qty, obj.Id.ToString(), NSession);
             IList <OrderType> orders = NSession.CreateQuery(" from OrderType where Id in(select OId from OrderProductType where SKU ='" + obj.SKU + "' and IsQue=1) and IsOutOfStock=1").List <OrderType>();
             foreach (OrderType item in orders)
             {
                 OrderHelper.SetQueOrder(item, NSession);
             }
         }
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Beispiel #2
0
 public JsonResult Create(StockInType obj)
 {
     try
     {
         IList <WarehouseStockType> list =
             NSession.CreateQuery(" from WarehouseStockType where WId=:p1 and SKU=:p2").SetInt32("p1", obj.WId).
             SetString("p2", obj.SKU).List <WarehouseStockType>();
         if (list.Count > 0)
         {
             obj.IsAudit  = 0;
             obj.CreateBy = CurrentUser.Realname;
             obj.CreateOn = DateTime.Now;
             NSession.SaveOrUpdate(obj);
             NSession.Flush();
         }
         else
         {
             return(Json(new { IsSuccess = false, ErrorMsg = "该产品没有在系统中。请先添加产品!" }));
         }
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Beispiel #3
0
        public ActionResult Edit(int id)
        {
            StockInType obj = GetById(id);

            ViewData["sku"] = obj.SKU;
            return(View(obj));
        }
Beispiel #4
0
 public ActionResult Edit(StockInType obj)
 {
     try
     {
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Beispiel #5
0
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public StockInType GetById(int Id)
        {
            StockInType obj = NSession.Get <StockInType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
Beispiel #6
0
        public static bool StockIn(int wid, string sku, int num, double price, string InType, string user, string memo, ISession NSession, bool isAudit = false)
        {
            IList <WarehouseStockType> list = NSession.CreateQuery(" from WarehouseStockType where WId=:p1 and SKU=:p2").SetInt32("p1", wid).SetString("p2", sku).List <WarehouseStockType>();

            if (list.Count > 0)
            {
                WarehouseStockType ws = list[0];
                ws.Qty      = ws.Qty + num;
                ws.UpdateOn = DateTime.Now;
                NSession.SaveOrUpdate(ws);
                NSession.Flush();
                SetComposeStock(sku, NSession);
                StockInType stockInType = new StockInType();
                stockInType.IsAudit = 0;
                if (isAudit)
                {
                    stockInType.IsAudit = 1;
                }
                stockInType.Price     = price;
                stockInType.Qty       = num;
                stockInType.SKU       = sku;
                stockInType.WId       = wid;
                stockInType.InType    = InType;
                stockInType.Memo      = memo;
                stockInType.WName     = ws.Warehouse;
                stockInType.SourceQty = ws.Qty - num;
                stockInType.CreateBy  = user;
                stockInType.CreateOn  = DateTime.Now;
                NSession.SaveOrUpdate(stockInType);
                NSession.Flush();

                if (price > 0)
                {
                    NSession.CreateSQLQuery(" update Products set Price=" + price + "  where  SKU='" + sku + "'")
                    .UniqueResult();
                    NSession.Flush();
                }

                IList <OrderType> orders = NSession.CreateQuery(" from OrderType where Id in(select OId from OrderProductType where SKU ='" + sku + "' and IsQue=1) and IsOutOfStock=1").List <OrderType>();
                foreach (OrderType item in orders)
                {
                    OrderHelper.SetQueOrder(item, NSession);
                }
                return(true);
            }
            return(false);
        }
Beispiel #7
0
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         StockInType obj = GetById(id);
         NSession.Delete("from SKUCodeType where PlanNo='" + obj.Id + "'");
         NSession.Flush();
         Utilities.StockOut(1, obj.SKU, obj.Qty, "入库删除", CurrentUser.Realname, "", "", NSession);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Beispiel #8
0
        public ActionResult PrintSKU(int Id)
        {
            StockInType obj = NSession.Get <StockInType>(Id);

            if (obj != null)
            {
                NSession.Flush();
                IList <SKUCodeType> list =
                    NSession.CreateQuery("from SKUCodeType where PlanNo='" + obj.Id + "'").
                    List <SKUCodeType>();
                DataTable dt = new DataTable();
                dt.Columns.Add("sku");
                dt.Columns.Add("name");
                dt.Columns.Add("num");
                dt.Columns.Add("date");
                dt.Columns.Add("people");
                dt.Columns.Add("desc");
                dt.Columns.Add("code");
                int i = 1;
                foreach (SKUCodeType skuCodeType in list)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = obj.SKU;
                    dr[1] = obj.SKU;
                    dr[2] = i + "/" + obj.Qty;
                    dr[3] = obj.CreateOn;
                    dr[4] = obj.CreateBy;
                    dr[5] = "手动入库";
                    dr[6] = skuCodeType.Code;
                    dt.Rows.Add(dr);
                    i++;
                }
                DataSet ds = new DataSet();
                ds.Tables.Add(dt);

                PrintDataType data = new PrintDataType();
                data.Content  = ds.GetXml();
                data.CreateOn = DateTime.Now;
                NSession.Save(data);
                NSession.Flush();
                return(Json(new { IsSuccess = true, Result = data.Id }));
            }
            return(Json(new { IsSuccess = false }));
        }