using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.LgClassModel; using Core.StlMes.Client.LgCommon; using CoreFS.CA06; using CoreFS.SA06; namespace Core.StlMes.Client.LgResMgt { public partial class NewResultsBase : FrmBase { private DataTable _materialData = null; protected List Plines; protected string CurrentPline; public string uceStatusText { get { return ucStoveQuery1.uceStatusText; } set { ucStoveQuery1.uceStatusText = value; } } protected DataTable DtMaterial { get { if (_materialData == null || _materialData.Rows.Count <= 0) { GetMaterialData(); } return _materialData; } set { _materialData = value; } } protected PlnSteelforfurnaceEntity CurrentEntity = null; protected string Station { get { return Process + (CurrentPline=="C001"?"01": (CurrentPline=="C003"?"02":(CurrentPline=="C006"?"03":"00"))); } } private int Width1 = 300; public int Width2 = 340; public int Width3 = 168; public NewResultsBase() { InitializeComponent(); } public bool OrderByPline { get { return ucStoveQuery1.OrderByPline; } set { ucStoveQuery1.OrderByPline = value; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { if (ob==null) return; Plines = ClsBusinessPack.InitDropPlinePower(OrderByPline?"A":"B", null, this.ValidDataPurviewIds, this.ob); if (Plines == null || Plines.Count <= 0) { MessageBox.Show(@"无产线数据权限"); this.Close(); } else { CurrentPline = Plines[0]; } ucStoveQuery1.GetStoveResultDelegate += GetHeatResult; ucStoveQuery1.Init(ob, Plines, Process); ucStoveQuery1.GiveUp = GiveupResult; ClsControlPack.SetUltraGridAppearance(this); } catch { } } /// /// 工序 /// protected LG_PROCESS Process { get; set; } protected string DeviceName { get; set; } //岗位中文名:如转炉 // 获取物料基础数据 /// /// 获取物料基础数据 /// protected void GetMaterialData() { bool bSuccess; string strMsg; var ds = ClsDataAccessPack.GetMaterialData(out bSuccess, out strMsg, ob); if (bSuccess) _materialData = ds.Tables[0]; } protected void RefreStoveQuery() { ucStoveQuery1.QueryStovePlan(); } protected virtual void Queryother() { } // 获取指定炉次岗位实绩信息 /// /// 获取指定炉次岗位实绩信息 /// /// /// /// /// /// protected void GetHeatResult(PlnSteelforfurnaceEntity PlnSteelforfurnaceEntity,bool refresh) { CurrentEntity = PlnSteelforfurnaceEntity; if (refresh) { QueryPlan(); ucNewChemelEment.RefreshData(CurrentEntity.StoveNo, CurrentEntity.EfPlineCode, Process, CurrentEntity.CraftNo, ob); } else { Query(); } } // 忽略实绩修改 /// /// 忽略实绩修改 /// /// protected bool GiveupResult() { if (ValueChanged && CurrentEntity!=null) if ( MessageBox.Show(@"炉次:" + CurrentEntity.StoveNo + @"\n" + DeviceName + @"实绩已修改,还未保存!\n放弃修改点击【是】,返回请按【否】", @"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return false; return true; } #region 属性 /// /// 实绩数据发生修改 /// protected virtual bool ValueChanged { get { return false; } } protected virtual bool DataOver { get { return false; } } protected virtual bool CanSave { get { return true; } } /// /// 用户名 /// protected string UserName { get { return CoreUserInfo.UserInfo.GetUserName(); } } /// /// 用户名 /// protected string ShifCode { get { return UserInfo.GetUserGroup() + UserInfo.GetUserOrder(); } } #endregion #region 工具栏事件 // 刷新实绩 /// /// 刷新实绩 /// /// protected void RefreshData(bool ignoreChanges) { try { if (!ignoreChanges) { if (!GiveupResult()) return; } Query(); } catch { } } // 保存实绩修改 /// /// 保存实绩修改 /// protected void SaveData() { // if (string.IsNullOrEmpty(HeatProcessNo)) return; if (CurrentEntity == null) return; if (!ValueChanged) { MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "\n" + DeviceName + "实绩未发生变化,无需保存!", "提示"); return; } if (!CanSave) { MessageBox.Show("数据有错误,请修正后再保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if ( MessageBox.Show("确定要修改炉次[" + CurrentEntity.StoveNo + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string Msg = ""; Msg = SaveAllData(Msg); RefreStoveQuery(); if (Msg == "") { if (DataOver) { if (MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "信息保存成功,是否跳入下个未维护信息的炉号!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ucStoveQuery1.GoNext(); } } else //RefreshData(true); MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "信息保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("炉次:" + CurrentEntity.StoveNo + Msg + "!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } protected virtual string SaveAllData(string Msg) { if (!SavePerformance()) Msg = Msg + "操作界面数据保存失败"; return Msg; } protected virtual bool SavePerformance() { return false; } protected virtual void Query() { QueryPlan(); QueryChemeEment(); if (CurrentEntity.EfPlineCode != CurrentPline) { RestPline(); } QueryOperation(); QueryTemperature(); Queryother(); } protected virtual void QueryTemperature() { } /// /// 查询炒作界面 /// protected virtual void QueryOperation() { } protected virtual void QueryPlan() { } protected virtual void RestPline() { CurrentPline = CurrentEntity.EfPlineCode; } private void QueryChemeEment() { ucNewChemelEment.SetData(CurrentEntity.StoveNo, CurrentEntity.EfPlineCode, Process, CurrentEntity.CraftNo, ob); } protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); try { if (!GiveupResult()) e.Cancel = true; } catch { // ignored } } /// /// 功能按钮 /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Refresh": RefreshData(!ValueChanged); break; case "Save": SaveData(); break; case "Exit": Close(); break; } } #endregion private void NewResultsBase_Shown(object sender, EventArgs e) { splitContainer1.SplitterDistance = Width1; spMain.SplitterDistance = spMain.Size.Height - Width3; if(splitContainer2.Panel2Collapsed) return; MainContainer.ExpandedStateChanging+=MainContainer_ExpandedStateChanged; MicContainer.ExpandedStateChanging += MicContainer_ExpandedStateChanged; egpChem.ExpandedStateChanging += egpChem_ExpandedStateChanged; if (Size.Width > 1300) { MicContainer.Expanded = true; splitContainer1.SplitterDistance = Size.Width - 700 - Width2 > Width1 ? Width1 : Size.Width - 700 - Width2; } else { MicContainer.Expanded = false; splitContainer2.SplitterDistance = splitContainer2.Size.Width - 25; } } private void MainContainer_ExpandedStateChanged(object sender, EventArgs e) { if (!MainContainer.Expanded) { splitContainer1.SplitterDistance = Width1; if (MicContainer.Expanded && !splitContainer2.Panel2Collapsed) { splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2; } } else { Width1 = splitContainer1.SplitterDistance; splitContainer1.SplitterDistance = 25; if (MicContainer.Expanded && !splitContainer2.Panel2Collapsed) { splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2; } } } private void MicContainer_ExpandedStateChanged(object sender, EventArgs e) { if (splitContainer2.Panel2Collapsed) return; if (!MicContainer.Expanded) { splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2; /* if (MainContainer.Expanded) { splitContainer1.SplitterDistance = Width1; }*/ } else { Width2 = splitContainer2.Panel2.Size.Width; splitContainer2.SplitterDistance = splitContainer2.Size.Width - 25; } } private void egpChem_ExpandedStateChanged(object sender, EventArgs e) { if (spMain.Panel2Collapsed) return; if (!egpChem.Expanded) { spMain.SplitterDistance = spMain.Size.Height - Width3; } else { Width3 = spMain.Panel2.Size.Height; spMain.SplitterDistance = spMain.Size.Height - 25; } } } }