/// <summary> /// 修改出库单的数量 /// </summary> /// <param name="snNum"></param> /// <param name="num"></param> /// <returns></returns> public int EditInOrderNum(string snNum, double num) { OutStoDetailEntity detail = new OutStoDetailEntity(); detail = new OutStoDetailEntity(); detail.Include(a => new { a.OrderNum, a.Num, a.OutPrice, a.Amount }); detail.Where(a => a.SnNum == snNum); detail = this.OutStoDetail.GetSingle(detail); int line = 0; if (detail != null) { string orderNum = detail.OrderNum; OutStoDetailEntity editDetail = new OutStoDetailEntity(); editDetail.Num = num; editDetail.Amount = editDetail.Num * editDetail.OutPrice; editDetail.IncludeNum(true).IncludeAmount(true); editDetail.Where(a => a.SnNum == snNum); line = this.OutStoDetail.Update(editDetail); OutStoDetailEntity orderDetail = new OutStoDetailEntity(); orderDetail.Include(a => new { a.Num, a.Amount }); orderDetail.Where(a => a.OrderNum == orderNum); List <OutStoDetailEntity> list = this.OutStoDetail.GetList(orderDetail); OutStorageEntity entity = new OutStorageEntity(); entity.Num = list.Sum(a => a.Num); entity.Amount = list.Sum(a => a.Amount); entity.IncludeNum(true).IncludeAmount(true); entity.Where(a => a.OrderNum == orderNum); line += this.OutStorage.Update(entity); } return(line); }
/// <summary> /// 根据出库单编号查询出库单 /// </summary> /// <param name="OrderNum"></param> /// <returns></returns> public OutStorageEntity GetOrderByNum(string OrderNum) { OutStorageEntity entity = new OutStorageEntity(); entity.IncludeAll(); AdminEntity admin = new AdminEntity(); admin.Include(a => new { CreateUserName = a.UserName }); entity.Left <AdminEntity>(admin, new Params <string, string>() { Item1 = "CreateUser", Item2 = "UserNum" }); AdminEntity auditeAdmin = new AdminEntity(); auditeAdmin.Include(item => new { AuditeUserName = item.UserName }); entity.Left <AdminEntity>(auditeAdmin, new Params <string, string>() { Item1 = "CreateUser", Item2 = "UserNum" }); entity.Where(a => a.OrderNum == OrderNum) .And(a => a.CompanyID == this.CompanyID) .And(a => a.IsDelete == (int)EIsDelete.NotDelete) ; entity = this.OutStorage.GetSingle(entity); return(entity); }
/// <summary> /// 设置承运商 /// </summary> /// <param name="SnNum"></param> /// <param name="CarrierNum"></param> /// <param name="LogisticsNo"></param> /// <returns></returns> public int SetCarrier(string SnNum, string CarrierNum, string LogisticsNo) { CarrierProvider provider = new CarrierProvider(this.CompanyID); OutStorageEntity entity = new OutStorageEntity(); entity.CarrierNum = CarrierNum; CarrierEntity carrier = provider.GetSingle(CarrierNum); if (carrier != null) { entity.CarrierName = carrier.CarrierName; } entity.LogisticsNo = LogisticsNo; entity.Include(item => new { item.CarrierNum, item.CarrierName, item.LogisticsNo }); entity.Where(item => item.SnNum == SnNum).And(item => item.CompanyID == this.CompanyID); int line = this.OutStorage.Update(entity); return(line); }
/// <summary> /// 获得某个客户的所有订购产品数量 /// </summary> /// <param name="cusNum"></param> /// <param name="queryTime"></param> /// <returns></returns> public double GetNumByCusNum(string cusNum, int queryTime, string storageNum) { OutStorageEntity entity = new OutStorageEntity(); entity.IncludeNum(true); entity.Where("CreateTime", ECondition.Between, DateTime.Now.AddDays(-queryTime), DateTime.Now); entity.And("StorageNum", ECondition.Eth, storageNum); entity.And("CusNum", ECondition.Eth, cusNum); entity.And("Status", ECondition.Eth, (int)EAudite.Pass); entity.And("IsDelete", ECondition.Eth, (int)EIsDelete.NotDelete); double allNum = 0; try { allNum = this.OutStorage.Sum <double>(entity); } catch (Exception e) { allNum = 0; log.Info(e.Message); } return(allNum); }
public ActionResult GetList() { int Status = WebUtil.GetFormValue <int>("Status", 0); string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string CusName = WebUtil.GetFormValue <string>("CusName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); string order = WebUtil.GetFormValue <string>("order", string.Empty); int OutType = WebUtil.GetFormValue <int>("OutType", 0); string planNum = WebUtil.GetFormValue <string>("planNum"); int pageSize = WebUtil.GetFormValue <int>("PageSize", 10); int pageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; OutStorageEntity entity = new OutStorageEntity(); if (Status > 0) { entity.Where(a => a.Status == Status); } if (!OrderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%"); } if (!CusName.IsEmpty()) { entity.Begin <OutStorageEntity>() .And <OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%") .Or <OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%") .End <OutStorageEntity>() ; } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } entity.And(a => a.StorageNum == this.DefaultStore); if (!order.IsEmpty()) { OrderProvider orderProvider = new OrderProvider(); List <string> listContractOrder = orderProvider.GetOrderPlan(order); listContractOrder = listContractOrder.IsNull() ? new List <string>() : listContractOrder; if (listContractOrder.Count == 0) { listContractOrder.Add(order); } entity.And("ContractOrder", ECondition.In, listContractOrder.ToArray()); } if (OutType > 0) { entity.And(a => a.OutType == OutType); } if (!planNum.IsEmpty()) { OutStoDetailEntity detail = new OutStoDetailEntity(); detail.Where("ContractOrder", ECondition.Like, "%" + planNum + "%"); entity.Left <OutStoDetailEntity>(detail, new Params <string, string>() { Item1 = "OrderNum", Item2 = "OrderNum" }); } Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(); List <OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <OutStorageEntity>() : listResult; string json = ConvertJson.ListToJson <OutStorageEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", json); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
public ActionResult ToExcel() { int Status = WebUtil.GetFormValue <int>("Status", 0); string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string CusName = WebUtil.GetFormValue <string>("CusName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = int.MaxValue }; OutStorageEntity entity = new OutStorageEntity(); if (Status > 0) { entity.Where(a => a.Status == Status); } if (!OrderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%"); } if (!CusName.IsEmpty()) { entity.Begin <OutStorageEntity>() .And <OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%") .Or <OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%") .End <OutStorageEntity>() ; } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } entity.And(a => a.StorageNum == this.DefaultStore); Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(); List <OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <OutStorageEntity>() : listResult; if (listResult.IsNotNull()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号 ")); dt.Columns.Add(new DataColumn("出库单编号 ")); dt.Columns.Add(new DataColumn("出库类型")); dt.Columns.Add(new DataColumn("客户名称")); dt.Columns.Add(new DataColumn("关联单号")); dt.Columns.Add(new DataColumn("总数量")); dt.Columns.Add(new DataColumn("总金额")); dt.Columns.Add(new DataColumn("状态")); dt.Columns.Add(new DataColumn("制单人")); dt.Columns.Add(new DataColumn("操作方式")); dt.Columns.Add(new DataColumn("创建时间")); int count = 1; foreach (OutStorageEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.OrderNum; row[2] = EnumHelper.GetEnumDesc <EOutType>(t.OutType); row[3] = t.CusName; row[4] = t.ContractOrder; row[5] = t.Num; row[6] = t.Amount; row[7] = EnumHelper.GetEnumDesc <EAudite>(t.Status); row[8] = t.CreateUserName; row[9] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType); row[10] = t.CreateTime.ToString("yyyy-MM-dd"); dt.Rows.Add(row); count++; } string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("出库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); NPOIExcel excel = new NPOIExcel("出库管理", "出库单", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return(Content(this.ReturnJson.ToString())); }