| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.LgClassModel;
- using Core.StlMes.Client.LgCommon;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgResMgt
- {
- public partial class ucTempManualSampling : UserControl
- {
- public ucTempManualSampling()
- {
- InitializeComponent();
- }
- public bool Changed
- {
- get
- {
- return _changed ? _changed : datas != null && datas.Any() && datas.Any(p => p.NewRow); }
- }
- public bool CanSave
- {
- get { return datas.All(p => p.Valid); }
- }
- private List<StlCcmF1samplingEntity> datas;
- private string _stove = "";
- private string _station = "";
- private string _disposalTime = "";
- private bool _changed = false;
- private OpeBase _ob;
- public bool SaveDate()
- {
- if (_ob == null) return false;
- if (!Changed || datas == null) return true;
- if (!CanSave)
- {
- MessageBox.Show("温度数据不正确,无法保存温度数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return true;
- }
- try
- {
- ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlTemperature.SaveCcmTemperature", new object[] { datas, _stove,
- _station,_disposalTime }, _ob);
- Refresh();
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
- public void SetData(string Stove, string station, string disposalTime, OpeBase ob)
- {
- _stove = Stove;
- _station = station;
- _disposalTime = disposalTime;
- if (_ob == null) _ob = ob;
- Refresh();
- }
- private void Refresh()
- {
- if (_ob == null) return;
- datas =
- EntityHelper.GetData<StlCcmF1samplingEntity>(
- "Core.LgMes.Server.LgDeviceManager.StlTemperature.GetCastSamp",
- new[]
- {
- _stove,
- _station,
- _disposalTime
- }, _ob) ?? new DataSourceList<StlCcmF1samplingEntity>();
- ugTem.DataBindings.Clear();
- ugTem.DataSource = datas;
- if (datas.Count >= 0)
- {
- ClsControlPack.RefreshAndAutoSize(ugTem);
- }
- _changed = false;
- }
-
- private void tsmAdd_Click(object sender, EventArgs e)
- {
- if (datas == null) return;
- datas.Add(new StlCcmF1samplingEntity() { NewRow = true, Valid = false, Optdate = DateTime.Now });
- ugTem.DataBind();
- ugTem.Rows[ugTem.Rows.Count - 1].Appearance.BackColor = Color.Orange;
- if (ugTem.Rows.Count <= 1)
- {
- ClsControlPack.RefreshAndAutoSize(ugTem);
- }
- }
- private void tsmDelete_Click(object sender, EventArgs e)
- {
- if (ugTem.ActiveRow == null)
- {
- MessageBox.Show("请选中一行再进行删除");
- return;
- }
- StlCcmF1samplingEntity StlCcmF1samplingEntity = ugTem.ActiveRow.ListObject as StlCcmF1samplingEntity;
- if (StlCcmF1samplingEntity != null && !StlCcmF1samplingEntity.NewRow)
- {
- _changed = true;
- }
- datas.RemoveAt(ugTem.ActiveRow.Index);
- }
- private void ugTem_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- ugTem.UpdateData();
- }
- catch (Exception)
- {
- }
- }
- private void ugTem_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
- {
- e.Row.Appearance.BackColor = Color.Orange;
- }
- private void ugTem_BeforeRowsDeleted(object sender, Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs e)
- {
- if (e.Rows != null)
- {
- StlCcmF1samplingEntity StlCcmF1samplingEntity = e.Rows[0].ListObject as StlCcmF1samplingEntity;
- if (StlCcmF1samplingEntity != null && !StlCcmF1samplingEntity.NewRow)
- {
- _changed = true;
- }
- }
- }
- private void ugTem_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Value = DateTime.Now;
- }
- private void ugTem_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- StlCcmF1samplingEntity StlCcmF1samplingEntity = ugTem.ActiveRow.ListObject as StlCcmF1samplingEntity;
- if (StlCcmF1samplingEntity != null)
- {
- if (StlCcmF1samplingEntity.NewRow)
- {
- if (StlCcmF1samplingEntity.Optdate == null
- || StlCcmF1samplingEntity.Midladle1weight == null
- || StlCcmF1samplingEntity.Midladletemp ==null
-
- )
- {
- ugTem.Rows[ugTem.ActiveRow.Index].Appearance.BackColor = Color.Orange;
- StlCcmF1samplingEntity.Valid = false;
- }
- else
- {
- ugTem.Rows[ugTem.ActiveRow.Index].Appearance.BackColor = Color.LightGreen;
- StlCcmF1samplingEntity.Valid = true;
- }
- }
- else
- {
- ugTem.Rows[ugTem.ActiveRow.Index].Appearance.BackColor = Color.Orange;
- StlCcmF1samplingEntity.Valid = false;
- _changed = true;
- }
- }
- }
- private void ugTem_CellChange(object sender, CellEventArgs e)
- {
- try
- {
- ugTem.UpdateData();
- }
- catch (Exception)
- {
- }
- }
- private void ugTem_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- var uieOver = ugTem.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));
- if (uieOver != null)
- {
- UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow;
- ugTem.ActiveRow = ugrOver;
- }
- }
- }
- private void ucTempManualSampling_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<StlCcmF1samplingEntity>(ugTem.DisplayLayout.Bands[0]);
- }
- }
- }
|