From bfaf54edfc4a790a734eee889938ff06c808e6b6 Mon Sep 17 00:00:00 2001 From: hechenqingyuan <821865130@qq.com> Date: Thu, 24 Nov 2016 19:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E6=8D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Git.Storage.Provider/Bad/BadOrder.cs | 687 ++++++++++++++------------- 1 file changed, 344 insertions(+), 343 deletions(-) diff --git a/Git.Storage.Provider/Bad/BadOrder.cs b/Git.Storage.Provider/Bad/BadOrder.cs index e8ab5a2..3babd65 100644 --- a/Git.Storage.Provider/Bad/BadOrder.cs +++ b/Git.Storage.Provider/Bad/BadOrder.cs @@ -1,343 +1,344 @@ -/******************************************************************************* - * Copyright (C) Git Corporation. All rights reserved. - * - * Author: 情缘 - * Create Date: 2013-11-30 12:42:01 - * - * Description: Git.Framework - * http://www.cnblogs.com/qingyuan/ - * Revision History: - * Date Author Description - * 2013-11-30 12:42:01 情缘 -*********************************************************************************/ - -using Git.Storage.Entity.Bad; -using Git.Framework.DataTypes; -using Git.Framework.DataTypes.ExtensionMethods; -using Git.Framework.Log; -using Git.Framework.ORM; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Transactions; -using Git.Storage.Common; -using Git.Storage.Entity.Base; -using Git.Storage.Provider.Store; -using Git.Storage.Entity.Store; -using System.Data; -using Git.Storage.Provider.Base; - -namespace Git.Storage.Provider.Bad -{ - public partial class BadOrder : Bill - { - public BadOrder() { } - - - /// - /// 创建单据 - /// - /// - /// - /// - public override string Create(BadReportEntity entity, List list) - { - using (TransactionScope ts = new TransactionScope()) - { - int line = 0; - entity.OrderNum = entity.OrderNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(BadReportEntity)) : entity.OrderNum; - entity.IncludeAll(); - if (!list.IsNullOrEmpty()) - { - list.ForEach(a => - { - a.IncludeAll(); - a.OrderNum = entity.OrderNum; - }); - entity.Amount = list.Sum(q => q.Num); - entity.Amount = list.Sum(a => a.Amount); - line = this.BadReport.Add(entity); - line += this.BadReportDetail.Add(list); - } - ts.Complete(); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - } - - /// - /// 取消单据 - /// - /// - /// - public override string Cancel(BadReportEntity entity) - { - //只有待审核状态的单据才能取消,已经成功的订单不能取消 - BadReportEntity checkOrder = new BadReportEntity(); - entity.Where(a => a.Status == (int)EAudite.Wait).And(a => a.OrderNum == entity.OrderNum); - if (this.BadReport.GetCount(checkOrder) > 0) - { - return EnumHelper.GetEnumDesc(EReturnStatus.Pass); //已经审核或者取消的订单不能审核 - } - entity.Status = (int)EAudite.NotPass; - entity.IncludeStatus(true); - entity.Where(a => a.OrderNum == entity.OrderNum); - int line = this.BadReport.Update(entity); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - - /// - /// 删除单据 - /// - /// - /// - public override string Delete(BadReportEntity entity) - { - entity.IsDelete = (int)EIsDelete.Deleted; - entity.IncludeIsDelete(true); - entity.Where(a => a.OrderNum == entity.OrderNum); - int line = this.BadReport.Update(entity); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - - /// - /// 审核单据 - /// - /// - /// - public override string Audite(BadReportEntity entity) - { - if (entity.Status == (int)EAudite.NotPass) - { - entity.IncludeStatus(true).IncludeReason(true).IncludeAuditUser(true).Where(a => a.OrderNum == entity.OrderNum); - int line = this.BadReport.Update(entity); - return line > 0 ? "1000" : string.Empty; - } - else if (entity.Status == (int)EAudite.Pass) - { - Proc_AuditeBadReportEntity auditeEntity = new Proc_AuditeBadReportEntity(); - auditeEntity.OrderNum = entity.OrderNum; - auditeEntity.Status = entity.Status; - auditeEntity.AuditUser = entity.AuditUser; - auditeEntity.Reason = entity.Reason; - auditeEntity.OperateType = entity.OperateType; - auditeEntity.EquipmentNum = entity.EquipmentNum; - auditeEntity.EquipmentCode = entity.EquipmentCode; - int line = this.Proc_AuditeBadReport.ExecuteNonQuery(auditeEntity); - return auditeEntity.ReturnValue; - } - return string.Empty; - } - - /// - /// 打印单据 - /// - /// - /// - public override string Print(BadReportEntity entity) - { - entity.IncludePrintUser(true).IncludePrintTime(true) - .Where(a => a.OrderNum == entity.OrderNum); - int line = this.BadReport.Update(entity); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - - /// - /// 查询单据 - /// - /// - /// - public override BadReportEntity GetOrder(BadReportEntity entity) - { - entity.IncludeAll(); - AdminEntity admin = new AdminEntity(); - admin.Include(a => new { CreateUserName = a.UserName }); - entity.Left(admin, new Params() { Item1 = "CreateUser", Item2 = "UserCode" }); - entity.Where(a => a.OrderNum == entity.OrderNum); - entity = this.BadReport.GetSingle(entity); - return entity; - } - - /// - /// 获得单据详细信息 - /// - /// - /// - public override List GetOrderDetail(BadReportDetailEntity entity) - { - BadReportDetailEntity detail = new BadReportDetailEntity(); - detail.IncludeAll(); - detail.Where(a => a.OrderNum == entity.OrderNum); - List list = this.BadReportDetail.GetList(detail); - if (!list.IsNullOrEmpty()) - { - List listLocation = new LocationProvider().GetList(); - listLocation = listLocation == null ? new List() : listLocation; - foreach (BadReportDetailEntity item in list) - { - LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.FromLocalNum); - item.FromLocalName = location == null ? "" : location.LocalName; - - location = listLocation.FirstOrDefault(a => a.LocalNum == item.ToLocalNum); - item.ToLocalName = location == null ? "" : location.LocalName; - if (item.Amount == 0) - { - item.Amount = item.InPrice * item.Num; - } - } - } - return list; - } - - /// - /// 查询单据分页 - /// - /// - /// - /// - public override List GetList(BadReportEntity entity, ref Framework.DataTypes.PageInfo pageInfo) - { - entity.IncludeAll(); - entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); - entity.OrderBy(a => a.ID, EOrderBy.DESC); - AdminEntity admin = new AdminEntity(); - admin.Include(a => new { CreateUserName = a.UserName }); - entity.Left(admin, new Params() { Item1 = "CreateUser", Item2 = "UserCode" }); - int rowCount = 0; - List listResult = this.BadReport.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); - pageInfo.RowCount = rowCount; - return listResult; - } - - /// - /// 查询单据详细数据分页 - /// - /// - /// - /// - public override List GetDetailList(BadReportDetailEntity entity, ref Framework.DataTypes.PageInfo pageInfo) - { - BadReportDetailEntity detail = new BadReportDetailEntity(); - detail.Where(a => a.OrderNum == entity.OrderNum); - detail.IncludeAll(); - detail.OrderBy(a => a.ID, EOrderBy.DESC); - int rowCount = 0; - List listResult = this.BadReportDetail.GetList(detail, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); - pageInfo.RowCount = rowCount; - if (!listResult.IsNullOrEmpty()) - { - List listLocation = new LocationProvider().GetList(); - listLocation = listLocation == null ? new List() : listLocation; - foreach (BadReportDetailEntity item in listResult) - { - LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.FromLocalNum); - item.FromLocalName = location == null ? "" : location.LocalName; - - location = listLocation.FirstOrDefault(a => a.LocalNum == item.ToLocalNum); - item.ToLocalName = location == null ? "" : location.LocalName; - if (item.Amount == 0) - { - item.Amount = item.InPrice * item.Num; - } - } - } - return listResult; - } - - /// - /// 编辑单据信息 - /// - /// - /// - public override string EditOrder(BadReportEntity entity) - { - entity.Include(a => new { a.BadType, a.ProductType, a.ContractOrder, a.Remark, a.Amount, a.Num }); - entity.Where(a => a.OrderNum == entity.OrderNum); - int line = this.BadReport.Update(entity); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - - /// - /// 编辑单据详细信息 - /// - /// - /// - public override string EditDetail(BadReportDetailEntity entity) - { - entity.Where(a => a.SnNum == entity.SnNum); - int line = this.BadReportDetail.Update(entity); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - - /// - /// 获得订单数量 - /// - /// - /// - public override int GetCount(BadReportEntity entity) - { - return this.BadReport.GetCount(entity); - } - - /// - /// 编辑报损单 - /// - /// - /// - /// - public override string EditOrder(BadReportEntity entity, List list) - { - using (TransactionScope ts = new TransactionScope()) - { - int line = 0; - entity.Include(a => new { a.BadType, a.ProductType, a.ContractOrder, a.Remark, a.Amount, a.Num }); - entity.Where(a => a.OrderNum == entity.OrderNum); - BadReportDetailEntity detail = new BadReportDetailEntity(); - detail.Where(a => a.OrderNum == entity.OrderNum); - this.BadReportDetail.Delete(detail); - foreach (BadReportDetailEntity item in list) - { - item.OrderNum = entity.OrderNum; - item.IncludeAll(); - } - entity.Num = list.Sum(a => a.Num); - entity.Amount = list.Sum(a => a.Amount); - line = this.BadReport.Update(entity); - this.BadReportDetail.Add(list); - ts.Complete(); - return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; - } - } - - /// - /// 获得打印单据的数据源 - /// - /// - /// - public override DataSet GetPrint(string argOrderNum) - { - DataSet ds = new DataSet(); - BadReportEntity entity = new BadReportEntity(); - entity.OrderNum = argOrderNum; - entity = GetOrder(entity); - if (entity != null) - { - List list = new List(); - list.Add(entity); - DataTable tableOrder = list.ToDataTable(); - ds.Tables.Add(tableOrder); - - BadReportDetailEntity detail = new BadReportDetailEntity(); - detail.OrderNum = argOrderNum; - List listDetail = GetOrderDetail(detail); - if (!listDetail.IsNullOrEmpty()) - { - DataTable tableDetail = listDetail.ToDataTable(); - ds.Tables.Add(tableDetail); - } - } - - return ds; - } - } -} +/******************************************************************************* + * Copyright (C) Git Corporation. All rights reserved. + * + * Author: 情缘 + * Create Date: 2013-11-30 12:42:01 + * + * Description: Git.Framework + * http://www.cnblogs.com/qingyuan/ + * Revision History: + * Date Author Description + * 2013-11-30 12:42:01 情缘 +*********************************************************************************/ + + +using Git.Storage.Entity.Bad; +using Git.Framework.DataTypes; +using Git.Framework.DataTypes.ExtensionMethods; +using Git.Framework.Log; +using Git.Framework.ORM; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Transactions; +using Git.Storage.Common; +using Git.Storage.Entity.Base; +using Git.Storage.Provider.Store; +using Git.Storage.Entity.Store; +using System.Data; +using Git.Storage.Provider.Base; + +namespace Git.Storage.Provider.Bad +{ + public partial class BadOrder : Bill + { + public BadOrder() { } + + + /// + /// 创建单据 + /// + /// + /// + /// + public override string Create(BadReportEntity entity, List list) + { + using (TransactionScope ts = new TransactionScope()) + { + int line = 0; + entity.OrderNum = entity.OrderNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(BadReportEntity)) : entity.OrderNum; + entity.IncludeAll(); + if (!list.IsNullOrEmpty()) + { + list.ForEach(a => + { + a.IncludeAll(); + a.OrderNum = entity.OrderNum; + }); + entity.Amount = list.Sum(q => q.Num); + entity.Amount = list.Sum(a => a.Amount); + line = this.BadReport.Add(entity); + line += this.BadReportDetail.Add(list); + } + ts.Complete(); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + } + + /// + /// 取消单据 + /// + /// + /// + public override string Cancel(BadReportEntity entity) + { + //只有待审核状态的单据才能取消,已经成功的订单不能取消 + BadReportEntity checkOrder = new BadReportEntity(); + entity.Where(a => a.Status == (int)EAudite.Wait).And(a => a.OrderNum == entity.OrderNum); + if (this.BadReport.GetCount(checkOrder) > 0) + { + return EnumHelper.GetEnumDesc(EReturnStatus.Pass); //已经审核或者取消的订单不能审核 + } + entity.Status = (int)EAudite.NotPass; + entity.IncludeStatus(true); + entity.Where(a => a.OrderNum == entity.OrderNum); + int line = this.BadReport.Update(entity); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + + /// + /// 删除单据 + /// + /// + /// + public override string Delete(BadReportEntity entity) + { + entity.IsDelete = (int)EIsDelete.Deleted; + entity.IncludeIsDelete(true); + entity.Where(a => a.OrderNum == entity.OrderNum); + int line = this.BadReport.Update(entity); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + + /// + /// 审核单据 + /// + /// + /// + public override string Audite(BadReportEntity entity) + { + if (entity.Status == (int)EAudite.NotPass) + { + entity.IncludeStatus(true).IncludeReason(true).IncludeAuditUser(true).Where(a => a.OrderNum == entity.OrderNum); + int line = this.BadReport.Update(entity); + return line > 0 ? "1000" : string.Empty; + } + else if (entity.Status == (int)EAudite.Pass) + { + Proc_AuditeBadReportEntity auditeEntity = new Proc_AuditeBadReportEntity(); + auditeEntity.OrderNum = entity.OrderNum; + auditeEntity.Status = entity.Status; + auditeEntity.AuditUser = entity.AuditUser; + auditeEntity.Reason = entity.Reason; + auditeEntity.OperateType = entity.OperateType; + auditeEntity.EquipmentNum = entity.EquipmentNum; + auditeEntity.EquipmentCode = entity.EquipmentCode; + int line = this.Proc_AuditeBadReport.ExecuteNonQuery(auditeEntity); + return auditeEntity.ReturnValue; + } + return string.Empty; + } + + /// + /// 打印单据 + /// + /// + /// + public override string Print(BadReportEntity entity) + { + entity.IncludePrintUser(true).IncludePrintTime(true) + .Where(a => a.OrderNum == entity.OrderNum); + int line = this.BadReport.Update(entity); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + + /// + /// 查询单据 + /// + /// + /// + public override BadReportEntity GetOrder(BadReportEntity entity) + { + entity.IncludeAll(); + AdminEntity admin = new AdminEntity(); + admin.Include(a => new { CreateUserName = a.UserName }); + entity.Left(admin, new Params() { Item1 = "CreateUser", Item2 = "UserCode" }); + entity.Where(a => a.OrderNum == entity.OrderNum); + entity = this.BadReport.GetSingle(entity); + return entity; + } + + /// + /// 获得单据详细信息 + /// + /// + /// + public override List GetOrderDetail(BadReportDetailEntity entity) + { + BadReportDetailEntity detail = new BadReportDetailEntity(); + detail.IncludeAll(); + detail.Where(a => a.OrderNum == entity.OrderNum); + List list = this.BadReportDetail.GetList(detail); + if (!list.IsNullOrEmpty()) + { + List listLocation = new LocationProvider().GetList(); + listLocation = listLocation == null ? new List() : listLocation; + foreach (BadReportDetailEntity item in list) + { + LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.FromLocalNum); + item.FromLocalName = location == null ? "" : location.LocalName; + + location = listLocation.FirstOrDefault(a => a.LocalNum == item.ToLocalNum); + item.ToLocalName = location == null ? "" : location.LocalName; + if (item.Amount == 0) + { + item.Amount = item.InPrice * item.Num; + } + } + } + return list; + } + + /// + /// 查询单据分页 + /// + /// + /// + /// + public override List GetList(BadReportEntity entity, ref Framework.DataTypes.PageInfo pageInfo) + { + entity.IncludeAll(); + entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); + entity.OrderBy(a => a.ID, EOrderBy.DESC); + AdminEntity admin = new AdminEntity(); + admin.Include(a => new { CreateUserName = a.UserName }); + entity.Left(admin, new Params() { Item1 = "CreateUser", Item2 = "UserCode" }); + int rowCount = 0; + List listResult = this.BadReport.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); + pageInfo.RowCount = rowCount; + return listResult; + } + + /// + /// 查询单据详细数据分页 + /// + /// + /// + /// + public override List GetDetailList(BadReportDetailEntity entity, ref Framework.DataTypes.PageInfo pageInfo) + { + BadReportDetailEntity detail = new BadReportDetailEntity(); + detail.Where(a => a.OrderNum == entity.OrderNum); + detail.IncludeAll(); + detail.OrderBy(a => a.ID, EOrderBy.DESC); + int rowCount = 0; + List listResult = this.BadReportDetail.GetList(detail, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); + pageInfo.RowCount = rowCount; + if (!listResult.IsNullOrEmpty()) + { + List listLocation = new LocationProvider().GetList(); + listLocation = listLocation == null ? new List() : listLocation; + foreach (BadReportDetailEntity item in listResult) + { + LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.FromLocalNum); + item.FromLocalName = location == null ? "" : location.LocalName; + + location = listLocation.FirstOrDefault(a => a.LocalNum == item.ToLocalNum); + item.ToLocalName = location == null ? "" : location.LocalName; + if (item.Amount == 0) + { + item.Amount = item.InPrice * item.Num; + } + } + } + return listResult; + } + + /// + /// 编辑单据信息 + /// + /// + /// + public override string EditOrder(BadReportEntity entity) + { + entity.Include(a => new { a.BadType, a.ProductType, a.ContractOrder, a.Remark, a.Amount, a.Num }); + entity.Where(a => a.OrderNum == entity.OrderNum); + int line = this.BadReport.Update(entity); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + + /// + /// 编辑单据详细信息 + /// + /// + /// + public override string EditDetail(BadReportDetailEntity entity) + { + entity.Where(a => a.SnNum == entity.SnNum); + int line = this.BadReportDetail.Update(entity); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + + /// + /// 获得订单数量 + /// + /// + /// + public override int GetCount(BadReportEntity entity) + { + return this.BadReport.GetCount(entity); + } + + /// + /// 编辑报损单 + /// + /// + /// + /// + public override string EditOrder(BadReportEntity entity, List list) + { + using (TransactionScope ts = new TransactionScope()) + { + int line = 0; + entity.Include(a => new { a.BadType, a.ProductType, a.ContractOrder, a.Remark, a.Amount, a.Num }); + entity.Where(a => a.OrderNum == entity.OrderNum); + BadReportDetailEntity detail = new BadReportDetailEntity(); + detail.Where(a => a.OrderNum == entity.OrderNum); + this.BadReportDetail.Delete(detail); + foreach (BadReportDetailEntity item in list) + { + item.OrderNum = entity.OrderNum; + item.IncludeAll(); + } + entity.Num = list.Sum(a => a.Num); + entity.Amount = list.Sum(a => a.Amount); + line = this.BadReport.Update(entity); + this.BadReportDetail.Add(list); + ts.Complete(); + return line > 0 ? EnumHelper.GetEnumDesc(EReturnStatus.Success) : string.Empty; + } + } + + /// + /// 获得打印单据的数据源 + /// + /// + /// + public override DataSet GetPrint(string argOrderNum) + { + DataSet ds = new DataSet(); + BadReportEntity entity = new BadReportEntity(); + entity.OrderNum = argOrderNum; + entity = GetOrder(entity); + if (entity != null) + { + List list = new List(); + list.Add(entity); + DataTable tableOrder = list.ToDataTable(); + ds.Tables.Add(tableOrder); + + BadReportDetailEntity detail = new BadReportDetailEntity(); + detail.OrderNum = argOrderNum; + List listDetail = GetOrderDetail(detail); + if (!listDetail.IsNullOrEmpty()) + { + DataTable tableDetail = listDetail.ToDataTable(); + ds.Tables.Add(tableDetail); + } + } + + return ds; + } + } +}