From 8fe2018dfa7aaa73db37f2c823449d9754f244a0 Mon Sep 17 00:00:00 2001 From: tdx Date: Sun, 16 Mar 2025 06:22:43 +0000 Subject: [PATCH] SVN r330 SVN-Revision: r330 --- 插件库/Lskj.PubBill/BillModule.Designer.cs | 13 +- 插件库/Lskj.PubBill/BillModule.cs | 234 +++++++++++---------- 2 files changed, 126 insertions(+), 121 deletions(-) diff --git a/插件库/Lskj.PubBill/BillModule.Designer.cs b/插件库/Lskj.PubBill/BillModule.Designer.cs index e3d159b..f9424b5 100644 --- a/插件库/Lskj.PubBill/BillModule.Designer.cs +++ b/插件库/Lskj.PubBill/BillModule.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl(); this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl(); this.pl_left = new DevExpress.XtraEditors.PanelControl(); @@ -40,7 +41,7 @@ this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl(); this.panelControl4 = new DevExpress.XtraEditors.PanelControl(); this.textEdit1 = new DevExpress.XtraEditors.TextEdit(); - this.barManager1 = new DevExpress.XtraBars.BarManager(); + this.barManager1 = new DevExpress.XtraBars.BarManager(this.components); this.barDockControl1 = new DevExpress.XtraBars.BarDockControl(); this.barDockControl2 = new DevExpress.XtraBars.BarDockControl(); this.barDockControl3 = new DevExpress.XtraBars.BarDockControl(); @@ -50,7 +51,7 @@ this.btnTreeSearch = new DevExpress.XtraEditors.SimpleButton(); this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl(); this.dbpFP = new DevExpress.XtraEditors.DropDownButton(); - this.pmFP = new DevExpress.XtraBars.PopupMenu(); + this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components); this.btnRefresh = new DevExpress.XtraEditors.SimpleButton(); this.btnHiding = new DevExpress.XtraEditors.SimpleButton(); this.btnHelp = new DevExpress.XtraEditors.SimpleButton(); @@ -63,15 +64,15 @@ this.labelControl2 = new DevExpress.XtraEditors.LabelControl(); this.btn_input = new DevExpress.XtraEditors.SimpleButton(); this.dpbImport = new DevExpress.XtraEditors.DropDownButton(); - this.pmBillExp = new DevExpress.XtraBars.PopupMenu(); + this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components); this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton(); this.btnBillApply = new DevExpress.XtraEditors.SimpleButton(); this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton(); - this.pmBill = new DevExpress.XtraBars.PopupMenu(); + this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components); this.btnPrint = new DevExpress.XtraEditors.DropDownButton(); - this.pMprint = new DevExpress.XtraBars.PopupMenu(); + this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components); this.dpbTools = new DevExpress.XtraEditors.DropDownButton(); - this.pMenu = new DevExpress.XtraBars.PopupMenu(); + this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components); this.btnDelete = new DevExpress.XtraEditors.SimpleButton(); this.btnBillSave = new DevExpress.XtraEditors.SimpleButton(); this.pl_main_top = new DevExpress.XtraEditors.PanelControl(); diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index c769709..e3d9ab0 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -1678,7 +1678,7 @@ namespace Lskj.PubBill if (attachModels.Count > 0) this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix; } - if (model.MainDetailsAddType!="2") + if (model.MainDetailsAddType != "2") { TreeGridDragGrid treeGridDragGrid = new TreeGridDragGrid((gridDetail as TreeGridControlEx).TreeListObj, this.gcMain.GridView); treeGridDragGrid.OnDragComplete += new TreeGridDragGridCompleteEventHandler(OnTreeGridDetailGridCompleted); @@ -1750,7 +1750,7 @@ namespace Lskj.PubBill int width = this.tb_buttom.Width;//获取控件宽度 splitContainerControl.SplitterPosition = width / 2;//然后将分割位置设置在宽度一半位置 } - if (model.MainDetailsAddType != "1") + if (model.MainDetailsAddType != "1") { //明细的明细拖拽到上方 if (this.BillModel.DetailTreeTable) @@ -1772,7 +1772,7 @@ namespace Lskj.PubBill gridDetail_Details.GridView.DoubleClick += new EventHandler(OnGridDetailDetailDoubleClick); } } - + splitContainerControl.Parent = tabDetail; unionModel.GridDetailDetailControlObj = gridDetail_Details; } @@ -1791,7 +1791,7 @@ namespace Lskj.PubBill this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix; } - if (model.MainDetailsAddType != "2") + if (model.MainDetailsAddType != "2") { if (this.BillModel.DetailTreeTable) { @@ -1809,7 +1809,7 @@ namespace Lskj.PubBill dragDetailGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragDetailGridCompleted); } } - + if (BillModel.IsBillDetailCheck == 1)//加载复选框 @@ -3784,12 +3784,12 @@ namespace Lskj.PubBill this.AddRowToGridViewByBom(rowItem, unionModel, ref onlyPopup); if (BillModel.drgFinishHide == "1" && unionModel.GridDetailControlObj != null) { - if (unionModel.GridDetailControlObj.GridControl.DataSourceTable().Rows.IndexOf(rowItem) >= 0) + if (unionModel.GridDetailControlObj.GridControl.DataSourceTable().Rows.IndexOf(rowItem) >= 0) { unionModel.GridDetailControlObj.GridControl.DataSourceTable().Rows.Remove(rowItem); //RemoveRowitem.Add(rowItem); } - if (unionModel.GridDetailDetailControlObj!=null&&unionModel.GridDetailDetailControlObj.GridControl.DataSourceTable().Rows.IndexOf(rowItem) >= 0) + if (unionModel.GridDetailDetailControlObj != null && unionModel.GridDetailDetailControlObj.GridControl.DataSourceTable().Rows.IndexOf(rowItem) >= 0) { unionModel.GridDetailDetailControlObj.GridControl.DataSourceTable().Rows.Remove(rowItem); //RemoveRowitem.Add(rowItem); @@ -4391,7 +4391,7 @@ namespace Lskj.PubBill { DataTable tvp = new DataTable();//虚构一个保存存储过程 //更新前进行数据源筛选 - if (DateColumnList.Count > 0) + if (DateColumnList.Count > 0 && string.IsNullOrEmpty(BillModel.PrimaryDetailKey)) { // 创建临时表 tvp.Columns.Add("lblOrderNo", typeof(string)); // 固定主键 @@ -4408,7 +4408,7 @@ namespace Lskj.PubBill if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) { // 提取 billdocument_id - string key = row["bom_rdl_productid"].ToString(); + string key = row[BillModel.PrimaryDetailKey].ToString(); // 遍历列并处理虚拟列 foreach (DataColumn col in mainDataSource.Columns) @@ -4519,9 +4519,9 @@ namespace Lskj.PubBill SaveRefreshSource(); RefreshPrindMenu(); //保存完成后所有数据源进行拼接执行保存 - if (tvp!=null&& tvp.Rows.Count > 0) + if (tvp != null && tvp.Rows.Count > 0) { - foreach (DataRow dataRow in tvp.Rows) + foreach (DataRow dataRow in tvp.Rows) { dataRow["lblOrderNo"] = billNo; } @@ -5045,39 +5045,18 @@ namespace Lskj.PubBill { if (DateColumnList.Count > 0 && DateColumnList[0].Tag is DateTime dateTime) { - this.gcMain.GridView.DataSourceChanged -= OnGcMainDataSourceChanged; - DataTable dataTable = gcMain.GridControl.DataSource as DataTable; - //DataTable dataMain = dataTable.Copy(); - string sqlValue = "select * from RD_worktimetab where 1 = 1"; - sqlValue = $"{sqlValue} and showday >= '{dateTime.ToString("yyyy-MM-dd")}'"; - DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue); - MergeMainDataWithDayPlan(dataTable, dataDayPlan, dateTime); - //gcMain.GridControl.DataSource = dataMain; - this.gcMain.GridView.DataSourceChanged += OnGcMainDataSourceChanged; - dataTable.TableNewRow += OnDataTableTableNewRow; - } - } - - /// - /// 表格行添加数据时 - /// - /// - /// - private void OnDataTableTableNewRow(object sender, DataTableNewRowEventArgs e) - { - if (DateColumnList.Count > 0 && DateColumnList[0].Tag is DateTime dateTime) - { - DataRow focusedRow = gcMain.GridView.GetFocusedDataRow(); - if (focusedRow != null) + string billNo = this.lblOrderNo.Text; + if (!string.IsNullOrEmpty(billNo)) { - string key = focusedRow.Table.Columns.Contains(BillModel.PrimaryKey) ? focusedRow[BillModel.PrimaryKey] + "" : ""; - if (!string.IsNullOrEmpty(key)) - { - string sqlValue = $"select * from RD_worktimetab where billdocument_id = '{key}'"; - sqlValue = $"{sqlValue} and showday >= '{dateTime.ToString("yyyy-MM-dd")}'"; - DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue); - UpdateRowWithDayPlan(focusedRow, dataDayPlan, dateTime); - } + this.gcMain.GridView.DataSourceChanged -= OnGcMainDataSourceChanged; + DataTable dataTable = gcMain.GridControl.DataSource as DataTable; + //DataTable dataMain = dataTable.Copy(); + string sqlValue = "select * from RD_worktimetab where 1 = 1"; + sqlValue = $"{sqlValue} and lblOrderNo = '{billNo}' and showday >= '{dateTime.ToString("yyyy-MM-dd")}'"; + DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue); + MergeMainDataWithDayPlan(dataTable, dataDayPlan, dateTime); + //gcMain.GridControl.DataSource = dataMain; + this.gcMain.GridView.DataSourceChanged += OnGcMainDataSourceChanged; } } } @@ -5129,8 +5108,10 @@ namespace Lskj.PubBill /// private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate) { - string rightPrimaryKey = "key"; - string topPrimaryKey = this.BillModel.PrimaryKey; + string rightPrimaryKey = "billdocument_id"; + string dateField = "showday"; + string amountField = "amount"; + string topPrimaryKey = this.BillModel.PrimaryDetailKey; DateTime endDate = startDate.AddDays(7); // 计算结束日期 // **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)** Dictionary> dayPlanMap = new Dictionary>(); @@ -5166,13 +5147,13 @@ namespace Lskj.PubBill { foreach (DataRow dayRow in dayPlanMap[key]) { - if (dayRow["date"] != DBNull.Value) + if (dayRow[dateField] != DBNull.Value) { - DateTime dayValue = Convert.ToDateTime(dayRow["date"]); + DateTime dayValue = Convert.ToDateTime(dayRow[dateField]); string colName = dayValue.ToString("yyyy-MM-dd"); if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName)) { - dataMap[key][colName] = Convert.ToDecimal(dayRow["amount"]); + dataMap[key][colName] = Convert.ToDecimal(dayRow[amountField]); } } } @@ -5201,8 +5182,10 @@ namespace Lskj.PubBill /// private void UpdateRowWithDayPlan(DataRow focusedRow, DataTable dataDayPlan, DateTime startDate) { - string rightPrimaryKey = "key"; - string topPrimaryKey = this.BillModel.PrimaryKey; + string rightPrimaryKey = "billdocument_id"; + string dateField = "showday"; + string amountField = "amount"; + string topPrimaryKey = this.BillModel.PrimaryDetailKey; DateTime endDate = startDate.AddDays(7); // 计算结束日期 // **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)** Dictionary> dayPlanMap = new Dictionary>(); @@ -5236,13 +5219,13 @@ namespace Lskj.PubBill { foreach (DataRow dayRow in dayPlanMap[key]) { - if (dayRow["date"] != DBNull.Value) + if (dayRow[dateField] != DBNull.Value) { - DateTime dayValue = Convert.ToDateTime(dayRow["date"]); + DateTime dayValue = Convert.ToDateTime(dayRow[dateField]); string colName = dayValue.ToString("yyyy-MM-dd"); if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName)) { - dataMap[key][colName] = Convert.ToDecimal(dayRow["amount"]); + dataMap[key][colName] = Convert.ToDecimal(dayRow[amountField]); } } } @@ -6388,11 +6371,7 @@ namespace Lskj.PubBill { try { - int[] selectRows = this.gcMain.GridView.GetSelectedRows(); - if (selectRows.Count() == 0) - { - return; - } + this.gcMain.GridView.FocusedRowHandle = 0; DataTable table = this.gcMain.GridControl.DataSource as DataTable; if (!table.Columns.Contains(guidField)) { @@ -6418,6 +6397,11 @@ namespace Lskj.PubBill // 检查数据是否为分配后的行 if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) + { + this.gcMain.GridView.FocusedRowHandle += 1; + FPNew(); + } return; } } @@ -6470,6 +6454,11 @@ namespace Lskj.PubBill // 检查数据是否为分配后的行 if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) + { + this.gcMain.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } return; } } @@ -6489,74 +6478,89 @@ namespace Lskj.PubBill } frmSelect.InitData(rowItem); bool success = frmSelect.FP(); - if (success && frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + if (success) { - // 增加标识列 - if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) { - this.mRecordPrimaryField = frmSelect.RecordPrimaryField; - table.Columns.Add(this.mRecordPrimaryField, typeof(String)); - } - foreach (DataRow item in frmSelect.SelectedRows) - { - DataRow newRow = table.NewRow(); - newRow.ItemArray = rowItem.ItemArray; - newRow[guidField] = rowItem[guidField]; - DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModel.DetailTable)) + ""); - //自增长列分配按空值取 - if (IsIdentCol != null) + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) { - if (IsIdentCol.DataType == typeof(Decimal) || - IsIdentCol.DataType == typeof(Double) || - IsIdentCol.DataType == typeof(Int16) || - IsIdentCol.DataType == typeof(Int32) || - IsIdentCol.DataType == typeof(Int64)) - { - newRow[IsIdentCol.ColumnName] = 0; - } + this.mRecordPrimaryField = frmSelect.RecordPrimaryField; + table.Columns.Add(this.mRecordPrimaryField, typeof(String)); } - foreach (DataColumn col in item.Table.Columns) + foreach (DataRow item in frmSelect.SelectedRows) { - if (table.Columns.Contains(col.ColumnName)) + DataRow newRow = table.NewRow(); + newRow.ItemArray = rowItem.ItemArray; + newRow[guidField] = rowItem[guidField]; + DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModel.DetailTable)) + ""); + //自增长列分配按空值取 + if (IsIdentCol != null) { - //newRow[col.ColumnName] = item[col.ColumnName]; - newRow[col.ColumnName] = item[col.ColumnName]; - GridColumn column = this.gcMain.GridView.Columns[col.ColumnName]; - if (column != null) + if (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) { - GridColumnModel model = column.Tag as GridColumnModel; - if (!string.IsNullOrEmpty(model.UnionFields)) - { - this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); - } - SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + newRow[IsIdentCol.ColumnName] = 0; } } + foreach (DataColumn col in item.Table.Columns) + { + if (table.Columns.Contains(col.ColumnName)) + { + //newRow[col.ColumnName] = item[col.ColumnName]; + newRow[col.ColumnName] = item[col.ColumnName]; + GridColumn column = this.gcMain.GridView.Columns[col.ColumnName]; + if (column != null) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + } + } + } + newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; + newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; + table.Rows.Add(newRow); + } + NumberMc = frmSelect.AmountField; + table.Rows.Remove(rowItem); + // 重排顺序 + table.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + if (frmSelect.isNextOne) + { + int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex(); + DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); + if (a.Length != 0) + { + this.gcMain.GridView.FocusedRowHandle = SourceRowIndex; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } } - newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; - newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; - table.Rows.Add(newRow); } - NumberMc = frmSelect.AmountField; - table.Rows.Remove(rowItem); - // 重排顺序 - table.OrderBy(this.BillModel.DetailOrderField); - this.gcMain.GridView.UpdateCurrentRow(); - this.gcMain.GridView.ShowEditor(); - if (frmSelect.isNextOne) + } + else + { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) { - int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex(); - DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); - if (a.Length != 0) - { - this.gcMain.GridView.FocusedRowHandle = SourceRowIndex; - OnAfterFPCallback(sender, e); - } - else - { - MessageUtil.Show("全部分配完毕"); - // frmSelect.SelectRowItem = null; - } + this.gcMain.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); } } } @@ -7908,4 +7912,4 @@ namespace Lskj.PubBill /// /// The cond. /// The data row. - /// true if XXXX, < \ No newline at end of file + /// true if X \ No newline at end of file