SVN-Revision: r275
This commit is contained in:
tdx
2025-02-20 09:26:14 +00:00
parent 95201e7bcf
commit 842fc9a637
3 changed files with 976 additions and 0 deletions
+286
View File
@@ -0,0 +1,286 @@
namespace Lskj.Control
{
partial class FrmBaseSelectBatch
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lable1 = new System.Windows.Forms.Label();
this.panelControl5 = new DevExpress.XtraEditors.PanelControl();
this.lblFP = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.panelControl3 = new DevExpress.XtraEditors.PanelControl();
this.gcMain = new Lskj.Control.GridControlEx();
this.lblTotal = new System.Windows.Forms.Label();
this.panelControl2 = new DevExpress.XtraEditors.PanelControl();
this.panelControl6 = new DevExpress.XtraEditors.PanelControl();
this.lblSY = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
this.btnCancel = new DevExpress.XtraEditors.SimpleButton();
this.btnFP = new DevExpress.XtraEditors.SimpleButton();
this.PlSearch = new DevExpress.XtraEditors.PanelControl();
this.btnJ = new DevExpress.XtraEditors.SimpleButton();
this.btnDel = new DevExpress.XtraEditors.SimpleButton();
this.btnUpdate = new DevExpress.XtraEditors.SimpleButton();
((System.ComponentModel.ISupportInitialize)(this.panelControl5)).BeginInit();
this.panelControl5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl3)).BeginInit();
this.panelControl3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl2)).BeginInit();
this.panelControl2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl6)).BeginInit();
this.panelControl6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl4)).BeginInit();
this.panelControl4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PlSearch)).BeginInit();
this.SuspendLayout();
//
// lable1
//
this.lable1.AutoSize = true;
this.lable1.ForeColor = System.Drawing.Color.Red;
this.lable1.Location = new System.Drawing.Point(10, 10);
this.lable1.Name = "lable1";
this.lable1.Size = new System.Drawing.Size(43, 14);
this.lable1.TabIndex = 42;
this.lable1.Text = "数量:";
//
// panelControl5
//
this.panelControl5.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl5.Controls.Add(this.lblFP);
this.panelControl5.Controls.Add(this.label2);
this.panelControl5.Dock = System.Windows.Forms.DockStyle.Left;
this.panelControl5.Location = new System.Drawing.Point(138, 2);
this.panelControl5.Name = "panelControl5";
this.panelControl5.Size = new System.Drawing.Size(166, 36);
this.panelControl5.TabIndex = 46;
//
// lblFP
//
this.lblFP.AutoSize = true;
this.lblFP.ForeColor = System.Drawing.Color.Red;
this.lblFP.Location = new System.Drawing.Point(86, 10);
this.lblFP.Name = "lblFP";
this.lblFP.Size = new System.Drawing.Size(14, 14);
this.lblFP.TabIndex = 43;
this.lblFP.Text = "0";
//
// label2
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(10, 10);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 14);
this.label2.TabIndex = 42;
this.label2.Text = "已分配数量:";
//
// panelControl3
//
this.panelControl3.Controls.Add(this.gcMain);
this.panelControl3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl3.Location = new System.Drawing.Point(0, 50);
this.panelControl3.Name = "panelControl3";
this.panelControl3.Size = new System.Drawing.Size(816, 476);
this.panelControl3.TabIndex = 5;
//
// gcMain
//
this.gcMain.AdapterObj = null;
this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.gcMain.Location = new System.Drawing.Point(2, 2);
this.gcMain.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gcMain.Name = "gcMain";
this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.gcMain.Size = new System.Drawing.Size(812, 472);
this.gcMain.TabIndex = 0;
//
// lblTotal
//
this.lblTotal.AutoSize = true;
this.lblTotal.ForeColor = System.Drawing.Color.Red;
this.lblTotal.Location = new System.Drawing.Point(49, 10);
this.lblTotal.Name = "lblTotal";
this.lblTotal.Size = new System.Drawing.Size(14, 14);
this.lblTotal.TabIndex = 43;
this.lblTotal.Text = "0";
//
// panelControl2
//
this.panelControl2.Controls.Add(this.panelControl6);
this.panelControl2.Controls.Add(this.panelControl5);
this.panelControl2.Controls.Add(this.panelControl4);
this.panelControl2.Controls.Add(this.btnCancel);
this.panelControl2.Controls.Add(this.btnFP);
this.panelControl2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panelControl2.Location = new System.Drawing.Point(0, 526);
this.panelControl2.Name = "panelControl2";
this.panelControl2.Size = new System.Drawing.Size(816, 40);
this.panelControl2.TabIndex = 4;
//
// panelControl6
//
this.panelControl6.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl6.Controls.Add(this.lblSY);
this.panelControl6.Controls.Add(this.label4);
this.panelControl6.Dock = System.Windows.Forms.DockStyle.Left;
this.panelControl6.Location = new System.Drawing.Point(304, 2);
this.panelControl6.Name = "panelControl6";
this.panelControl6.Size = new System.Drawing.Size(136, 36);
this.panelControl6.TabIndex = 47;
//
// lblSY
//
this.lblSY.AutoSize = true;
this.lblSY.ForeColor = System.Drawing.Color.Red;
this.lblSY.Location = new System.Drawing.Point(50, 10);
this.lblSY.Name = "lblSY";
this.lblSY.Size = new System.Drawing.Size(14, 14);
this.lblSY.TabIndex = 43;
this.lblSY.Text = "0";
//
// label4
//
this.label4.AutoSize = true;
this.label4.ForeColor = System.Drawing.Color.Red;
this.label4.Location = new System.Drawing.Point(10, 10);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(43, 14);
this.label4.TabIndex = 42;
this.label4.Text = "差量:";
//
// panelControl4
//
this.panelControl4.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl4.Controls.Add(this.lblTotal);
this.panelControl4.Controls.Add(this.lable1);
this.panelControl4.Dock = System.Windows.Forms.DockStyle.Left;
this.panelControl4.Location = new System.Drawing.Point(2, 2);
this.panelControl4.Name = "panelControl4";
this.panelControl4.Size = new System.Drawing.Size(136, 36);
this.panelControl4.TabIndex = 45;
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnCancel.Appearance.Options.UseFont = true;
this.btnCancel.Location = new System.Drawing.Point(739, 7);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(72, 26);
this.btnCancel.TabIndex = 41;
this.btnCancel.Text = "退出";
this.btnCancel.Click += new System.EventHandler(this.OnBtnCancelClick);
//
// btnFP
//
this.btnFP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | 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(661, 7);
this.btnFP.Name = "btnFP";
this.btnFP.Size = new System.Drawing.Size(72, 26);
this.btnFP.TabIndex = 39;
this.btnFP.Text = "自动分配";
this.btnFP.Click += new System.EventHandler(this.OnBtnFPClick);
//
// PlSearch
//
this.PlSearch.Dock = System.Windows.Forms.DockStyle.Top;
this.PlSearch.Location = new System.Drawing.Point(0, 0);
this.PlSearch.Name = "PlSearch";
this.PlSearch.Size = new System.Drawing.Size(816, 50);
this.PlSearch.TabIndex = 3;
//
// btnJ
//
this.btnJ.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnJ.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnJ.Appearance.Options.UseFont = true;
this.btnJ.Location = new System.Drawing.Point(583, 7);
this.btnJ.Name = "btnJ";
this.btnJ.Size = new System.Drawing.Size(72, 26);
this.btnJ.TabIndex = 39;
this.btnJ.Text = "自动分配";
//
// btnDel
//
this.btnDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnDel.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnDel.Appearance.Options.UseFont = true;
this.btnDel.Location = new System.Drawing.Point(661, 7);
this.btnDel.Name = "btnDel";
this.btnDel.Size = new System.Drawing.Size(72, 26);
this.btnDel.TabIndex = 40;
this.btnDel.Text = "确定";
//
// btnUpdate
//
this.btnUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnUpdate.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnUpdate.Appearance.Options.UseFont = true;
this.btnUpdate.Location = new System.Drawing.Point(739, 7);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(72, 26);
this.btnUpdate.TabIndex = 41;
this.btnUpdate.Text = "放弃";
//
// FrmBaseSelectBatch
//
this.Appearance.BackColor = System.Drawing.SystemColors.Control;
this.Appearance.Options.UseBackColor = true;
this.Appearance.Options.UseFont = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(816, 566);
this.Controls.Add(this.panelControl3);
this.Controls.Add(this.panelControl2);
this.Controls.Add(this.PlSearch);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "FrmBaseSelectBatch";
((System.ComponentModel.ISupportInitialize)(this.panelControl5)).EndInit();
this.panelControl5.ResumeLayout(false);
this.panelControl5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl3)).EndInit();
this.panelControl3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.panelControl2)).EndInit();
this.panelControl2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.panelControl6)).EndInit();
this.panelControl6.ResumeLayout(false);
this.panelControl6.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl4)).EndInit();
this.panelControl4.ResumeLayout(false);
this.panelControl4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.PlSearch)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lab
@@ -0,0 +1,570 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control.Model;
using Lskj.Model;
using Lskj.Business.Impl;
using Lskj.Data;
using Lskj.Util;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Base;
using Lskj.Business;
using System.Text.RegularExpressions;
using System.Diagnostics;
using Lskj.Core;
namespace Lskj.Control
{
public partial class FrmBaseSelectBatch : BaseForm
{
string ParmaryKey;
/// <summary>
/// 库存数量字段、输入数量字段、结余数量字段、记录唯一值标识
/// </summary>
public string KcAmountField, AmountField, JYAmountField, RecordPrimaryField;
public DataTable QueryTable = new DataTable();
public DataTable GridColumns = new DataTable();
public string SearchSQL = "";
public MyControl SearchObj = new MyControl();
// 传入参数
public MyControl ControlObj = null;
public GridControlEx ParentGridControl;
public DynamicBaseSelectModel Model;
public DataRow SelectRowItem = null;
public DataRow[] FpRows = null; // 已分配数据行
public DataRow[] FpOtherRows = null; // 已分配其他数据行
// 输出参数
public DataRow[] SelectedRows = null;
/// <summary>
/// 系统模块实体对象
/// </summary>
/// <value>The system model.</value>
public ModuleModel SysModel { get; private set; }
/// <summary>
/// 是否点击下一个
/// </summary>
public bool isNextOne = false;
/// <summary>
/// 分配完成后回调
/// </summary>
public event EventHandler OnAfterFPCallback;
public FrmBaseSelectBatch() : this(null, null, null)
{
}
public FrmBaseSelectBatch(DynamicBaseSelectModel model, MyControl controlObj, GridControlEx gridControl)
{
InitializeComponent();
this.Model = model;
this.ControlObj = controlObj;
this.ParentGridControl = gridControl;
this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
this.gcMain.GridView.CellValueChanging += new CellValueChangedEventHandler(OnGridViewCellValueChanging);
//this.gcMain.GridView.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(GridView_RowStyle);
this.gcMain.RefreshTotal = false;
}
/// <summary>
/// 初始化数据
/// </summary>
/// <param name="selectRowItem"></param>
public void InitData(DataRow selectRowItem)
{
this.SelectRowItem = selectRowItem;
this.SearchObj = new MyControl(ReplaceHelper.ReplaceRowParam(SelectRowItem, SearchSQL), gcMain, null, null, null);
this.PlSearch.Height = this.SearchObj.InitSearchControl(QueryTable, this.PlSearch);
if (!string.IsNullOrEmpty(KcAmountField))
{
this.lblSY.Text = this.lblTotal.Text = Convert.ToDouble(SelectRowItem[AmountField] + "") + "";
this.lblFP.Text = "0";
}
this.gcMain.GridControl.DataSource = null;
this.SearchObj.SearchLastGrid();
if (this.FpOtherRows != null && this.FpOtherRows.Length > 0)
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
foreach (DataRow item in this.FpOtherRows)
{
DataRow rowItem = table.Rows.Cast<DataRow>().FirstOrDefault(x => x[RecordPrimaryField] + "" == item[RecordPrimaryField] + "");
if (rowItem != null)
{
rowItem[KcAmountField] = Convert.ToDouble(rowItem[KcAmountField]) - Convert.ToDouble(item[AmountField]);
}
}
double total = Convert.ToDouble(this.lblTotal.Text);
double ypfAmount = CalcYfpAmount();
this.lblFP.Text = ypfAmount + "";
this.lblSY.Text = (total - ypfAmount) + "";
}
if (this.FpRows != null && this.FpRows.Length > 0)
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
foreach (DataRow item in this.FpRows)
{
DataRow rowItem = table.Rows.Cast<DataRow>().FirstOrDefault(x => x[RecordPrimaryField] + "" == item[RecordPrimaryField] + "");
if (rowItem != null)
{
rowItem[AmountField] = Convert.ToDouble(item[AmountField]);
rowItem[JYAmountField] = Convert.ToDouble(rowItem[KcAmountField]) - Convert.ToDouble(rowItem[AmountField]);
}
}
double total = Convert.ToDouble(this.lblTotal.Text);
double ypfAmount = CalcYfpAmount();
this.lblFP.Text = ypfAmount + "";
this.lblSY.Text = (total - ypfAmount) + "";
}
}
/// <summary>
/// 初始化界面
/// </summary>
public void InitControl()
{
WaitForm.ShowForm();
try
{
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
if (modelRow == null)
{
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
this.Close();
}
this.lblTotal.Text = Model.AmountValue;
this.SysModel = new ModuleModel(modelRow);
this.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
this.QueryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);
this.GridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);
this.SearchSQL = this.ControlObj.ReplaceParentControlValue(this.SysModel.MenuSql);
if (this.QueryTable == null || this.QueryTable.Rows.Count > 0)
{
this.PlSearch.Visible = false;
}
if (this.GridColumns != null && this.GridColumns.Rows.Count > 0)
{
DataRow[] rows = this.GridColumns.Select("tm_tagid=1");
if (rows == null || rows.Length == 0)
{
MessageUtil.Show("未配置数量字段,基础档案库存数量字段标识设置为1!");
this.Close();
}
else
{
this.KcAmountField = rows[0]["fieldname"] + "";
}
rows = this.GridColumns.Select("tm_tagid=2");
if (rows == null || rows.Length == 0)
{
MessageUtil.Show("未配置数量字段,基础档案数量字段标识设置为2,可虚拟字段!");
this.Close();
}
else
{
this.AmountField = rows[0]["fieldname"] + "";
}
rows = this.GridColumns.Select("tm_tagid=3");
if (rows == null || rows.Length == 0)
{
MessageUtil.Show("未配置数量字段,基础档案数量字段标识设置为3,可虚拟字段!");
this.Close();
}
else
{
this.JYAmountField = rows[0]["fieldname"] + "";
}
rows = this.GridColumns.Select("tm_tagid=4");
if (rows == null || rows.Length == 0)
{
MessageUtil.Show("未配置唯一值字段,基础档案数量字段标识设置为4!");
this.Close();
}
else
{
this.RecordPrimaryField = rows[0]["fieldname"] + "";
}
}
this.gcMain.SetEditColumns(this.GridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);
InitCheckEdit();
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this.Model.ModuleCode));
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode), this.Model, OnGridViewRightCallBack, this.SearchObj, null);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule);
}
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
WaitForm.HideForm();
}
/// <summary>
/// <para>说明:计算剩余数量</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <returns>System.Single.</returns>
public double CalcYfpAmount()
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
double total = 0.0;
DataRow[] rowItems = table.Rows.Cast<DataRow>().Where(x => x.RowState == DataRowState.Modified).ToArray();
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
if (rowItems != null && rowItems.Length > 0)
{
foreach (DataRow item in rowItems)
{
if (item == rowItem) continue;
total += Convert.ToDouble(item[AmountField] + "");
}
}
return total;
}
/// <summary>
/// <para>说明:获取差量</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <returns>System.Double.</returns>
public double GetSyAmount()
{
return Convert.ToDouble(lblSY.Text);
}
/// <summary>
/// <para>说明:创建CheckBoxEdit</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-08-21 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="gridColumn">The grid column.</param>
public void InitCheckEdit()
{
GridColumn gridColumn = new GridColumn();
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
checkEdit.ValueChecked = true;
checkEdit.ValueUnchecked = false;
gridColumn.ColumnEdit = checkEdit;
gridColumn.Caption = "直接分配";
gridColumn.FieldName = "checkEdit";
gridColumn.Name = "checkEdit";
gridColumn.Visible = true;
gridColumn.VisibleIndex = 0;
gridColumn.ColumnEdit = checkEdit;
checkEdit.CheckedChanged += new EventHandler(OnCheckedChanged);
this.gcMain.GridControl.RepositoryItems.Add(checkEdit);
this.gcMain.GridView.Columns.Add(gridColumn);
}
/// <summary>
/// 选择状态改变触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnCheckedChanged(object sender, EventArgs e)
{
try
{
int rowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex();
double total = Convert.ToDouble(this.lblTotal.Text);
double totalCopy = total - CalcOldAmount();
double fpAmount = 0.0;
CheckEdit checkEdit = sender as CheckEdit;
// 分配规则,根据当前行自动分配直到分完为止
DataRow item = this.gcMain.GridView.GetFocusedDataRow();
double kcAmount = Convert.ToDouble(item[KcAmountField] + "");
if (checkEdit.Checked)
{
double check = Convert.ToDouble(item[AmountField] + "");
if (check == 0.0)
{
if (kcAmount >= totalCopy)
{
item[AmountField] = totalCopy;
totalCopy = 0;
}
else
{
if (fpAmount + kcAmount > totalCopy)
{
// 最后一次分配
item[AmountField] = kcAmount - (totalCopy - fpAmount);
}
else
{
item[AmountField] = kcAmount;
}
}
}
}
else
{
item[AmountField] = 0;
}
fpAmount = Convert.ToDouble(item[AmountField]);
this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(rowIndex, this.gcMain.GridView.Columns[AmountField], fpAmount));
item[JYAmountField] = Convert.ToDouble(item[KcAmountField]) - Convert.ToDouble(item[AmountField]);
double ypfAmount = CalcOldAmount();
this.lblFP.Text = ypfAmount + "";
this.lblSY.Text = (total - ypfAmount) + "";
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
public double CalcOldAmount()
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
double total = 0.0;
DataRow[] rowItems = table.Rows.Cast<DataRow>().Where(x => x.RowState == DataRowState.Modified).ToArray();
//DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
if (rowItems != null && rowItems.Length > 0)
{
foreach (DataRow item in rowItems)
{
//if (item == rowItem) continue;
total += Convert.ToDouble(item[AmountField] + "");
}
}
return total;
}
/// <summary>
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void OnGridViewRightCallBack(object sender, EventArgs e)
{
try
{
this.SearchObj.SearchLastGrid();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:取消</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnBtnCancelClick(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// <para>说明:自动分配</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
public void OnBtnFPClick(object sender, EventArgs e)
{
if (OnAfterFPCallback != null)
{
OnAfterFPCallback(this, null);
}
}
public bool FP()
{
bool success = false;
// 分配规则,根据当前行自动分配直到分完为止
try
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
if (table == null || table.Rows.Count == 0)
{
return false;
}
double total = Convert.ToDouble(this.lblTotal.Text);
double totalCopy = total - CalcOldAmount();
double fpAmount = 0.0;
int rowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex();
DataRow item = null;
for (int i = rowIndex; i < table.Rows.Count; i++)
{
item = table.Rows[i];
double kcAmount = Convert.ToDouble(item[KcAmountField] + "");
double check = Convert.ToDouble(item[AmountField] + "");
totalCopy = total - CalcOldAmount();
if (check == 0.0)
{
if (kcAmount >= totalCopy)
{
item[AmountField] = totalCopy;
totalCopy = 0;
}
else
{
//if (fpAmount + kcAmount > total)
//{
// // 最后一次分配
// item[AmountField] = kcAmount - (total - fpAmount);
//}
//else
//{
item[AmountField] = kcAmount;
//}
}
}
fpAmount = Convert.ToDouble(item[AmountField]);
item[JYAmountField] = Convert.ToDouble(item[KcAmountField]) - Convert.ToDouble(item[AmountField]);
this.gcMain.GridView.SelectRowHandler(i);
this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(i, this.gcMain.GridView.Columns[AmountField], fpAmount));
}
//double ypfAmount = CalcYfpAmount() + (item == null ? 0 : Convert.ToDouble(item[AmountField]));
double ypfAmount = CalcOldAmount();
this.lblFP.Text = ypfAmount + "";
this.lblSY.Text = (total - ypfAmount) + "";
if (Convert.ToDouble(this.lblFP.Text) != 0)
{
try
{
List<DataRow> listRows = new List<DataRow>();
foreach (DataRow dataRow in table.Rows)
{
if (dataRow.RowState == DataRowState.Modified && !string.IsNullOrEmpty(dataRow[AmountField] + "") && Convert.ToDouble(dataRow[AmountField] + "") > 0)
{
listRows.Add(dataRow);
}
}
this.SelectedRows = listRows.ToArray();
this.isNextOne = true;
success = true;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show("继续分配出错!" + Message);
success = false;
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show("自动分配出错!" + Message);
}
return success;
}
/// <summary>
/// <para>说明:数量字段发生变化时</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs"/> instance containing the event data.</param>
void OnGridViewCellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
try
{
if (e.Column.Name == this.AmountField)
{
double total = Convert.ToDouble(lblTotal.Text);
double yfpAmount = CalcYfpAmount();
double fpAmount;
if (string.IsNullOrWhiteSpace(e.Value.ToString()))
{
this.gcMain.GridView.SetRowCellValue(e.RowHandle, e.Column, 0);
fpAmount = 0;
}
else
{
// 计算剩余数量
fpAmount = Convert.ToDouble(e.Value + "");
}
// 验证是否超出单行总数
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
double kcAmount = Convert.ToDouble(rowItem[KcAmountField] + "");
if (fpAmount > kcAmount)
{
fpAmount = kcAmount;
this.gcMain.GridView.SetRowCellValue(e.RowHandle, e.Column, fpAmount);
}
// 验证是否超总数
if (yfpAmount + fpAmount > total)
{
fpAmount = total - yfpAmount;
this.gcMain.GridView.SetRowCellValue(e.RowHandle, e.Column, fpAmount);
}
rowItem[JYAmountField] = Convert.ToDouble(rowItem[KcAmountField]) - fpAmount;
fpAmount = yfpAmount + fpAmount;
this.lblFP.Text = fpAmount + "";
this.lblSY.Text = (total - fpAmount) + "";
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:行颜色</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>