diff --git a/插件库/Lskj.PubBill/BillModule.Designer.cs b/插件库/Lskj.PubBill/BillModule.Designer.cs index 13e80ef..6356e9f 100644 --- a/插件库/Lskj.PubBill/BillModule.Designer.cs +++ b/插件库/Lskj.PubBill/BillModule.Designer.cs @@ -49,9 +49,10 @@ this.panelControl3 = new DevExpress.XtraEditors.PanelControl(); 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.btnRefresh = new DevExpress.XtraEditors.SimpleButton(); this.btnHiding = new DevExpress.XtraEditors.SimpleButton(); - this.btnFP = new DevExpress.XtraEditors.SimpleButton(); this.btnHelp = new DevExpress.XtraEditors.SimpleButton(); this.pl_templete = new DevExpress.XtraEditors.PanelControl(); this.cb_templete = new DevExpress.XtraEditors.ComboBoxEdit(); @@ -109,6 +110,7 @@ this.panelControl3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).BeginInit(); this.pl_main_bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pmFP)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).BeginInit(); this.pl_templete.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cb_templete.Properties)).BeginInit(); @@ -376,9 +378,9 @@ this.pl_main_bottom.Appearance.BackColor = System.Drawing.Color.Transparent; this.pl_main_bottom.Appearance.Options.UseBackColor = true; this.pl_main_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_bottom.Controls.Add(this.dbpFP); this.pl_main_bottom.Controls.Add(this.btnRefresh); this.pl_main_bottom.Controls.Add(this.btnHiding); - this.pl_main_bottom.Controls.Add(this.btnFP); this.pl_main_bottom.Controls.Add(this.btnHelp); this.pl_main_bottom.Controls.Add(this.pl_templete); this.pl_main_bottom.Controls.Add(this.pl_input); @@ -396,6 +398,25 @@ this.pl_main_bottom.Size = new System.Drawing.Size(1211, 37); this.pl_main_bottom.TabIndex = 1; // + // dbpFP + // + this.dbpFP.AllowFocus = false; + this.dbpFP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dbpFP.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dbpFP.Appearance.Options.UseFont = true; + this.dbpFP.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dbpFP.DropDownControl = this.pmFP; + this.dbpFP.Location = new System.Drawing.Point(356, 7); + this.dbpFP.Name = "dbpFP"; + this.dbpFP.Size = new System.Drawing.Size(52, 26); + this.dbpFP.TabIndex = 34; + this.dbpFP.Text = "分配"; + // + // pmFP + // + this.pmFP.Manager = this.barManager1; + this.pmFP.Name = "pmFP"; + // // btnRefresh // this.btnRefresh.AllowFocus = false; @@ -423,19 +444,6 @@ this.btnHiding.Visible = false; this.btnHiding.Click += new System.EventHandler(this.OnMainTableHiding); // - // btnFP - // - this.btnFP.AllowFocus = false; - this.btnFP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnFP.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnFP.Appearance.Options.UseFont = true; - this.btnFP.Location = new System.Drawing.Point(345, 7); - this.btnFP.Name = "btnFP"; - this.btnFP.Size = new System.Drawing.Size(67, 26); - this.btnFP.TabIndex = 31; - this.btnFP.Text = "分配"; - this.btnFP.Click += new System.EventHandler(this.OnBtnFPClick); - // // btnHelp // this.btnHelp.AllowFocus = false; @@ -850,6 +858,7 @@ this.panelControl3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).EndInit(); this.pl_main_bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pmFP)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).EndInit(); this.pl_templete.ResumeLayout(false); this.pl_templete.PerformLayout(); @@ -910,7 +919,6 @@ private DevExpress.XtraEditors.PanelControl panelControl3; private DevExpress.XtraEditors.SimpleButton btnTreeSearch; public DevExpress.XtraEditors.PanelControl pl_main_bottom; - private DevExpress.XtraEditors.SimpleButton btnFP; private DevExpress.XtraEditors.SimpleButton btnHelp; private DevExpress.XtraEditors.PanelControl pl_templete; private DevExpress.XtraEditors.ComboBoxEdit cb_templete; @@ -928,20 +936,4 @@ private DevExpress.XtraEditors.SimpleButton btnDelete; private DevExpress.XtraEditors.SimpleButton btnBillSave; private DevExpress.XtraEditors.PanelControl pl_main_top; - private DevExpress.XtraEditors.PanelControl pl_main_top_center; - private System.Windows.Forms.Label lbTitle; - private DevExpress.XtraEditors.PanelControl pl_main_top_right; - private DevExpress.XtraEditors.LabelControl lblOrderNo; - private DevExpress.XtraEditors.LabelControl labelControl1; - private DevExpress.XtraEditors.PanelControl pl_main_top_left; - private DevExpress.XtraEditors.PanelControl pl_red; - private System.Windows.Forms.RadioButton rdRed; - private DevExpress.XtraEditors.PanelControl pl_blue; - private System.Windows.Forms.RadioButton rdBlue; - private Control.TabControlEx tb_buttom; - private DevExpress.XtraEditors.TextEdit txt_input; - private DevExpress.XtraEditors.SimpleButton btnHiding; - private DevExpress.XtraEditors.SimpleButton btnRefresh; - private Control.GridControlEx gcMain; - } -} + private DevExpress \ No newline at end of file diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index db7cec6..2d6ca7c 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -821,7 +821,7 @@ namespace Lskj.PubBill this.pl_main_bottom.Enabled = false; this.ssc_main_top.SplitterPosition = this.BillModel.PanelWidth; InitializeUnionCode();//根据红蓝字段更新分配 - this.btnFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); } /// /// 说明:初始化常用操作等功能 @@ -843,6 +843,12 @@ namespace Lskj.PubBill BarButtonItem itemExport = new BarButtonItem(); itemExport.Caption = "导出Excel文件"; itemExport.ItemClick += new ItemClickEventHandler(OnExportItemClick); + BarButtonItem itemFPNormal = new BarButtonItem(); + itemFPNormal.Caption = "普通分配"; + itemFPNormal.ItemClick += new ItemClickEventHandler(OnBtnFPOldClick); + BarButtonItem itemFPBatch = new BarButtonItem(); + itemFPBatch.Caption = "批量分配"; + itemFPBatch.ItemClick += new ItemClickEventHandler(OnBtnFPNewClick); this._itemImport = new BarButtonItem(); this._itemImport.Caption = "导入Excel文件"; @@ -853,16 +859,17 @@ namespace Lskj.PubBill // 复制单据 this.pmBill.AddItems(new BarItem[] { itemCopyMaster, itemCopyAll }); - // 导入导出 if (this.BillModel.CanExport && this.BillModel.ExportPermission) { this.pmBillExp.AddItem(itemExport); } - if (this.BillModel.CanImport) + { this.pmBillExp.AddItems(new BarItem[] { _itemImport, _itemImportUpdate }); - + } + //分配 + this.pmFP.AddItems(new BarItem[] { itemFPNormal, itemFPBatch }); // 打印模版 string[] files = this.BillModel.PrintFile.Split('|'); for (int i = 0; i < files.Length; i++) @@ -1918,7 +1925,7 @@ namespace Lskj.PubBill this._itemImport.Enabled = this._itemImportUpdate.Enabled = !isReadOnly; this.ControlObj.SetReadOnlyAllControl(isReadOnly); this.ControlObj.SetAllControlValue(rowItem); - this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = !isReadOnly; + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = !isReadOnly; this.ControlObj.CanExecControl = true; this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = !isReadOnly; this.BillRowItem = rowItem; @@ -1929,7 +1936,7 @@ namespace Lskj.PubBill this.cb_templete.Enabled = !isReadOnly; } this.BillModel.PopupUnionCode = rdBlue.Checked ? rdBlueUnionCode : rdRedUnionCode; - this.btnFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = rdBlue.Checked ? Color.Blue : Color.Red; this.gcMain.GridView.OptionsBehavior.Editable = !isReadOnly; // 上一次查询 @@ -1971,7 +1978,7 @@ namespace Lskj.PubBill else { // 单据为新增状态 - this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; this.lbTitle.Text = this.BillModel.TypeName + "(新增)"; this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); this._itemImport.Enabled = this._itemImportUpdate.Enabled = true; @@ -2022,7 +2029,7 @@ namespace Lskj.PubBill { this.rdRed.Checked = false; this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Blue; - this.btnFP.Visible = !string.IsNullOrWhiteSpace(rdBlueUnionCode); + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(rdBlueUnionCode); this.BillModel.PopupUnionCode = rdBlueUnionCode; BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); @@ -2046,7 +2053,7 @@ namespace Lskj.PubBill { this.rdBlue.Checked = false; this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Red; - this.btnFP.Visible = !string.IsNullOrWhiteSpace(rdRedUnionCode); + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(rdRedUnionCode); this.BillModel.PopupUnionCode = rdRedUnionCode; BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); @@ -2071,7 +2078,7 @@ namespace Lskj.PubBill /// The instance containing the event data. protected void OnCopyMasterItemClick(object sender, ItemClickEventArgs e) { - this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; this.lbTitle.Text = this.BillModel.TypeName + "(新增)"; this.lbTitle.Invalidate(); this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); @@ -2119,7 +2126,7 @@ namespace Lskj.PubBill { gridTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows(); } - this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; this.lbTitle.Text = this.BillModel.TypeName + "(新增)"; this.lbTitle.Invalidate(); this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); @@ -2750,7 +2757,7 @@ namespace Lskj.PubBill if (unionModel.GridControlObj != null) { unionModel.GridControlObj.gridControl.DataSource = BaseImpl.GetDataTableResult(sql); - + if (unionModel.GridControlObj != null) { unionModel.GridControlObj.GridView.SelectRowHandler(Handle); @@ -5948,8 +5955,6 @@ namespace Lskj.PubBill WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, this.BillModel.TypeName); } - - FrmBaseSelect frmSelect = new FrmBaseSelect(); /// /// 说明:分配明细 /// 创建人:龚宇超 @@ -5961,47 +5966,106 @@ namespace Lskj.PubBill /// /// The source of the event. /// The instance containing the event data. - private void OnBtnFPClick(object sender, EventArgs e) + private void OnBtnFPOldClick(object sender, EventArgs e) { + FPOld(); + } + private void OnBtnFPNewClick(object sender, EventArgs e) + { + FPNew(); + } + /// + /// 新版分配 + /// + private void FPNew() + { + try + { + int[] selectRows = this.gcMain.GridView.GetSelectedRows(); + if (selectRows.Count() == 0) + { + return; + } + DataTable table = this.gcMain.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + #region 创建分配界面 + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelectBatch frmSelect = new FrmBaseSelectBatch(baseModel, this.ControlObj, this.gcMain)) + { + frmSelect.Text = this.BillModel.TypeName; + frmSelect.InitControl(); + frmSelect.OnAfterFPCallback += OnAfterFPCallback; + #region 初始化第一条数据 + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + return; + } + rowItem[guidField] = Guid.NewGuid().ToString(); + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + return; + } + } + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + frmSelect.InitData(rowItem); + frmSelect.OnBtnFPClick(null, null); + #endregion + //frmSelect.ShowDialog(); + #endregion + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 分配完成后回调 + /// + /// + /// + private void OnAfterFPCallback(object sender, EventArgs e) + { + WaitForm.ShowForm(); try { DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); if (rowItem == null) { - MessageUtil.Show("请先选择一条明细在进行分配!"); return; } - DataTable table = this.gcMain.GridControl.DataSource as DataTable; - if (!table.Columns.Contains(guidField)) - { - table.Columns.Add(guidField, typeof(String)); - } - rowItem[guidField] = Guid.NewGuid().ToString(); ; + FrmBaseSelectBatch frmSelect = (FrmBaseSelectBatch)sender; + rowItem[guidField] = Guid.NewGuid().ToString(); if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) { // 检查数据是否为分配后的行 if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) { - MessageUtil.Show("该行数据为已分配后的数据,无需分配!"); return; } } - - - string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" }; - DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); - frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); - //if (frmSelect.SelectRowItem == null) - //{ - // frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); - //} - - frmSelect.Text = this.BillModel.TypeName; - frmSelect.SelectRowItem = rowItem; - bool isNextOne = false; - - if (!string.IsNullOrEmpty(mRecordPrimaryField)) { frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); @@ -6016,29 +6080,21 @@ namespace Lskj.PubBill frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); } } - if (frmSelect.ShowDialog() == DialogResult.OK && frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + frmSelect.InitData(rowItem); + bool success = frmSelect.FP(); + if (success && frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) { - //if (frmSelect.isNextOne) - //{ - // isNextOne = true; - //} - //else - //{ - // isNextOne = false; - //} // 增加标识列 if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) { 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) @@ -6052,9 +6108,6 @@ namespace Lskj.PubBill newRow[IsIdentCol.ColumnName] = 0; } } - - - foreach (DataColumn col in item.Table.Columns) { if (table.Columns.Contains(col.ColumnName)) @@ -6076,47 +6129,187 @@ namespace Lskj.PubBill newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; table.Rows.Add(newRow); - } NumberMc = frmSelect.AmountField; - //double syAmount = frmSelect.GetSyAmount(); - //if (syAmount > 0) - //{ - // rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount(); - //} - //else - //{ - // table.Rows.Remove(rowItem); - //} 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; + } + } } - if (frmSelect.isNextOne) + } + catch (Exception) + { + throw; + } + finally + { + WaitForm.HideForm(); + } + } + + /// + /// 老版分配 + /// + private void FPOld() + { + try + { + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem == null) { - int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex(); - DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); - if (a.Length != 0) + MessageUtil.Show("请先选择一条明细在进行分配!"); + return; + } + DataTable table = this.gcMain.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + rowItem[guidField] = Guid.NewGuid().ToString(); ; + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) { - this.gcMain.GridView.FocusedRowHandle = SourceRowIndex; - OnBtnFPClick(sender, e); + MessageUtil.Show("该行数据为已分配后的数据,无需分配!"); + return; } - else + } + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelect frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain)) + { + //if (frmSelect.SelectRowItem == null) + //{ + // frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); + //} + frmSelect.Text = this.BillModel.TypeName; + frmSelect.SelectRowItem = rowItem; + bool isNextOne = false; + if (!string.IsNullOrEmpty(mRecordPrimaryField)) { - MessageUtil.Show("全部分配完毕"); - // frmSelect.SelectRowItem = null; + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } } + if (frmSelect.ShowDialog() == DialogResult.OK && frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + { + //if (frmSelect.isNextOne) + //{ + // isNextOne = true; + //} + //else + //{ + // isNextOne = false; + //} + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + { + 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 (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) + { + 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; + //double syAmount = frmSelect.GetSyAmount(); + //if (syAmount > 0) + //{ + // rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount(); + //} + //else + //{ + // table.Rows.Remove(rowItem); + //} + 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; + OnBtnFPOldClick(null, null); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } + } } } catch (Exception ex) { MessageUtil.Show(ex); } - } private void cb_templete_QueryCloseUp(object sender, CancelEventArgs e) { @@ -6533,7 +6726,7 @@ namespace Lskj.PubBill buttons.Add(this.btnRefresh); } //分配按钮 - buttons.Add(this.btnFP); + buttons.Add(this.dbpFP); //从最后开始计算 @@ -7308,4 +7501,37 @@ namespace Lskj.PubBill /// /// The cond. /// The data row. - /// true if XXXX, < \ No newline at end of file + /// true if XXXX, false otherwise. + private bool ValidateCond(string cond, DataRow dataRow) + { + bool result = false; + string condition = cond; + try + { + if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确 + cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else if (dataRow == null) + { + result = ReplaceHelper.EvalCond(cond); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); + } + return result; + } + catch (Exception ex) + { + + } + return result; + + } + + + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBill/BillModule.resx b/插件库/Lskj.PubBill/BillModule.resx index f999b69..6043357 100644 --- a/插件库/Lskj.PubBill/BillModule.resx +++ b/插件库/Lskj.PubBill/BillModule.resx @@ -121,7 +121,10 @@ 642, 21 - 25 + 83 + + + 1078, 23 873, 21 diff --git a/插件库/Lskj.PubBill/DllBaseClass.cs b/插件库/Lskj.PubBill/DllBaseClass.cs index fd3f030..d408c79 100644 --- a/插件库/Lskj.PubBill/DllBaseClass.cs +++ b/插件库/Lskj.PubBill/DllBaseClass.cs @@ -35,30 +35,4 @@ namespace Lskj.PubBill try { FrmMain main = new FrmMain(); - DynamicBillModel moduleModel = new DynamicBillModel(obj); - main.SysModel = moduleModel; - moduleModel.DataCaches = new Dictionary(); - if (SystemInfo.Instance.OptimizationSpeed) main.GetDataCaches(moduleModel.DataCaches); - GridEnum gridEnum = GridEnum.GridView; - if (!moduleModel.DataCaches.GetValue(main, "FormType", out int formType)) - { - formType = BaseImpl.GetBillDetailType(moduleModel.ModuleCode); - } - if (formType == 1) - { - gridEnum = GridEnum.BandedGridView; - } - main.SysModel.GridEnumObj = gridEnum; - this.SubForm = main; - - } - catch (Exception ex) - { - LogUtil.WriteError("Lskj.PubBill.dll--参数错误-->" + obj.ToString(), ex); - } - - } - - public Form SubForm { get; set; } - } -} + DynamicBillModel \ No newline at end of file diff --git a/插件库/Lskj.PubBill/FrmMain.cs b/插件库/Lskj.PubBill/FrmMain.cs index c60e79b..f5696fc 100644 --- a/插件库/Lskj.PubBill/FrmMain.cs +++ b/插件库/Lskj.PubBill/FrmMain.cs @@ -152,36 +152,4 @@ namespace Lskj.PubBill { if (isInitialization) { - this.billModule1.txtinputobj.Focus();//如果有扫码框,就默认获得焦点 - isInitialization = false; - } - - } - - private void OnClose(object sender, FormClosingEventArgs e) - { - string guid = this.Tag + ""; - if (string.IsNullOrWhiteSpace(guid)) return; - DllModule m = Manager.ModuleForms[guid]; - m.IsClose = true; - if (billModule1.closeTheJudgment()) - { - - - if (string.IsNullOrWhiteSpace(guid)) return; - DialogResult result = MessageUtil.Show(("数据未保存,是否确定关闭?"), MessageBoxButtons.YesNo); - if (result == DialogResult.Yes) - { - m.IsClose = true; - e.Cancel = false; - } - else - { - m.IsClose = false; - e.Cancel = true; - } - } - - } - } -} \ No newline at end of file + this.billModule1.txtinputobj.Fo \ No newline at end of file