/// <summary> /// 根据唯一编号删除入库单 /// </summary> /// <returns></returns> public ActionResult DeleteSingle() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); string SnNum = WebUtil.GetFormValue <string>("SnNum", string.Empty); InStorageEntity entity = new InStorageEntity(); entity.CompanyID = CompanyID; entity.SnNum = SnNum; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.Delete(entity); DataResult result = new DataResult(); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "入库单删除成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单删除失败"; } return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult Edit() { Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = null; string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; entity = bill.GetOrder(entity); entity = entity == null ? new InStorageEntity() : entity; entity.InTypeLable = EnumHelper.GetEnumDesc <EInType>(entity.InType); entity.StatusLable = EnumHelper.GetEnumDesc <EAudite>(entity.Status); ViewBag.InStorage = entity; ViewBag.InType = EnumHelper.GetOptions <EInType>(entity.InType, "请选择入库单类型"); ViewBag.ProductType = EnumHelper.GetOptions <EProductType>(entity.Status, "请选择入库产品类型"); InStorDetailEntity detail = new InStorDetailEntity(); detail.OrderNum = orderNum; List <InStorDetailEntity> list = bill.GetOrderDetail(detail); list = list == null ? new List <InStorDetailEntity>() : list; if (list.IsNullOrEmpty() == false) { foreach (InStorDetailEntity item in list) { item.Size = item.Size.IsEmpty() ? "" : item.Size; item.Amount = item.Amount == 0 ? item.InPrice * item.Num : item.Amount; item.TotalPrice = item.Amount; } Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = list; } ViewBag.Detail = list; return(View()); }
/// <summary> /// 入库单打印的数据写入 /// </summary> /// <returns></returns> public ActionResult Print() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string PrintUser = WebUtil.GetFormValue <string>("PrintUser"); DateTime PrintTime = WebUtil.GetFormValue <DateTime>("PrintTime"); string SnNum = WebUtil.GetFormValue <string>("SnNum"); InStorageEntity entity = new InStorageEntity(); entity.SnNum = SnNum; entity.PrintUser = PrintUser; entity.PrintTime = PrintTime; entity.CompanyID = CompanyID; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.Print(entity); DataResult result = new DataResult(); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "打印数据设置成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "打印数据设置失败"; } return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 新增入库单 /// </summary> /// <returns></returns> public ActionResult Create() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); InStorageEntity entity = WebUtil.GetFormObject <InStorageEntity>("Entity"); List <InStorDetailEntity> list = WebUtil.GetFormObject <List <InStorDetailEntity> >("List"); entity.SnNum = ConvertHelper.NewGuid(); entity.ProductType = (int)EProductType.Goods; entity.Status = (int)EAudite.Wait; entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.CompanyID = entity.CompanyID.IsEmpty() ? CompanyID : entity.CompanyID; entity.EquipmentNum = ""; entity.EquipmentCode = ""; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.Create(entity, list); DataResult result = new DataResult(); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "入库单创建成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单创建失败"; } return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult Create() { int InType = WebUtil.GetFormValue <int>("InType", 0); int ProductType = WebUtil.GetFormValue <int>("ProductType", 0); string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty); string SupNum = WebUtil.GetFormValue <string>("SupNum", string.Empty); string SupName = WebUtil.GetFormValue <string>("SupName", string.Empty); string ContactName = WebUtil.GetFormValue <string>("ContactName", string.Empty); string Phone = WebUtil.GetFormValue <string>("Phone", string.Empty); DateTime OrderTime = WebUtil.GetFormValue <DateTime>("OrderTime", DateTime.Now); string Remark = WebUtil.GetFormValue <string>("Remark", string.Empty); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = SequenceProvider.GetSequence(typeof(InStorageEntity)); entity.InType = InType; entity.ProductType = ProductType; entity.SupNum = SupNum; entity.SupName = SupName; entity.ContactName = ContactName; entity.Phone = Phone; entity.Address = ""; entity.ContractOrder = ContractOrder; entity.Status = (int)EAudite.Wait; entity.IsDelete = (int)EIsDelete.NotDelete; entity.OrderTime = OrderTime; entity.CreateTime = DateTime.Now; entity.CreateUser = this.LoginUserCode; entity.AuditUser = string.Empty; entity.AuditeTime = DateTime.MinValue; entity.PrintUser = string.Empty; entity.PrintTime = DateTime.MinValue; entity.Reason = string.Empty; entity.OperateType = (int)EOpType.PC; entity.EquipmentNum = string.Empty; entity.EquipmentCode = string.Empty; entity.Remark = Remark; entity.StorageNum = this.DefaultStore; List <InStorDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] as List <InStorDetailEntity>; if (list.IsNullOrEmpty()) { this.ReturnJson.AddProperty("Key", "1001"); this.ReturnJson.AddProperty("Value", "请选择要入库的产品以及数量"); return(Content(this.ReturnJson.ToString())); } entity.Num = list.Sum(a => a.Num); entity.Amount = list.Sum(a => a.Amount); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); string returnValue = bill.Create(entity, list); if (returnValue == EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success)) { Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = null; this.ReturnJson.AddProperty("Key", "1000"); this.ReturnJson.AddProperty("Value", "入库单创建成功"); } return(Content(this.ReturnJson.ToString())); }
public ActionResult GetList() { int status = WebUtil.GetFormValue <int>("Status", 0); string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string supName = WebUtil.GetFormValue <string>("SupName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); int pageSize = WebUtil.GetFormValue <int>("PageSize", 10); int pageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int InType = WebUtil.GetFormValue <int>("InType", 0); string planNum = WebUtil.GetFormValue <string>("planNum", string.Empty); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; InStorageEntity entity = new InStorageEntity(); if (status > 0) { entity.Where(a => a.Status == status); } if (!orderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); } if (!supName.IsEmpty()) { entity.AndBegin <InStorageEntity>() .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%") .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%") .End <InStorageEntity>() ; } 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 (InType > 0) { entity.And(a => a.InType == InType); } if (!planNum.IsEmpty()) { entity.And("ContractOrder", ECondition.Like, "%" + planNum + "%"); } Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <InStorageEntity>() : listResult; string json = ConvertJson.ListToJson <InStorageEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", json); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
public ActionResult Delete() { string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); if (!orderNum.IsEmpty()) { Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; string returnValue = bill.Delete(entity); this.ReturnJson.AddProperty("d", returnValue); } return(Content(this.ReturnJson.ToString())); }
public ActionResult DeleteBatch([ModelBinder(typeof(JsonBinder <List <string> >))] List <string> list) { if (!list.IsNullOrEmpty()) { foreach (string orderNum in list) { Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; string returnValue = bill.Delete(entity); this.ReturnJson.AddProperty("d", returnValue); } } return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 查询入库单分页列表 /// </summary> /// <returns></returns> public ActionResult GetOrderList() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int PageSize = WebUtil.GetFormValue <int>("PageSize", 10); string OrderNum = WebUtil.GetFormValue <string>("OrderNum"); int InType = WebUtil.GetFormValue <int>("InType", 0); string SupNum = WebUtil.GetFormValue <string>("SupNum"); string SupName = WebUtil.GetFormValue <string>("SupName"); string Phone = WebUtil.GetFormValue <string>("Phone"); string StorageNum = WebUtil.GetFormValue <string>("StorageNum"); string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder"); int Status = WebUtil.GetFormValue <int>("Status", 0); string BeginTime = WebUtil.GetFormValue <string>("BeginTime"); string EndTime = WebUtil.GetFormValue <string>("EndTime"); InStorageEntity entity = new InStorageEntity(); entity.CompanyID = CompanyID; entity.OrderNum = OrderNum; entity.InType = InType; entity.SupNum = SupNum; entity.SupName = SupName; entity.Phone = Phone; entity.StorageNum = StorageNum; entity.ContractOrder = ContractOrder; entity.Status = Status; entity.BeginTime = BeginTime; entity.EndTime = EndTime; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); PageInfo pageInfo = new PageInfo() { PageIndex = PageIndex, PageSize = PageSize }; List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo); DataListResult <InStorageEntity> dataResult = new DataListResult <InStorageEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = listResult, PageInfo = pageInfo }; return(Content(JsonHelper.SerializeObject(dataResult))); }
/// <summary> /// 审核入库单 /// </summary> /// <returns></returns> public ActionResult Audite() { string SnNum = WebUtil.GetFormValue <string>("SnNum"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); int Status = WebUtil.GetFormValue <int>("Status", (int)EAudite.NotPass); string AuditUser = WebUtil.GetFormValue <string>("AuditUser", string.Empty); string Reason = WebUtil.GetFormValue <string>("Reason", string.Empty); int OperateType = WebUtil.GetFormValue <int>("OperateType", 0); string EquipmentNum = WebUtil.GetFormValue <string>("EquipmentNum"); string EquipmentCode = WebUtil.GetFormValue <string>("EquipmentCode"); string Remark = WebUtil.GetFormValue <string>("Remark"); InStorageEntity entity = new InStorageEntity(); entity.SnNum = SnNum; entity.CompanyID = CompanyID; entity.Status = Status; entity.AuditUser = AuditUser; entity.Reason = Reason; entity.OperateType = OperateType; entity.EquipmentNum = EquipmentNum; entity.EquipmentCode = EquipmentCode; entity.Remark = Remark; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.Audite(entity); DataResult result = new DataResult(); if ("1000" == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "操作成功"; } else if ("1001" == returnValue) { result.Code = (int)EResponseCode.Exception; result.Message = "入库单不存在"; } else if ("1002" == returnValue) { result.Code = (int)EResponseCode.Exception; result.Message = "入库单已经审核"; } return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 根据入库单唯一编号查询入库单 /// </summary> /// <returns></returns> public ActionResult GetOrder() { string SnNum = WebUtil.GetFormValue <string>("SnNum"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); InStorageEntity entity = new InStorageEntity(); entity.SnNum = SnNum; entity.CompanyID = CompanyID; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); InStorageEntity result = bill.GetOrder(entity); DataResult <InStorageEntity> dataResult = new DataResult <InStorageEntity>(); dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "响应成功"; dataResult.Result = result; return(Content(JsonHelper.SerializeObject(dataResult))); }
public ActionResult Audite() { string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); int status = WebUtil.GetFormValue <int>("Status", 0); string reason = WebUtil.GetFormValue <string>("Reason", string.Empty); InStorageEntity entity = new InStorageEntity(); entity.Status = status; entity.OrderNum = orderNum; entity.AuditUser = this.LoginUserCode; entity.OperateType = (int)EOpType.PC; entity.EquipmentCode = string.Empty; entity.EquipmentNum = string.Empty; entity.Remark = string.Empty; entity.Reason = reason; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); string returnValue = bill.Audite(entity); this.ReturnJson.AddProperty("d", returnValue); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 编辑入库单的主体 /// </summary> /// <returns></returns> public ActionResult EditOrder() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); InStorageEntity entity = WebUtil.GetFormObject <InStorageEntity>("Entity"); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.EditOrder(entity); DataResult result = new DataResult(); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "入库单主体编辑成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单主体编辑失败"; } return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 根据入库单编号查询入库单 /// </summary> /// <returns></returns> public InStorageEntity GetOrderByNum(string OrderNum) { InStorageEntity entity = new InStorageEntity(); 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" }); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And(a => a.CompanyID == this.CompanyID) .And(a => a.OrderNum == OrderNum); entity = this.InStorage.GetSingle(entity); return(entity); }
/// <summary> /// 统计入库单数据行 /// </summary> /// <returns></returns> public ActionResult GetCount() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string OrderNum = WebUtil.GetFormValue <string>("OrderNum"); int InType = WebUtil.GetFormValue <int>("InType", 0); string SupNum = WebUtil.GetFormValue <string>("SupNum"); string SupName = WebUtil.GetFormValue <string>("SupName"); string Phone = WebUtil.GetFormValue <string>("Phone"); string StorageNum = WebUtil.GetFormValue <string>("StorageNum"); string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder"); int Status = WebUtil.GetFormValue <int>("Status", 0); string BeginTime = WebUtil.GetFormValue <string>("BeginTime"); string EndTime = WebUtil.GetFormValue <string>("EndTime"); InStorageEntity entity = new InStorageEntity(); entity.CompanyID = CompanyID; entity.OrderNum = OrderNum; entity.InType = InType; entity.SupNum = SupNum; entity.SupName = SupName; entity.Phone = Phone; entity.StorageNum = StorageNum; entity.ContractOrder = ContractOrder; entity.Status = Status; entity.BeginTime = BeginTime; entity.EndTime = EndTime; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); int Count = bill.GetCount(entity); DataResult <int> dataResult = new DataResult <int>(); dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "响应成功"; dataResult.Result = Count; return(Content(JsonHelper.SerializeObject(dataResult))); }
public ActionResult Detail() { string SnNum = WebUtil.GetQueryStringValue <string>("SnNum"); InStorageEntity entity = null; if (!SnNum.IsEmpty()) { ITopClient client = new TopClientDefault(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("CompanyID", CompanyID); dic.Add("SnNum", SnNum); string result = client.Execute(InStorageApiName.InStorageApiName_GetOrder, dic); DataResult <InStorageEntity> dataResult = JsonConvert.DeserializeObject <DataResult <InStorageEntity> >(result); entity = dataResult.Result; } entity = entity.IsNull() ? new InStorageEntity() : entity; ViewBag.Entity = entity; return(View()); }
public ActionResult Add() { InStorageEntity entity = WebUtil.GetFormObject <InStorageEntity>("Entity"); List <InStorDetailEntity> listDetail = Session[SessionKey.SESSION_INSTORAGE_DETAIL] as List <InStorDetailEntity>; string CompanyID = this.CompanyID; if (listDetail.IsNullOrEmpty()) { DataResult <string> dataResult = new DataResult <string>() { Code = (int)EResponseCode.Exception, Message = "请选择要入库的产品" }; return(Content(JsonHelper.SerializeObject(dataResult))); } string ApiName = InStorageApiName.InStorageApiName_Add; if (!entity.SnNum.IsEmpty()) { ApiName = InStorageApiName.InStorageApiName_Edit; } entity.CreateUser = this.LoginUser.UserNum; entity.CreateTime = DateTime.Now; entity.IsDelete = (int)EIsDelete.NotDelete; entity.Status = (int)EAudite.Wait; entity.StorageNum = this.DefaultStorageNum; Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("CompanyID", CompanyID); dic.Add("Entity", JsonConvert.SerializeObject(entity)); dic.Add("List", JsonConvert.SerializeObject(listDetail)); ITopClient client = new TopClientDefault(); string result = client.Execute(ApiName, dic); return(Content(result)); }
public ActionResult Add() { string SnNum = WebUtil.GetQueryStringValue <string>("SnNum"); InStorageEntity entity = null; List <InStorDetailEntity> list = null; if (!SnNum.IsEmpty()) { ITopClient client = new TopClientDefault(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("CompanyID", CompanyID); dic.Add("SnNum", SnNum); string result = client.Execute(InStorageApiName.InStorageApiName_GetOrder, dic); DataResult <InStorageEntity> dataResult = JsonConvert.DeserializeObject <DataResult <InStorageEntity> >(result); entity = dataResult.Result; result = client.Execute(InStorageApiName.InStorageApiName_GetDetail, dic); DataResult <List <InStorDetailEntity> > dataList = JsonConvert.DeserializeObject <DataResult <List <InStorDetailEntity> > >(result); list = dataList.Result; } if (entity == null) { entity = new InStorageEntity(); entity.CreateUser = this.LoginUser.UserNum; entity.CreateUserName = this.LoginUser.UserName; entity.OrderTime = DateTime.Now; } ViewBag.Entity = entity; list = list.IsNull() ? new List <InStorDetailEntity>() : list; Session[SessionKey.SESSION_INSTORAGE_DETAIL] = list; ViewBag.InType = EnumHelper.GetOptions <EInType>(entity.InType); return(View()); }
/// <summary> /// 编辑入库单详细数量 /// </summary> /// <param name="snNum"></param> /// <param name="num"></param> /// <returns></returns> public int EditInOrderNum(string snNum, double num) { InStorDetailEntity detail = new InStorDetailEntity(); detail = new InStorDetailEntity(); detail.Include(a => new { a.OrderNum, a.Num, a.InPrice }); detail.Where(a => a.SnNum == snNum); detail = this.InStorDetail.GetSingle(detail); int line = 0; if (detail != null) { InStorDetailEntity editEntity = new InStorDetailEntity(); editEntity.IncludeNum(true).IncludeAmount(true); editEntity.Num = num; editEntity.Amount = num * detail.InPrice; editEntity.Where(a => a.SnNum == snNum); line = this.InStorDetail.Update(editEntity); string orderNum = detail.OrderNum; detail = new InStorDetailEntity(); detail.IncludeNum(true).IncludeAmount(true); detail.Where(a => a.OrderNum == orderNum); List <InStorDetailEntity> list = this.InStorDetail.GetList(detail); double total = list.Sum(a => a.Num); double amount = list.Sum(a => a.Amount); InStorageEntity entity = new InStorageEntity(); entity.Num = total; entity.Amount = amount; entity.IncludeNum(true).IncludeAmount(true); entity.Where(a => a.OrderNum == orderNum); line += this.InStorage.Update(entity); } return(line); }
/// <summary> /// 获得某个供应商的所有订购产品数量 /// </summary> /// <param name="supNum"></param> /// <param name="queryTime"></param> /// <param name="storageNum"></param> /// <returns></returns> public double GetNumBySupNum(string supNum, int queryTime, string storageNum) { InStorageEntity entity = new InStorageEntity(); entity.IncludeNum(true); entity.Where("CreateTime", ECondition.Between, DateTime.Now.AddDays(-queryTime), DateTime.Now); entity.And("StorageNum", ECondition.Eth, storageNum); entity.And("SupNum", ECondition.Eth, supNum); entity.And("Status", ECondition.Eth, (int)EAudite.Pass); entity.And("IsDelete", ECondition.Eth, (int)EIsDelete.NotDelete); double allNum = 0; try { allNum = this.InStorage.Sum <double>(entity); } catch (Exception e) { allNum = 0; log.Info(e.Message); } return(allNum); }
public static InStorage_CE ToCE(InStorageEntity item) { InStorage_CE target = new InStorage_CE(); target.ID = item.ID; target.OrderNum = item.OrderNum; target.InType = item.InType; target.ProductType = item.ProductType; target.SupNum = item.SupNum; target.SupName = item.SupName; target.ContactName = item.ContactName; target.Phone = item.Phone; target.Address = item.Address; target.ContractOrder = item.ContractOrder; target.ContractType = item.ContractType; target.Status = item.Status; target.IsDelete = item.IsDelete; target.Num = item.Num; target.Amount = item.Amount; target.NetWeight = item.NetWeight; target.GrossWeight = item.GrossWeight; target.OrderTime = item.OrderTime; target.CreateTime = item.CreateTime; target.CreateUser = item.CreateUser; target.AuditUser = item.AuditUser; target.AuditeTime = item.AuditeTime; target.PrintUser = item.PrintUser; target.PrintTime = item.PrintTime; target.StoreKeeper = item.StoreKeeper; target.Reason = item.Reason; target.OperateType = item.OperateType; target.EquipmentNum = item.EquipmentNum; target.EquipmentCode = item.EquipmentCode; target.Remark = item.Remark; return(target); }
public ActionResult Detail() { string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty); string flag = WebUtil.GetQueryStringValue <string>("flag", "1"); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; entity = bill.GetOrder(entity); entity = entity == null ? new InStorageEntity(): entity; entity.InTypeLable = EnumHelper.GetEnumDesc <EInType>(entity.InType); entity.StatusLable = EnumHelper.GetEnumDesc <EAudite>(entity.Status); ViewBag.InStorage = entity; ViewBag.Flag = flag; InStorDetailEntity detail = new InStorDetailEntity(); detail.OrderNum = orderNum; List <InStorDetailEntity> list = bill.GetOrderDetail(detail); list = list == null ? new List <InStorDetailEntity>() : list; ViewBag.Detail = list; return(View()); }
/// <summary> /// 导出Excel /// </summary> /// <returns></returns> public ActionResult ToExcel() { int status = WebUtil.GetFormValue <int>("Status", 0); string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty); string supName = WebUtil.GetFormValue <string>("SupName", string.Empty); string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty); string endTime = WebUtil.GetFormValue <string>("endTime", string.Empty); int pageSize = Int32.MaxValue; int pageIndex = 1; PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; InStorageEntity entity = new InStorageEntity(); if (status > 0) { entity.Where(a => a.Status == status); } if (!orderNum.IsEmpty()) { entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); } if (!supName.IsEmpty()) { entity.AndBegin <InStorageEntity>() .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%") .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%") .End <InStorageEntity>() ; } if (!beginTime.IsEmpty() && !endTime.IsEmpty()) { entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime)); } Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo); listResult = listResult == null ? new List <InStorageEntity>() : listResult; 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("创建时间")); foreach (InStorageEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = t.OrderNum; row[1] = EnumHelper.GetEnumDesc <EInType>(t.InType); row[2] = t.SupName; row[3] = t.ContractOrder; row[4] = t.Num; row[5] = t.Amount.ToString("0.00") + " 元"; row[6] = EnumHelper.GetEnumDesc <EAudite>(t.Status); row[7] = t.CreateUserName; row[8] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType); row[9] = t.OrderTime.ToString("yyyy-MM-dd"); dt.Rows.Add(row); } 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()); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 根据采购订单转化为入库单 /// 1: 采购订单生成入库单成功 /// 1001:采购订单不存在 /// 1002:采购订单已经全部入库,请勿重新入库 /// 1003: 订单已经被取消,不能入库 /// 1004: 采购订单中不存在入库物品 /// 1005: 存在不在采购单内的货品 /// </summary> /// <param name="SnNum">采购订单唯一编号</param> /// <param name="list">要入库的内容</param> /// <param name="StorageNum">仓库编号</param> /// <param name="CreateUser">操作人编号</param> /// <returns></returns> public DataResult ToInStorage(string SnNum, List <PurchaseDetailEntity> list, string StorageNum, string CreateUser) { PurchaseEntity entity = new PurchaseEntity(); entity.SnNum = SnNum; entity = this.GetOrder(entity); DataResult result = new DataResult(); if (entity == null) { result.Code = 1001; result.Message = "采购订单不存在"; return(result); } if (entity.Status < (int)EPurchaseStatus.InTheStock) { result.Code = 1001; result.Message = "采购订单审核流程不正确,不能生成入库单"; return(result); } if (entity.Status == (int)EPurchaseStatus.AllIn) { result.Code = 1002; result.Message = "采购订单已经全部入库,请勿重新入库"; return(result); } if (entity.Status == (int)EPurchaseStatus.OrderCancel) { result.Code = 1003; result.Message = "订单已经被取消,不能入库"; return(result); } PurchaseDetailEntity detailEntity = new PurchaseDetailEntity(); detailEntity.OrderSnNum = SnNum; List <PurchaseDetailEntity> listSource = this.GetOrderDetail(detailEntity); if (listSource.IsNullOrEmpty()) { result.Code = 1004; result.Message = "采购订单中不存在入库物品"; return(result); } //检查入库产品是否在采购单内 List <PurchaseDetailEntity> listExists = new List <PurchaseDetailEntity>(); foreach (PurchaseDetailEntity item in list) { if (!listSource.Exists(a => a.SnNum == item.SnNum)) { //不存在添加到集合 listExists.Add(item); } } if (!listExists.IsNullOrEmpty()) { string content = listExists.Select(a => string.Format("[{0}]{1}", a.BarCode, a.ProductName)).ToArray().ToString(); result.Code = 1005; result.Message = content + " 不在采购订单[" + entity.OrderNum + "]中,请重新确认再入库"; return(result); } InStorageEntity InEntity = new InStorageEntity(); InEntity.SnNum = ConvertHelper.NewGuid(); InEntity.InType = (int)EInType.Purchase; InEntity.ProductType = (int)EProductType.Goods; InEntity.StorageNum = StorageNum; InEntity.SupNum = entity.SupNum; InEntity.SupSnNum = entity.SupSnNum; InEntity.SupName = entity.SupName; InEntity.ContactName = entity.Contact; InEntity.Phone = entity.Phone; InEntity.Address = entity.Address; InEntity.ContractOrder = entity.SnNum; //0 无关联 1 采购 2 出库 3退货 InEntity.ContractType = 1; InEntity.Status = (int)EAudite.Wait; InEntity.IsDelete = (int)EIsDelete.NotDelete; InEntity.CreateTime = DateTime.Now; InEntity.OrderTime = DateTime.Now; InEntity.CreateUser = CreateUser; InEntity.CompanyID = this.CompanyID; List <InStorDetailEntity> listDetail = new List <InStorDetailEntity>(); foreach (PurchaseDetailEntity item in list) { InStorDetailEntity InDetail = new InStorDetailEntity(); InDetail.SnNum = ConvertHelper.NewGuid(); InDetail.OrderSnNum = InEntity.SnNum; InDetail.ProductNum = item.ProductNum; InDetail.ProductName = item.ProductName; InDetail.BarCode = item.BarCode; InDetail.BatchNum = item.BatchNum; InDetail.Num = item.Qty; InDetail.InPrice = item.Price; InDetail.Amount = item.Qty * item.Price; InDetail.ContractOrder = item.SnNum; InDetail.CreateTime = DateTime.Now; InDetail.LocalNum = item.LocalNum; InDetail.StorageNum = StorageNum; InDetail.CreateUser = CreateUser; InDetail.CompanyID = this.CompanyID; listDetail.Add(InDetail); } string returnValue = string.Empty; using (TransactionScope ts = new TransactionScope()) { Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(this.CompanyID); returnValue = bill.Create(InEntity, listDetail); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { foreach (PurchaseDetailEntity item in list) { if (item.RealNum + item.Qty >= item.Num) { item.Status = (int)EPurchaseStatus.AllIn; item.RealNum += item.Qty; } else if ((item.RealNum + item.Qty) < item.Num && (item.RealNum + item.Qty) > 0) { item.Status = (int)EPurchaseStatus.PartialIn; item.RealNum += item.Qty; } item.Include(a => new { a.RealNum, a.Status }); item.Where(a => a.SnNum == item.SnNum); this.PurchaseDetail.Update(item); } //再次查询校验状态 detailEntity = new PurchaseDetailEntity(); detailEntity.OrderSnNum = SnNum; listSource = this.GetOrderDetail(detailEntity); if (!listSource.IsNullOrEmpty()) { if (listSource.Count(a => a.Status == (int)EPurchaseStatus.PartialIn) > 0 || (listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) < listSource.Count() && listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) > 0) ) { entity.Status = (int)EPurchaseStatus.PartialIn; } else if (listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) == listSource.Count()) { entity.Status = (int)EPurchaseStatus.AllIn; } entity.IncludeStatus(true); entity.Where(a => a.SnNum == entity.SnNum); this.Purchase.Update(entity); } result.Code = (int)EResponseCode.Success; result.Message = "入库单创建成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单创建失败"; } ts.Complete(); } return(result); }