ab56a9bcf7
SVN-Revision: r240
239 lines
9.7 KiB
C#
239 lines
9.7 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Control;
|
|
using Lskj.Core;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
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;
|
|
|
|
namespace mes_BgManage
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
|
|
#region 公共字段
|
|
/// <summary>
|
|
/// 公共版焜入口参数
|
|
/// </summary>
|
|
public DynamicBgModel moduleModel;
|
|
/// <summary>
|
|
/// 版辊所关联的所有表格
|
|
/// </summary>
|
|
public List<GridControlEx> GridList = new List<GridControlEx>();
|
|
/// <summary>
|
|
/// 版辊所关联的所有表格
|
|
/// </summary>
|
|
public List<TextBox> TextList = new List<TextBox>();
|
|
/// <summary>
|
|
/// 所有删除按钮
|
|
/// </summary>
|
|
public List<SimpleButton> DelBtnList = new List<SimpleButton>();
|
|
/// <summary>
|
|
/// 所有panel
|
|
/// </summary>
|
|
public List<DevExpress.XtraEditors.PanelControl> panControlList = new List<DevExpress.XtraEditors.PanelControl>();
|
|
#endregion
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:窗体加载时</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
InitControls();
|
|
SetFormPoint();
|
|
AutoColWidth();
|
|
}
|
|
#region 方法
|
|
/// <summary>
|
|
/// <para>说明:创建界面</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-04-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitControls()
|
|
{
|
|
this.GridList.AddRange(new List<GridControlEx> { oneGcEX, twoGcEX, thrGcEX, forGcEX, fivGcEX, sixGcEX });//注册表格界面集合
|
|
this.TextList.AddRange(new List<TextBox> { oneText, twoText, thrText, forText, fivText, sixText });//注册文本框集合
|
|
this.DelBtnList.AddRange(new List<SimpleButton> { oneDelbtn, twoDelBtn, thrDelBtn, forDelBtn, fivDelBtn, sixDelBtn });
|
|
this.panControlList.AddRange(new List<DevExpress.XtraEditors.PanelControl> { oneGcPanel, twoGcPanel, thrGcPanel, forGcPanel, fivGcPanel, sixGcPanel });
|
|
this.SizeChanged += new EventHandler(OnFrmMain_SizeChanged);
|
|
this.FormClosing += new FormClosingEventHandler(OnFrmMain_FormClosing);
|
|
BindingGridStructure();
|
|
BindingDelBtnEvent();
|
|
InitTextEven();
|
|
InitGridData();
|
|
}
|
|
/// <summary>
|
|
/// 绑定所有删除按钮的点击事件
|
|
/// </summary>DyBgModel Clientid
|
|
private void BindingDelBtnEvent()
|
|
{
|
|
for (int i = 0; i < this.DelBtnList.Count; i++)
|
|
{
|
|
DelBtnList[i].Click += new EventHandler(OnFrmMain_Click);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 绑定所有文本的回车事件
|
|
/// </summary>DyBgModel Clientid
|
|
public void InitTextEven()
|
|
{
|
|
for (int i = 0; i < TextList.Count; i++)
|
|
{
|
|
TextList[i].KeyDown += OnKeyDown;
|
|
TextList[i].Tag = i + 1;
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 所有文本框的回车事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
TextBox textBox = sender as TextBox;
|
|
moduleModel.gridIndex = textBox.Tag + "";
|
|
moduleModel.textBox = textBox.Text;
|
|
moduleModel.rowCount = this.GridList[Convert.ToInt32(moduleModel.gridIndex) - 1].GridView.DataRowCount;
|
|
// 弹出版锟控件
|
|
UnionControl frmAddRole = new UnionControl();
|
|
frmAddRole.InitUnionControl(moduleModel);
|
|
if (frmAddRole.ShowDialog() == DialogResult.OK)
|
|
{
|
|
TextList[frmAddRole.focusToIndex - 1].Focus();
|
|
InitGridData();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 所有删除按钮点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMain_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DevExpress.XtraEditors.SimpleButton delBtn = (DevExpress.XtraEditors.SimpleButton)sender;
|
|
int btnIndex = this.DelBtnList.IndexOf(delBtn);
|
|
int focusRowIndex = GridList[btnIndex].GridView.GetFocusedDataSourceRowIndex();
|
|
DataRow focusRow = (GridList[btnIndex].gridControl.DataSource as DataTable).Rows[focusRowIndex];
|
|
string delSqlStr = string.Format("delete from P_FixedAssetsDYTab where id='{0}';update P_FixedAssetsMlTab set ZtTig=1 where id='{1}'", focusRow["id"] + "", focusRow["pid"] + "");
|
|
SqlHelper.ExecuteNonQuery(delSqlStr);
|
|
this.InitGridData();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 调整宽度
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMain_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
AutoColWidth();
|
|
}
|
|
/// <summary>
|
|
/// 记录位置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMain_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
IniHelper.Write(string.Format("mes_BgManagePointX_{0}", this.moduleModel.ModuleCode), this.Location.X + "");
|
|
IniHelper.Write(string.Format("mes_BgManagePointY_{0}", this.moduleModel.ModuleCode), this.Location.Y + "");
|
|
IniHelper.Write(string.Format("mes_BgManageSizeWidth_{0}", this.moduleModel.ModuleCode), this.Size.Width + "");
|
|
IniHelper.Write(string.Format("mes_BgManageSizeHeight_{0}", this.moduleModel.ModuleCode), this.Size.Height + "");
|
|
}
|
|
/// <summary>
|
|
/// 绑定所有表格的表结构
|
|
/// </summary>DyBgModel Clientid
|
|
private void BindingGridStructure()
|
|
{
|
|
for (int i = 0; i < this.GridList.Count; i++)
|
|
{
|
|
GridControlEx gridEx = GridList[i];
|
|
gridEx.GridView.Columns.AddVisible("ProductId", "版辊编码");
|
|
gridEx.GridView.Columns.AddVisible("Appellation", "版辊名称");
|
|
gridEx.GridView.Columns.AddVisible("Model", "版辊型号");
|
|
gridEx.GridView.Columns.AddVisible("Spec", "版辊规格");
|
|
gridEx.GridView.Columns.AddVisible("OriginBill", "版辊钢号");
|
|
gridEx.GridView.Columns["ProductId"].Visible = false;
|
|
gridEx.GridView.OptionsView.ShowIndicator = false;
|
|
gridEx.GridView.OptionsBehavior.Editable = false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 调整宽度
|
|
/// </summary>
|
|
private void AutoColWidth()
|
|
{
|
|
for (int i = 0; i < this.panControlList.Count; i++)
|
|
{
|
|
panControlList[i].Width = this.mainPanel.Width / 6;
|
|
}
|
|
}
|
|
private void SetFormPoint()
|
|
{
|
|
try
|
|
{
|
|
string pointX = IniHelper.Read(string.Format("mes_BgManagePointX_{0}", this.moduleModel.ModuleCode));
|
|
string pointY = IniHelper.Read(string.Format("mes_BgManagePointY_{0}", this.moduleModel.ModuleCode));
|
|
string sizeWidth = IniHelper.Read(string.Format("mes_BgManageSizeWidth_{0}", this.moduleModel.ModuleCode));
|
|
string sizeHeight = IniHelper.Read(string.Format("mes_BgManageSizeHeight_{0}", this.moduleModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(pointX) && !string.IsNullOrEmpty(pointY))
|
|
{
|
|
this.Location = new Point(Convert.ToInt32(pointX), Convert.ToInt32(pointY));
|
|
}
|
|
if (!string.IsNullOrEmpty(sizeWidth) && !string.IsNullOrEmpty(sizeHeight))
|
|
{
|
|
this.Size = new Size(Convert.ToInt32(sizeWidth), Convert.ToInt32(sizeHeight));
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 初始化所有表格的数据源
|
|
/// </summary>DyBgModel Clientid
|
|
public void InitGridData()
|
|
{
|
|
for (int i = 0; i < GridList.Count; i++)
|
|
{
|
|
String gridDataSql = string.Format(@"select aa.ProductId,aa.Appellation,aa.Model,aa.Spec,aa.OriginBill,a.id,aa.id as pid from P_FixedAssetsDYTab a
|
|
join P_FixedAssetsMlTab aa on a.LProductid = aa.ProductId
|
|
where a.JtID = '{0}' and a.planlistid = '{1}' and a.siteid = '{2}'", moduleModel.DyBgModel, moduleModel.Clientid, i + 1);
|
|
GridList[i].gridControl.DataSource = SqlHelper.ExecuteDataTable(gridDataSql);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|