public ActionResult Create(int Id) { PurchasePlanType plan = NSession.Get <PurchasePlanType>(Id); ViewData["plan"] = plan; return(View()); }
public JsonResult DeleteConfirmed(int id) { try { PlanDaoType obj = GetById(id); PurchasePlanType plan = NSession.Get <PurchasePlanType>(obj.PlanId); if (plan != null) { plan.Status = "已发货"; plan.DaoQty = plan.DaoQty - obj.RealQty; NSession.Update(plan); NSession.Flush(); } NSession.Delete("from SKUCodeType where PlanNo='" + obj.PlanNo + "' and Code >=" + obj.SKUCode + " and Code < " + (obj.SKUCode + obj.RealQty)); NSession.Flush(); NSession.Delete(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
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 })); }
public ActionResult Edit(int id) { PurchasePlanType obj = GetById(id); ViewData["sku"] = obj.SKU; return(View(obj)); }
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 })); }
/// <summary> /// 根据Id获取 /// </summary> /// <param name="Id"></param> /// <returns></returns> public PurchasePlanType GetById(int Id) { PurchasePlanType obj = NSession.Get <PurchasePlanType>(Id); if (obj == null) { throw new Exception("返回实体为空"); } else { return(obj); } }
public JsonResult DeleteConfirmed(int id) { try { PurchasePlanType obj = GetById(id); NSession.Delete(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public JsonResult PrintSKU(int Id) { PlanDaoType obj = NSession.Get <PlanDaoType>(Id); if (obj != null) { NSession.Flush(); IList <PurchasePlanType> plans = NSession.CreateQuery("from PurchasePlanType where PlanNo=:p and SKU=:p2").SetString("p", obj.PlanNo).SetString("p2", obj.SKU).SetMaxResults(1).List <PurchasePlanType>(); PurchasePlanType plan = plans[0]; IList <SKUCodeType> list = NSession.CreateQuery("from SKUCodeType where SKU=:p1 and PlanNo=:p2 and Code >=:p3 order by Id").SetString("p1", obj.SKU). SetString("p2", obj.PlanNo).SetInt32("p3", obj.SKUCode).SetMaxResults(obj.RealQty).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] = plan.SKU; dr[1] = plan.ProductName; dr[2] = i + "/" + obj.RealQty; dr[3] = plan.BuyOn; dr[4] = plan.BuyBy; dr[5] = plan.PlanNo; dr[6] = skuCodeType.Code; dt.Rows.Add(dr); i++; } DataSet ds = new DataSet(); ds.Tables.Add(dt); if (plan.ExpectReceiveOn < (new DateTime(2000, 1, 1))) { plan.ExpectReceiveOn = new DateTime(2000, 1, 1); } 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 })); }
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)); }
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 })); }
public JsonResult Create(PurchaseTroubleType obj) { try { obj.CreateBy = CurrentUser.Realname; obj.CreateOn = DateTime.Now; obj.DealOn = Convert.ToDateTime("2000-01-01"); NSession.Save(obj); NSession.Flush(); PurchasePlanController a = new PurchasePlanController(); PurchasePlanType pu = a.GetById(obj.PurchaseId); LoggerUtil.GetPurchasePlanRecord(pu, "采购问题", "采购出现问题:" + obj.TroubleDetail, CurrentUser, NSession); } catch (Exception ee) { return(Json(new { errorMsg = "出错了" })); } return(Json(new { IsSuccess = "true" })); }
public ActionResult Create(int id) { PurchaseTroubleType obj = new PurchaseTroubleType(); PurchasePlanController a = new PurchasePlanController(); PurchasePlanType pu = a.GetById(id); obj.PurchaseId = pu.Id; obj.PurchaseCode = pu.PlanNo; obj.Qty = pu.Qty; obj.Price = pu.Price; obj.SKU = pu.SKU; obj.Supplier = pu.Suppliers; obj.LogisticsMode = pu.LogisticsMode; obj.LogisticsCode = pu.TrackCode; obj.ReceiveOn = pu.ReceiveOn; obj.Freight = pu.Freight; obj.BuyOn = pu.BuyOn; obj.Status = "未解决"; return(View(obj)); }
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(); } } }
//采购计划日志 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); }
public static string getPlanTypeText(int Status) { PurchasePlanType col = (PurchasePlanType)Status; return(col.ToString()); }