diff --git a/CowOutputClient/SelectedProductWindow.xaml.cs b/CowOutputClient/SelectedProductWindow.xaml.cs index 33cf10b..499f33a 100644 --- a/CowOutputClient/SelectedProductWindow.xaml.cs +++ b/CowOutputClient/SelectedProductWindow.xaml.cs @@ -25,8 +25,7 @@ namespace CowOutputClient private List catalogsDetails = new List(); List detailIds = new List(); bool? useSequenceWindow = null; - //====新增:记录当前选中的分类ID,用于搜索过滤==== - private long? _currentSelectCatalogId; + public SelectedProductWindow() { InitializeComponent(); @@ -95,7 +94,7 @@ namespace CowOutputClient //先按分类筛选 IEnumerable details = catalogsDetails.Where(x => x.ProductCatalog_ID == productCatalog_ID); - //====编码模糊过滤,不区分大小写;注意:ProCataGoods编码字段名如果不是Goods_Code,请修改此处属性名==== + //====编码模糊过滤,不区分大小写; if (!string.IsNullOrWhiteSpace(searchCode)) { details = details.Where(c => c.Goods_Code != null @@ -185,6 +184,8 @@ namespace CowOutputClient } } + //====新增:记录当前选中的分类ID,用于搜索过滤==== + private long? _currentSelectCatalogId; //====新增:搜索框文本变化,执行编码模糊过滤==== private void TxtSearchCode_TextChanged(object sender, TextChangedEventArgs e) { diff --git a/WeighBusiness/BL/ProductCatalogBL.cs b/WeighBusiness/BL/ProductCatalogBL.cs index 4b4996d..32cd24a 100644 --- a/WeighBusiness/BL/ProductCatalogBL.cs +++ b/WeighBusiness/BL/ProductCatalogBL.cs @@ -47,17 +47,21 @@ namespace WeighBusiness.BL public static void Insert(List productCatalogs, List catalogDetails) { - using (var she = new SqlHelperEx()) { + using (var she = new SqlHelperEx()) + { she.CreateTransaction(); bool success = false; string errorMessage; - if (productCatalogs.Count() > 0) { - foreach (var catalog in productCatalogs) { + if (productCatalogs.Count() > 0) + { + foreach (var catalog in productCatalogs) + { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类, new string[] { "ProductCatalog_ID", "Name", "RowVersion" }, new string[] { catalog.ProductCatalog_ID.ToString(), catalog.Name, catalog.RowVersion.ToString() }); she.ExecuteNonQuery(insertSql, out success, out errorMessage); - if (!success && !string.IsNullOrEmpty(errorMessage)) { + if (!success && !string.IsNullOrEmpty(errorMessage)) + { she.Rollback(); throw new ApplicationException(errorMessage); } @@ -67,8 +71,8 @@ namespace WeighBusiness.BL if (catalogDetails.Count() > 0) { foreach (var detail in catalogDetails) { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类明细, - new string[] { "ProductCatalog_ID", "CatalogDetail_ID", "Goods_Name", "Goods_ID", "UnitConvertDirection", "MainUnitRatio", "SecondUnitRatio","Goods_Spec", "Goods_Code" }, - new string[] { detail.ProductCatalog_ID.ToString(), detail.CatalogDetail_ID.ToString(), detail.Goods_Name, detail.Goods_ID.ToString(), detail.UnitConvertDirection == null ? "null" : detail.UnitConvertDirection.ToString(), detail.MainUnitRatio == null ? "null" : detail.MainUnitRatio.ToString(), detail.SecondUnitRatio == null ? "null" : detail.SecondUnitRatio.ToString(),detail.Goods_Spec,detail.Goods_Code }); + new string[] { "ProductCatalog_ID", "CatalogDetail_ID", "Goods_Name", "Goods_ID", "UnitConvertDirection", "MainUnitRatio", "SecondUnitRatio","Goods_Spec", "Goods_Code", "Employee_Name" }, + new string[] { detail.ProductCatalog_ID.ToString(), detail.CatalogDetail_ID.ToString(), detail.Goods_Name, detail.Goods_ID.ToString(), detail.UnitConvertDirection == null ? "null" : detail.UnitConvertDirection.ToString(), detail.MainUnitRatio == null ? "null" : detail.MainUnitRatio.ToString(), detail.SecondUnitRatio == null ? "null" : detail.SecondUnitRatio.ToString(),detail.Goods_Spec,detail.Goods_Code ,detail.Employee_Name??string.Empty }); she.ExecuteNonQuery(insertSql, out success, out errorMessage); if (!success && !string.IsNullOrEmpty(errorMessage)) { she.Rollback(); @@ -108,62 +112,63 @@ namespace WeighBusiness.BL public static void SyncProductCatalog() { var domain_ID = ConfigurationManager.AppSettings["Domain_ID"]; - var method = "/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/GetProductCatalogRowVersion"; + var clientNode = ConfigurationManager.AppSettings["ClientNode"]; + var method = "/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/MewGetProductCatalogRowVersion"; if (domain_ID != null && !string.IsNullOrEmpty(domain_ID.ToString())) { - var productCatalogRowVersion = RpcFacade.Call>>(method, long.Parse(domain_ID)); + var productCatalogRowVersion = RpcFacade.Call>>(method, long.Parse(domain_ID), clientNode); Delete(); //var oldpCatalogRowVersion = GetProductCatalogRowVersion(); - var oldpCatalogRowVersion = new List(); + // var oldpCatalogRowVersion = new List(); var needInsertCatalogID = new List(); - var needDeleteAndInsertCatalogID = new List(); - if (productCatalogRowVersion.Count > 0) { - if (oldpCatalogRowVersion.Count() <= 0) { - productCatalogRowVersion.ForEach(x => needInsertCatalogID.Add(x.Item1)); - } else { - foreach (var catalogRowVersion in productCatalogRowVersion) { - var catalog_ID = catalogRowVersion.Item1; - var oldCatalogs = oldpCatalogRowVersion.Where(x => x.ProductCatalog_ID == catalog_ID); - if (oldCatalogs.Count() > 0 && oldCatalogs.FirstOrDefault().RowVersion != catalogRowVersion.Item2) { - needDeleteAndInsertCatalogID.Add(catalog_ID); - } else if (oldCatalogs.Count() <= 0) { - needInsertCatalogID.Add(catalog_ID); - } - } - - foreach (var oldVersion in oldpCatalogRowVersion) { - if (!productCatalogRowVersion.Any(x => x.Item1 == oldVersion.ProductCatalog_ID)) { - Delete(oldVersion.ProductCatalog_ID); - } - } - } - } else { + //var needDeleteAndInsertCatalogID = new List(); + if (productCatalogRowVersion.Count > 0) + { + productCatalogRowVersion.ForEach(x => needInsertCatalogID.Add(x.Item1)); + //{ } else { + //foreach (var catalogRowVersion in productCatalogRowVersion) { + // var catalog_ID = catalogRowVersion.Item1; + // var oldCatalogs = oldpCatalogRowVersion.Where(x => x.ProductCatalog_ID == catalog_ID); + // if (oldCatalogs.Count() > 0 && oldCatalogs.FirstOrDefault().RowVersion != catalogRowVersion.Item2) { + // needDeleteAndInsertCatalogID.Add(catalog_ID); + // } else if (oldCatalogs.Count() <= 0) { + // needInsertCatalogID.Add(catalog_ID); + // } + //} + //foreach (var oldVersion in oldpCatalogRowVersion) { + // if (!productCatalogRowVersion.Any(x => x.Item1 == oldVersion.ProductCatalog_ID)) { + // Delete(oldVersion.ProductCatalog_ID); + // } + //} + //} + } + else + { Delete(); } - if (needDeleteAndInsertCatalogID.Count() > 0) { - foreach (var catalogID in needDeleteAndInsertCatalogID) { - var error = Delete(catalogID.Value); - if (!string.IsNullOrEmpty(error)) { - throw new ApplicationException(error); - } - needInsertCatalogID.Add(catalogID); - } - } + //if (needDeleteAndInsertCatalogID.Count() > 0) { + // foreach (var catalogID in needDeleteAndInsertCatalogID) { + // var error = Delete(catalogID.Value); + // if (!string.IsNullOrEmpty(error)) { + // throw new ApplicationException(error); + // } + // needInsertCatalogID.Add(catalogID); + // } + //} if (needInsertCatalogID.Count > 0) { - var method2 = "/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/GetProductCatalogDetailData"; - var catalogDetails = RpcFacade.Call>(method2, needInsertCatalogID.ToArray()); + var method2 = "/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/NewGetProductCatalogDetailData"; + var catalogDetails = RpcFacade.Call>(method2, needInsertCatalogID.Distinct().ToArray(), clientNode); var list = new List(); var detailList = new List(); - foreach (var catalogID in needInsertCatalogID) { - var catalog = new ProductCatalog(); - catalog.ProductCatalog_ID = catalogID.Value; - var result = productCatalogRowVersion.Where(x => x.Item1 == catalogID).First(); - catalog.ProductCatalog_ID = result.Item1.Value; - catalog.RowVersion = result.Item2.Value; - catalog.Name = result.Item3; + + foreach (var tuple in productCatalogRowVersion) { + var catalog = new ProductCatalog(); + catalog.ProductCatalog_ID = tuple.Item1 ?? 0; + catalog.RowVersion = tuple.Item2 ?? 0; + catalog.Name = tuple.Item3; list.Add(catalog); } @@ -180,6 +185,7 @@ namespace WeighBusiness.BL catalogDetail.SecondUnitRatio = detail.Get("SecondUnitRatio"); catalogDetail.Goods_Spec = detail.Get("Goods_Spec"); catalogDetail.Goods_Code = detail.Get("Goods_Code"); + catalogDetail.Employee_Name = detail.Get("Employee_Name"); detailList.Add(catalogDetail); } } @@ -221,6 +227,7 @@ namespace WeighBusiness.BL catalog.ProductCatalog_ID = (long)(int.Parse(row[0].ToString())); catalog.Name = row[1].ToString(); catalog.Sequence = DataTypeUtil.GetIntNullNum(row[2]); + list.Add(catalog); } return list; @@ -230,7 +237,15 @@ namespace WeighBusiness.BL public static List GetProductCatalogDetails(bool? isSelected = null) { - var table = SqlHelperEx.DoQuery("select a.ProductCatalog_ID,a.CatalogDetail_ID,a.Goods_Name,a.Goods_ID,b.Goods_ID,a.UnitConvertDirection,a.MainUnitRatio,a.SecondUnitRatio,a.Goods_Spec,a.Goods_Code from {0} a left outer join {1} b on a.ProductCatalog_ID = b.ProductCatalog_ID and a.Goods_ID = b.Goods_ID where 1=1 {2}".FormatWith(TableNames.客户端产品分类明细, TableNames.客户端产品分类配制存货, isSelected == true ? "and b.Goods_ID is not null" : string.Empty)); + var table = SqlHelperEx.DoQuery(@"select a.ProductCatalog_ID,a.CatalogDetail_ID,a.Goods_Name,a.Goods_ID,b.Goods_ID,a.UnitConvertDirection, + a.MainUnitRatio,a.SecondUnitRatio,a.Goods_Spec,a.Goods_Code ,a.Employee_Name + from {0} a + left outer join {1} b on a.ProductCatalog_ID = b.ProductCatalog_ID and a.Goods_ID = b.Goods_ID and a.Employee_Name = b.Employee_Name + where a.Employee_Name ='{2}' {3}".FormatWith( + TableNames.客户端产品分类明细, + TableNames.客户端产品分类配制存货, + UserBL.CurrentUser.ERP_User_Name, + isSelected == true ? "and b.Goods_ID is not null" : string.Empty)); if (table.Rows.Count == 0) return new List(); var list = new List(); @@ -246,6 +261,7 @@ namespace WeighBusiness.BL catalog.SecondUnitRatio = DataTypeUtil.GetDecimalNullNum(row[7]); catalog.Goods_Spec = DataTypeUtil.ToStringEmptyIfNull(row[8]); catalog.Goods_Code = DataTypeUtil.ToStringEmptyIfNull(row[9]); + catalog.Employee_Name = DataTypeUtil.ToStringEmptyIfNull(row[10]); list.Add(catalog); } return list; @@ -261,8 +277,8 @@ namespace WeighBusiness.BL if (selectedList.Count() > 0) { foreach (var catalogDetail in selectedList) { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类配制存货, - new string[] { "ProductCatalog_ID", "Goods_ID" }, - new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString() }); + new string[] { "ProductCatalog_ID", "Goods_ID", "Employee_Name" }, + new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString(), catalogDetail.Employee_Name??string.Empty }); she.ExecuteNonQuery(insertSql, out success); if (!success) she.Rollback(); @@ -283,8 +299,9 @@ namespace WeighBusiness.BL foreach (DataRow row in table.Rows) { var catalog = new ProductCatalog(); - catalog.ProductCatalog_ID = int.Parse(row[0].ToString()); + catalog.ProductCatalog_ID = int.Parse(row[0].ToString()); catalog.Sequence = DataTypeUtil.GetIntNullNum(row[1]); + selectedList.Add(catalog); } } @@ -301,7 +318,11 @@ namespace WeighBusiness.BL { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类, new string[] { "ProductCatalog_ID", "Name", "Sequence", "RowVersion" }, - new string[] { catalog.ProductCatalog_ID.ToString(), catalog.ProductCatalog_ID.ToString(), catalog.Sequence == null ? "null" : catalog.Sequence.ToString(), "0" }); + new string[] { + catalog.ProductCatalog_ID.ToString(), + catalog.ProductCatalog_ID.ToString(), + catalog.Sequence == null ? "null" : catalog.Sequence.ToString(), "0" }); + she.ExecuteNonQuery(insertSql, out success, out errorMessage); if (!success) { @@ -324,8 +345,8 @@ namespace WeighBusiness.BL foreach (var catalogDetail in goodslist) { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类配制存货, - new string[] { "ProductCatalog_ID", "Goods_ID" }, - new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString() }); + new string[] { "ProductCatalog_ID", "Goods_ID", "Employee_Name" }, + new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString(), catalogDetail.Employee_Name??string.Empty }); she.ExecuteNonQuery(insertSql, out success); if (!success) she.Rollback(); @@ -342,16 +363,17 @@ namespace WeighBusiness.BL { var selectedList = new List(); - var table = SqlHelperEx.DoQuery("select ProductCatalog_ID, Goods_ID from {0} b ".FormatWith( TableNames.客户端产品分类配制存货 ), TableNames.数据库_backup); + var table = SqlHelperEx.DoQuery("select ProductCatalog_ID, Goods_ID, Employee_Name from {0} b ".FormatWith(TableNames.客户端产品分类配制存货), TableNames.数据库_backup); if (table.Rows.Count > 0) - { + { foreach (DataRow row in table.Rows) { var catalog = new ProCataGoods(); - catalog.ProductCatalog_ID = int.Parse(row[0].ToString()); - catalog.Goods_ID = int.Parse(row[1].ToString()); + catalog.ProductCatalog_ID = int.Parse(row[0].ToString()); + catalog.Goods_ID = int.Parse(row[1].ToString()); + catalog.Employee_Name = DataTypeUtil.ToStringEmptyIfNull(row[2]); selectedList.Add(catalog); - } + } } var selectedList2 = new List(); @@ -379,8 +401,8 @@ namespace WeighBusiness.BL foreach (var catalogDetail in selectedList) { string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类配制存货, - new string[] { "ProductCatalog_ID", "Goods_ID" }, - new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString() }); + new string[] { "ProductCatalog_ID", "Goods_ID" , "Employee_Name" }, + new string[] { catalogDetail.ProductCatalog_ID.ToString(), catalogDetail.Goods_ID.ToString() , catalogDetail.Employee_Name??string.Empty }); she.ExecuteNonQuery(insertSql, out success); if (!success) she.Rollback(); @@ -431,6 +453,7 @@ namespace WeighBusiness.BL public long CatalogDetail_ID { get; set; } public string Goods_Name { get; set; } public string Goods_Code { get; set; } + public string Employee_Name { get; set; } public string Goods_Spec { get; set; } public long Goods_ID { get; set; } public string UnitConvertDirection { get; set; } diff --git a/WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs b/WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs index 7e1fb26..2e1c087 100644 --- a/WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs +++ b/WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs @@ -32,6 +32,7 @@ namespace WeighBusiness.BO.CreateTables }); cth.AddField(new FieldInfo() { FieldName = "Goods_Spec", FieldType = FBType.Varchar, FieldTypeParams = "(100)", IsNotNull = false }); cth.AddField(new FieldInfo() { FieldName = "Goods_Code", FieldType = FBType.Varchar, FieldTypeParams = "(100)", IsNotNull = false }); + cth.AddField(new FieldInfo() { FieldName = "Employee_Name", FieldType = FBType.Varchar, FieldTypeParams = "(50)", IsNotNull = false }); base.AddFields(cth); } diff --git a/WeighBusiness/BO/CreateTables/CreateSelectedProductCatalogGoods.cs b/WeighBusiness/BO/CreateTables/CreateSelectedProductCatalogGoods.cs index 89699f6..378653e 100644 --- a/WeighBusiness/BO/CreateTables/CreateSelectedProductCatalogGoods.cs +++ b/WeighBusiness/BO/CreateTables/CreateSelectedProductCatalogGoods.cs @@ -16,7 +16,8 @@ namespace WeighBusiness.BO.CreateTables public override void AddFields(CreateTableHelper cth) { cth.AddField(new FieldInfo() { FieldName = "ProductCatalog_ID", FieldType = FBType.Integer, IsNotNull = true }); - cth.AddField(new FieldInfo() { FieldName = "Goods_ID", FieldType = FBType.Integer, IsNotNull = true }); + cth.AddField(new FieldInfo() { FieldName = "Goods_ID", FieldType = FBType.Integer, IsNotNull = true }); + cth.AddField(new FieldInfo() { FieldName = "Employee_Name", FieldType = FBType.Varchar, FieldTypeParams = "(50)", IsNotNull = false }); base.AddFields(cth); } diff --git a/WeighBusiness/BO/ProductCatalog_Detail.cs b/WeighBusiness/BO/ProductCatalog_Detail.cs index fa4cf76..c07a9ac 100644 --- a/WeighBusiness/BO/ProductCatalog_Detail.cs +++ b/WeighBusiness/BO/ProductCatalog_Detail.cs @@ -19,7 +19,7 @@ namespace WeighBusiness.BO public long CatalogDetail_ID { get; set; } public string Goods_Name { get; set; } public string Goods_Code { get; set; } - + public string Employee_Name { get; set; } public string Goods_Spec { get; set; } public long Goods_ID { get; set; } public string UnitConvertDirection { get; set; } diff --git a/WeighBusiness/Utils/TableName.cs b/WeighBusiness/Utils/TableName.cs index 169e7c9..315ba65 100644 --- a/WeighBusiness/Utils/TableName.cs +++ b/WeighBusiness/Utils/TableName.cs @@ -8,8 +8,8 @@ namespace WeighBusiness.Utils public static class TableNames//名称不能太长,有限制。例如:触发器的名称长度限制(触发器中有一段是表名) { //public const string 数据库 = @"Datas"; - public const string 数据库 = @"C:\CowOutputClient\Datas"; - public const string 数据库_backup = @"C:\CowOutputClient\Datas_backup"; + public const string 数据库 = @"C:\NewCowOutputClient\Datas"; + public const string 数据库_backup = @"C:\NewCowOutputClient\Datas_backup"; //public static string 数据库 = ConfigUtil.DatabasePath;// @"D:\temp\CustomerSale.FDB"; public const string 称重表 = "T_W";