コード例 #1
0
 public JsonResult Create(PurchasePlanType obj)
 {
     try
     {
         if (obj.SendOn < Convert.ToDateTime("2000-01-01"))
         {
             obj.SendOn = Convert.ToDateTime("2000-01-01");
         }
         if (obj.ReceiveOn < Convert.ToDateTime("2000-01-01"))
         {
             obj.ReceiveOn = Convert.ToDateTime("2000-01-01");
         }
         if (obj.ReceiveOn < Convert.ToDateTime("2000-01-01"))
         {
             obj.ReceiveOn = Convert.ToDateTime("2000-01-01");
         }
         obj.CreateOn = DateTime.Now;
         obj.BuyOn = DateTime.Now;
         obj.CreateBy = CurrentUser.Realname;
         obj.BuyBy = CurrentUser.Realname;
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
         SaveSupplier(obj);
         LoggerUtil.GetPurchasePlanRecord(obj, "新建计划", "创建采购计划", CurrentUser, NSession);
     }
     catch (Exception ee)
     {
         return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
     }
     return Json(new { IsSuccess = true });
 }
コード例 #2
0
        public ActionResult ImportPlan(string fileName)
        {
            DataTable dt = OrderHelper.GetDataTable(fileName);
            IList<WarehouseType> list = NSession.CreateQuery(" from WarehouseType").List<WarehouseType>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PurchasePlanType p = new PurchasePlanType { CreateOn = DateTime.Now, BuyOn = DateTime.Now, ReceiveOn = DateTime.Now, SendOn = DateTime.Now };
                p.PlanNo = Utilities.GetPlanNo(NSession);
                p.SKU = dt.Rows[i]["SKU"].ToString();
                p.Price = Convert.ToDouble(dt.Rows[i]["单价"].ToString());
                p.Qty = Convert.ToInt32(dt.Rows[i]["Qty"].ToString());
                p.DaoQty = 0;
                p.ProductName = "";
                p.Freight = Convert.ToDouble(dt.Rows[i]["运费"].ToString());
                p.ProductUrl = dt.Rows[i]["产品链接"].ToString();
                p.PicUrl = dt.Rows[i]["图片链接"].ToString();
                p.Suppliers = dt.Rows[i]["供应商"].ToString();
                p.LogisticsMode = dt.Rows[i]["发货方式"].ToString();
                p.TrackCode = dt.Rows[i]["追踪码"].ToString();
                p.Status = dt.Rows[i]["状态"].ToString();
                p.Memo = dt.Rows[i]["备注"].ToString();

                NSession.Save(p);
                NSession.Flush();


            }
            return Json(new { IsSuccess = true });
        }
コード例 #3
0
 public ActionResult CreateByW(string Id)
 {
     ViewData["No"] = Utilities.GetPlanNo(NSession);
     IList<PurchasePlanType> obj =
           NSession.CreateQuery("from PurchasePlanType where SKU=:sku order by Id desc").SetString("sku", Id)
               .SetFirstResult(0)
               .SetMaxResults(1).List<PurchasePlanType>();
     if (obj.Count > 0)
     {
         return View(obj[0]);
     }
     PurchasePlanType p = new PurchasePlanType();
     p.SKU = Id;
     return View(p);
 }
コード例 #4
0
  //采购计划日志
 public static void GetPurchasePlanRecord(PurchasePlanType obj, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     GetPurchasePlanRecord(obj.Id, obj.PlanNo, obj.SKU, recordType, Content, CurrentUser, NSession);
 }
コード例 #5
0
        public ActionResult Edit(PurchasePlanType obj)
        {

            try
            {
                string str = "";
                PurchasePlanType obj2 = GetById(obj.Id);
                str += Utilities.GetObjEditString(obj2, obj) + "<br>";
                NSession.Clear();
                NSession.Update(obj);
                NSession.Flush();
                LoggerUtil.GetPurchasePlanRecord(obj, "修改采购计划", str, CurrentUser, NSession);
            }
            catch (Exception ee)
            {
                return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
            }
            return Json(new { IsSuccess = true });

        }
コード例 #6
0
 private void SaveSupplier(PurchasePlanType obj)
 {
     object exit = NSession.CreateQuery("from SupplierType where SuppliersName='"+obj.Suppliers+"'").UniqueResult();
     if (exit==null)
     {
         SupplierType super = new SupplierType
         {
             SuppliersName = obj.Suppliers
         };
         NSession.Save(super);
         NSession.Flush();
         SuppliersProductType product = new SuppliersProductType
         {
             SId = super.Id,
             SKU = obj.SKU,
             Price = obj.Price,
             Web = obj.ProductUrl
         };
         NSession.Save(product);
         NSession.Flush();
     }
     else
     {
         IList<SupplierType> list = NSession.CreateQuery("from SupplierType where SuppliersName='" + obj.Suppliers + "'").List<SupplierType>();
         object productexit = NSession.CreateQuery("from SuppliersProductType where SId='" +list[0].Id+ "' and SKU='"+obj.SKU+"' ").UniqueResult();
         if (productexit == null)
         {
             SuppliersProductType product = new SuppliersProductType
             {
                 SId = list[0].Id,
                 SKU = obj.SKU,
                 Price = obj.Price,
                 Web = obj.ProductUrl
             };
             NSession.Save(product);
             NSession.Flush();
         }
     }
 }