ab56a9bcf7
SVN-Revision: r240
127 lines
5.8 KiB
C#
127 lines
5.8 KiB
C#
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
using Lskj.Control;
|
|
using Lskj.Core;
|
|
using Lskj.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace mes_BgManage
|
|
{
|
|
public partial class UnionControl : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 跳转值
|
|
/// </summary>
|
|
public int focusToIndex;
|
|
public UnionControl()
|
|
{
|
|
InitializeComponent();
|
|
this.SizeChanged += new EventHandler(OnFrmMain_SizeChanged);
|
|
}
|
|
public DynamicBgModel pubModel;
|
|
public string gridIndex = "";
|
|
/// <summary>
|
|
/// 初始化中间关联字段
|
|
/// </summary>
|
|
public void InitUnionControl(DynamicBgModel model)
|
|
{
|
|
BindingGridStructure();
|
|
this.pubModel = model;
|
|
string leftSql = string.Format(@"select a.productid,a.appellation,a.model,a.spec from bg_productidmainView a where 1=1 and a.model like '{0}'", model.textBox);
|
|
this.leftGcEX.GridControl.DataSource = SqlHelper.ExecuteDataTable(leftSql);
|
|
this.leftGcEX.GridView.FocusedRowChanged += new FocusedRowChangedEventHandler(OnLeftGridViewFocusedRowChanged);
|
|
this.rightGcEX.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
}
|
|
/// <summary>
|
|
/// 左侧表选中触发改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnLeftGridViewFocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
|
{
|
|
DataRow rowItem = this.leftGcEX.GridView.GetFocusedDataRow();
|
|
string detailSql = string.Format("select a.id,a.ProductId,a.Model,a.Spec,a.OriginBill from P_FixedAssetsMlTab a where a.SbBillid='{0}' and ZtTig='1'", rowItem["productid"] + "");
|
|
this.rightGcEX.GridControl.DataSource = SqlHelper.ExecuteDataTable(detailSql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:表格双击打开模块配置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-04-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
string sqlStr = "select MIN(a.id) from [dbo].[Fn_StringSplitToTable]('1,2,3,4,5,6',',') a where a.id not in (select a.siteid from P_FixedAssetsDYTab a where a.planlistid='{0}')";
|
|
sqlStr = string.Format(sqlStr, pubModel.Clientid);
|
|
int index = Convert.ToInt32(SqlHelper.ExecuteScalar(sqlStr) + "");
|
|
if (index < Convert.ToInt32(pubModel.gridIndex))
|
|
{
|
|
MessageUtil.Show("请按顺序添加,不能跳版!");
|
|
this.focusToIndex = index;
|
|
this.Close();
|
|
this.DialogResult = DialogResult.OK;
|
|
return;
|
|
}
|
|
if (pubModel.rowCount > 0)
|
|
{
|
|
MessageUtil.Show("已存在版辊!");
|
|
return;
|
|
}
|
|
string document_id = string.Format("select DBO.p_Getbillid('8000301', '')");
|
|
document_id = SqlHelper.ExecuteScalar(document_id) + "";
|
|
DataRow rowItem = this.rightGcEX.GridView.GetFocusedDataRow();
|
|
string doubEvenSql = string.Format(@"INSERT P_FixedAssetsDYTab (DYbilldocument_id,LProductid,JtID,operatename,operatedate,planlistid,siteid) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", document_id, rowItem["ProductId"] + "", pubModel.DyBgModel, pubModel.BgArg6, DateTime.Now.ToString(), pubModel.Clientid, pubModel.gridIndex);
|
|
string updEvenSql = string.Format(@"UPDATE P_FixedAssetsMlTab SET ZtTig=3,jtwz='{0}' where ProductId='{1}'", pubModel.DyBgModel, rowItem["ProductId"] + "");
|
|
SqlHelper.ExecuteNonQuery(doubEvenSql);
|
|
SqlHelper.ExecuteNonQuery(updEvenSql);
|
|
this.Close();
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 绑定表结构
|
|
/// </summary>
|
|
private void BindingGridStructure()
|
|
{
|
|
#region 左侧表结构
|
|
this.leftGcEX.GridView.Columns.AddVisible("productid", "版辊套号");
|
|
this.leftGcEX.GridView.Columns.AddVisible("appellation", "版辊名称");
|
|
this.leftGcEX.GridView.Columns.AddVisible("model", "版辊型号");
|
|
this.leftGcEX.GridView.Columns.AddVisible("spec", "版辊规格");
|
|
this.leftGcEX.GridView.OptionsView.ShowIndicator = false;
|
|
this.leftGcEX.GridView.OptionsBehavior.Editable = false;
|
|
#endregion
|
|
#region 右侧表结构
|
|
this.rightGcEX.GridView.Columns.AddVisible("id", "明细序号");
|
|
this.rightGcEX.GridView.Columns.AddVisible("ProductId", "版辊编号");
|
|
this.rightGcEX.GridView.Columns.AddVisible("Model", "版辊型号");
|
|
this.rightGcEX.GridView.Columns.AddVisible("Spec", "版辊规格");
|
|
this.rightGcEX.GridView.Columns.AddVisible("OriginBill", "版辊钢号");
|
|
this.rightGcEX.GridView.OptionsView.ShowIndicator = false;
|
|
this.rightGcEX.GridView.OptionsBehavior.Editable = false;
|
|
#endregion
|
|
}
|
|
/// <summary>
|
|
/// 调整宽度
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMain_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
this.leftPanel.Width = this.rightPanel.Width = this.mainPanel.Width / 2;
|
|
}
|
|
}
|
|
}
|