| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560 |
- using com.steering.mes.zgmil.entity;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.ZGMil.Common;
- using Core.StlMes.Client.ZGMil.Entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.ZGMil.Signature
- {
- public partial class FrmMilControlLog : FrmBase
- {
- private string departm = "";
- UltraComboEditor ucePline = new UltraComboEditor();//产线名称
- private string plineCode;
- private string[] plineCodes = { };
- private string userId = "";
- //int stratday;//开始时间日期差,天,时,分
- //int strathours;
- //int stratminutes;
- //int endday;//结束时间日期差,天,时,分
- //int endhours;
- //int endminutes;toolba
- int flag = 0;//分析时间错误
- int flag1 = 0;//分析相差时间
- private string basecodeSamll = "";//停机小类值
- private string basecodeReason = "";//停机原因值
- public FrmMilControlLog()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- private void FrmMilControlLog_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<MilControlLogEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<MilControlLogEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- NativeMethodNew na = new NativeMethodNew(this.ob);
- departm = UserInfo.GetDepartment();
- userId = UserInfo.GetUserID();
- plineCode = na.GetPCode(departm);//获取 用户 对应的产线
- plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob);
- //cmbPline.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob);
- //cmbPline.ValueMember = "PLINE_CODE";
- //cmbPline.DisplayMember = "PLINE_NAME";
- //TubeRoll.SetComboItemHeight(cmbPline);
- //cmbPlineE.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob);
- //cmbPlineE.ValueMember = "PLINE_CODE";
- //cmbPlineE.DisplayMember = "PLINE_NAME";
- //TubeRoll.SetComboItemHeight(cmbPlineE);
- //cmbDate.MaxDate = DateTime.Now;
- if (!plineCode.Equals("C072"))
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["Dept"].Hidden = true;
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["Dept"].Hidden = true;
- }
-
- cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
- cmbPline.Value = na.GetPCodePline(this.ValidDataPurviewIds);
- TubeRoll.setUltraGridColumnInput(ultraGrid1, new string[] { "QualifiedNum", "ScrapNum" });//支数
- TubeRoll.setUltraGridColumnMaxInput(ultraGrid1, new string[] { "QualifiedWt", "ScrapWt" });//重量
- TubeRoll.SetComboItemHeight(cmbPline);
- TubeRoll.SetComboItemHeight(cmbBc);
- TubeRoll.SetComboItemHeight(cmbBz);
- DataTable dt = TubeRoll.GetComBaseInfo("5006", ob);
- cmbStop.DataSource = dt;
- cmbStop.ValueMember = "BASECODE";
- cmbStop.DisplayMember = "BASENAME";
- TubeRoll.SetComboItemHeight(cmbStop);
- DataTable dt2 = TubeRoll.GetComBaseInfo("5011", ob);
- cmbDept.DataSource = dt2;
- cmbDept.ValueMember = "BASECODE";
- cmbDept.DisplayMember = "BASENAME";
- TubeRoll.SetComboItemHeight(cmbDept);
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- doQuery();
- break;
- case "Add":
- doAdd();
- break;
- case "Update":
- doUpdate();
- break;
- case "Delete":
- doDelete();
- break;
- case "Analysis":
- doQuery();
- doAnalysis();
- break;
- case "Confirm":
- doConfirm();
- break;
- case "UpConfirm":
- UpConfirm();
- break;
- case "OneKeyProces":
- DoOneKeyProces();
- break;
- case "Statistical":
- DoStatistical();
- break;
- case "OneKeyUpdate":
- DoOneKeyUpdate();
- break;
- case "Production":
- DoProduction();
- break;
- case "Export":
- GridHelper.ulGridToExcel(ultraGrid1, "轧管调度日志");
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 生产记录
- /// </summary>
- private void DoProduction()
- {
- FrmProductionDetails pro = new FrmProductionDetails(cmbDate.Value.ToString("yyyyMMdd"), plineCode, this.ob);
- pro.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- pro.Text = "生产详细";
- pro.ShowDialog();
- }
- /// <summary>
- /// 查询统计数据
- /// </summary>
- private void DoStatistical()
- {
- //string date = "";
- // string endDate = "";
- // if (chkDate.Checked)
- // {
- // if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
- // {
- // MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
- // return;
- // }
- // else
- // {
- // date = cmbDate.Value.ToString("yyyyMMddHHmm");
- // endDate = cmbEndDate.Value.ToString("yyyyMMddHHmm");
- // }
- // }
- // else
- // {
- // MessageUtil.ShowTips("请选择日期!");
- // return;
- // }
- //doQuery();
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
- //foreach (UltraGridRow urg in ultraGrid1.Rows)
- //{
- // if (row.Cells["ConfirmFlag"].Text.Equals("未确认")) { MessageUtil.ShowTips("未确认,不允许此操作!"); return; }
- //}
- FrmStatistical fsta = new FrmStatistical(plineCode, ob);
- fsta.AutoSize = true;
- fsta.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fsta.Text = "统计查询";
- fsta.ShowDialog();
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQuery()
- {
- ArrayList list = new ArrayList();
- //当天
- string date = "";
- //前一天
- string endDate = "";
- date = cmbDate.Value.ToString("yyyyMMdd");
- endDate = cmbDate.Value.AddDays(-1).ToString("yyyyMMdd");
- //当班数据
- List<MilControlLogEntity> listSource = EntityHelper.GetData<MilControlLogEntity>
- ("com.steering.mes.signature.FrmMilControlLog.doQueryPlan", new object[] { date, endDate, this.UserInfo.GetUserOrder(), this.UserInfo.GetUserGroup(), plineCodes, "" }, this.ob);
- MilControlLogEntity.DataSource = listSource;
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].MaskInput = "yyyy-mm-dd hh:mm";
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].MaskInput = "yyyy-mm-dd hh:mm";
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["ProType"].Text.ToString().Trim().Equals("停机"))
- {
- row.Cells["StopType"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["StopReasonm"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["StopSmallm"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["Dept"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- else
- {
- row.Cells["StopType"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["StopReasonm"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["StopSmallm"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["Dept"].Appearance.BackColor = Color.Transparent;
- row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- }
- //上一个班数据
- string shift = "";
- if (this.UserInfo.GetUserOrder().Equals("1"))
- {
- shift = "3";
- }
- if (this.UserInfo.GetUserOrder().Equals("2"))
- {
- shift = "1";
- }
- if (this.UserInfo.GetUserOrder().Equals("3"))
- {
- if (plineCode.Equals("C072"))
- {
- shift = "2";
- }
- else
- {
- shift = "0";
- }
- date = endDate;
- }
- if (this.UserInfo.GetUserOrder().Equals("0"))
- {
- shift = "3";
- }
- List<MilControlLogEntity> listSource2 = EntityHelper.GetData<MilControlLogEntity>
- ("com.steering.mes.signature.FrmMilControlLog.doQueryPlan", new object[] { date, endDate, shift, this.UserInfo.GetUserGroup(), plineCodes, "" }, this.ob);
- MilControlLogEntity2.DataSource = listSource2;
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsBeg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsBeg"].MaskInput = "yyyy-mm-dd hh:mm";
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsEnd"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsEnd"].MaskInput = "yyyy-mm-dd hh:mm";
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.Cells["ProType"].Text.ToString().Trim().Equals("停机"))
- {
- row.Cells["StopType"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["StopReasonm"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["StopSmallm"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- row.Cells["Dept"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
- row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.None;
- row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- else
- {
- row.Cells["StopType"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["StopReasonm"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["StopSmallm"].Appearance.BackColor = Color.Transparent;
- row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- row.Cells["Dept"].Appearance.BackColor = Color.Transparent;
- row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.Default;
- row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 一键处理新增(分析后五分钟以内的时间间隔)
- /// </summary>
- private void DoOneKeyProces()
- {
- ultraGrid1.UpdateData();
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; }
- int minutes = int.Parse(MinTime.Value.ToString());
- if (minutes == 0) { MessageUtil.ShowTips("请输入相差时间!"); }
- ArrayList pram = new ArrayList();
- if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
- if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; }
- if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
- int i = 0;
- try
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
- //{
- // MessageUtil.ShowTips("已确认数据,不允许此操作!");
- // return;
- //}
- if (!ugr.Cells["LogsEnd"].Value.Equals(""))
- {
- i += 1;
- }
- }
- for (int j = 0; j < i; j++)
- {
- string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
- string loagBeg = "";
- if (j + 1 < i)
- {
- loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
- if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
- {
- if (TubeRoll.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) <= minutes
- && TubeRoll.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) > 0)
- {
- ArrayList list = new ArrayList();
- list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list.Add(this.UserInfo.GetUserName());
- list.Add(this.UserInfo.GetUserOrder());
- list.Add(this.UserInfo.GetUserGroup());
- list.Add(plineCode);
- pram.Add(list);
- }
- }
- }
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否一键新增处理?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "oneKeyProcesMilControlLog";
- ccp.ServerParams = new object[] { pram };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("一键处理成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("开始时间或结束时间不能为空!");
- }
- }
- /// <summary>
- /// 一键修改
- /// </summary>
- private void DoOneKeyUpdate()
- {
- ultraGrid1.UpdateData();
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; }
- ArrayList pram = new ArrayList();
- if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
- if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; }
- //if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
- int i = 0;
- try
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
- //{
- // MessageUtil.ShowTips("已确认数据,不允许此操作!");
- // return;
- //}
- if (!ugr.Cells["LogsEnd"].Value.Equals(""))
- {
- i += 1;
- }
- }
- for (int j = 0; j < i; j++)
- {
- string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
- string loagBeg = "";
- if (j + 1 < i)
- {
- loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
- if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
- {
- ArrayList list = new ArrayList();
- list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list.Add(this.UserInfo.GetUserName());
- list.Add(this.UserInfo.GetUserOrder());
- list.Add(this.UserInfo.GetUserGroup());
- list.Add(plineCode);
- list.Add(ultraGrid1.Rows[j].Cells["ControlId"].Value.ToString());
- pram.Add(list);
- }
- }
- }
- if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
- {
- int a = ultraGrid2.Rows.Count;
- string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString();
- string logsEnd = ultraGrid2.Rows[a - 1].Cells["LogsEnd"].Value.ToString();
- string ControlId = ultraGrid1.Rows[0].Cells["ControlId"].Value.ToString();
- if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0)
- {
- logsEnd = DateTime.Parse(logsEnd).ToString("yyyyMMddHHmm");
- ServerHelper.SetData("com.steering.mes.signature.FrmMilControlLog.updateOneDate", new object[] { logsEnd, ControlId }, this.ob);
- }
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否一键修改处理?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "oneKeyUpdateMilControlLog";
- ccp.ServerParams = new object[] { pram };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("一键处理成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("开始时间或结束时间不能为空!");
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- ultraGrid1.UpdateData();
- ArrayList pram = new ArrayList();
- UltraGridRow row = ultraGrid1.ActiveRow;
- int count = 0;
- int statrindex = 0;//第一行记录
- int endindex = 0;//最后一行记录
- int indexEnd = 0;//获取Grid最后一行记录
- string statime = "";//新增开始时间
- string endtime = "";//新增结束时间
- string datetime1 = "";//获取选中第一行结束时间
- string datetime2 = "";//获取选中第二行开始时间
- if (row != null)
- {
- try
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
- //{
- // MessageUtil.ShowTips("已确认数据,不允许此操作!");
- // return;
- //}
- statime = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm");//新增开始时间
- datetime1 = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm");
- statrindex = ugr.Index;
- break;
- }
- }
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- count += 1;
- endindex = ugr.Index;
- endtime = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm");//新增结束时间
- datetime2 = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm");
- }
- indexEnd = ugr.Index;
- }
- //判断选中的两行没有时间差,不许增加
- int cnt = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Count();
- if (datetime2 == datetime1 && cnt > 1)
- { MessageUtil.ShowTips("选中的两行没有时间差,不允许增加!"); return; }
- int index = endindex - statrindex;
- if (index == 0)
- {
- if (statrindex == 0)//获取第一行
- {
- if (indexEnd == 0)//如果只有一条数据
- {
- FrmPopupWindow win = new FrmPopupWindow();
- win.AutoSize = true;
- win.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- win.Text = "提示";
- win.ShowDialog();
- if (win.DialogResult == System.Windows.Forms.DialogResult.OK)
- {
- if (win.Popup == "之前")
- {
- pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- }
- else if (win.Popup == "之后")
- {
- pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- }
- else
- {
- return;
- }
- }
- }
- else
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- }
- }
- }
- }
- else if (statrindex == indexEnd)//获取最后一行
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
- }
- }
- }
- else
- {
- if (count == 0 || count > 2 || count < 2 && index < 2)
- {
- MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
- {
- return;
- }
- pram.Add(statime);
- pram.Add(endtime);
- }
- }
- else
- {
- if (count == 0 || count > 2 || count < 2 && index < 2)
- {
- MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
- {
- return;
- }
- pram.Add(statime);
- pram.Add(endtime);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("开始时间或结束时间不能为空!");
- return;
- }
- }
- else//Grid 为空
- {
- if (MessageUtil.ShowYesNoAndQuestion("当前班次无数据是否新增?") == DialogResult.No)
- {
- return;
- }
- pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm"));
- pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm"));
- //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm"));
- //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm"));
- }
- pram.Add(this.UserInfo.GetUserName());
- pram.Add(this.UserInfo.GetUserOrder());
- pram.Add(this.UserInfo.GetUserGroup());
- pram.Add(plineCode);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "addMilControlLog";
- ccp.ServerParams = new object[] { pram };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("新增成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doUpdate()
- {
- ultraGrid1.UpdateData();
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
- int count = 0;
- int statrindex = 0;//选择行记录
- int endindex = 0;//最后一行记录
- //if (flag == false) { MessageUtil.ShowTips("未分析或分析后数据不通过!"); return; }
- ArrayList list = new ArrayList();
- try
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- count += 1;
- if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
- {
- MessageUtil.ShowTips("已确认数据,不允许此操作!");
- return;
- }
- if (ugr.Cells["ProType"].Text.Equals("正常") && ugr.Cells["QualifiedNum"].Text.Equals("0") && ugr.Cells["ScrapNum"].Text.Equals("0"))
- {
- MessageUtil.ShowTips("此炉的生产支数和废品支数都为0,请联系【连轧】做【交接班】或【结炉】处理!");
- return;
- }
- //string plineCode1 = "";
- //if (!ugr.Cells["PlineCode"].Text.ToString().Equals(""))
- //{
- // plineCode1 = ugr.Cells["PlineCode"].Value.ToString();
- //}
- string stopType = "";
- if (!ugr.Cells["StopType"].Text.ToString().Equals(""))
- {
- stopType = ugr.Cells["StopType"].Value.ToString();
- }
- string stopReason = "";
- if (!ugr.Cells["StopReasonm"].Text.ToString().Equals(""))
- {
- stopReason = basecodeReason;// ugr.Cells["StopReason"].Value.ToString();
- }
- string stopSmall = "";
- if (!ugr.Cells["StopSmallm"].Text.ToString().Equals(""))
- {
- stopSmall = basecodeSamll;// ugr.Cells["StopSmall"].Value.ToString();
- }
- string dept = "";
- if (!ugr.Cells["Dept"].Text.ToString().Equals(""))
- {
- dept = ugr.Cells["Dept"].Value.ToString();
- }
- string bc = "";
- if (!ugr.Cells["ProBc"].Text.ToString().Equals(""))
- {
- bc = ugr.Cells["ProBc"].Value.ToString();
- }
- string bz = "";
- if (!ugr.Cells["ProBz"].Text.ToString().Equals(""))
- {
- bz = ugr.Cells["ProBz"].Value.ToString();
- }
- if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString()))
- {
- MessageUtil.ShowTips("开始时间不能大于等于结束时间!");
- return;
- }
- ArrayList pram = new ArrayList();
- pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyy-MM-dd HH:mm"));
- pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyy-MM-dd HH:mm"));
- pram.Add(plineCode);
- pram.Add(stopType);
- pram.Add(stopReason);
- pram.Add(ugr.Cells["QualifiedNum"].Value.ToString());
- pram.Add(ugr.Cells["QualifiedWt"].Value.ToString());
- pram.Add(ugr.Cells["ScrapNum"].Value.ToString());
- pram.Add(ugr.Cells["ScrapWt"].Value.ToString());
- pram.Add(bc);
- pram.Add(bz);
- pram.Add(ugr.Cells["ControlId"].Value.ToString());
- pram.Add(stopSmall);
- pram.Add(ugr.Cells["Memo"].Value.ToString());
- pram.Add(dept);
- list.Add(pram);
- }
- }
- int index = endindex - statrindex;
- if (count == 0 || count > 1)
- {
- MessageUtil.ShowTips("请选择一条需要修改的数据!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "updateMilControlLog";
- ccp.ServerParams = new object[] { list ,"0"};
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("修改成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("开始时间或结束时间不能为空!");
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void doDelete()
- {
- ultraGrid1.UpdateData();
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
- int count = 0;
- ArrayList list = new ArrayList();
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- count += 1;
- //只有各厂总账号可以删除正常数据,普通账号只可删除停机数据。
- if (userId != "250001" && userId != "1680001" && userId != "2580001" && userId != "4600001" && userId != "5080001")
- {
- if (ugr.Cells["ProType"].Text.Equals("正常"))
- {
- MessageUtil.ShowTips("请选择停机数据!");
- return;
- }
- }
-
- if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
- {
- MessageUtil.ShowTips("已确认数据,不允许此操作!");
- return;
- }
- ArrayList pram = new ArrayList();
- pram.Add(ugr.Cells["ControlId"].Value.ToString());
- list.Add(pram);
- }
- }
- if (count == 0)
- {
- MessageUtil.ShowTips("请选择要删除的停机数据!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "deleteMilControlLog";
- ccp.ServerParams = new object[] { list };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("删除成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- /// <summary>
- ///分析
- /// </summary>
- private void doAnalysis()
- {
- flag = 1;
- flag1 = 0;
- int i = 0;
- try
- {
- //当班数据分析
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (!ugr.Cells["LogsEnd"].Value.Equals(""))
- { i += 1; }
- if (!ugr.Cells["LogsEnd"].Value.Equals(""))
- {
- if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString()))
- {
- ugr.RowSelectorAppearance.BackColor = Color.Red;
- //ugr.Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
- //ugr.Cells["LogsEnd"].Appearance.BackColor = Color.Red;
- //ugr.Cells["LogsEnd"].Appearance.BackHatchStyle = BackHatchStyle.None;
- flag = 2;//分析时间错误
- }
- }
- }
- for (int j = 0; j < i; j++)
- {
- string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
- string loagBeg = "";
- if (j + 1 < i)
- {
- loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
- if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
- {
- if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
- {
- ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink;
- ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink;
- ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- flag1 = 1;//时间差
- }
- //else if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) <= 5 && TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd))>=3)
- //{
- // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.LightGray;
- // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.LightGray;
- // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- // flag = 2;
- //}
- }
- else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
- {
- ultraGrid1.Rows[j].RowSelectorAppearance.BackColor = Color.Red;
- //ultraGrid1.Rows[j + 1].RowSelectorAppearance.BackColor = Color.Red;
- //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackColor = Color.Orange;
- //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
- //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackColor = Color.Orange;
- //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
- flag = 2;
- }
- TimeSpan timeSpan = DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) -
- DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString());
- ultraGrid1.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
- }
- }
- //上班数据分析
- i = 0;
- foreach (UltraGridRow ugr in ultraGrid2.Rows)
- {
- if (!ugr.Cells["LogsBeg"].Value.Equals(""))
- { i += 1; }
- if (!ugr.Cells["LogsEnd"].Value.Equals(""))
- {
- //i += 1;
- if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString()))
- {
- ugr.RowSelectorAppearance.BackColor = Color.Red;
- flag = 2;//分析时间错误
- }
- }
- }
- for (int j = 0; j < i; j++)
- {
- string loagEnd = ultraGrid2.Rows[j].Cells["LogsEnd"].Text.ToString();
- string loagBeg = "";
- if (j + 1 < i)
- {
- loagBeg = ultraGrid2.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
- if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
- {
- if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
- {
- ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink;
- ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink;
- ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
- flag1 = 1;//时间差
- }
- }
- else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
- {
- ultraGrid2.Rows[j].RowSelectorAppearance.BackColor = Color.Red;
- flag = 2;
- }
- TimeSpan timeSpan = DateTime.Parse(ultraGrid2.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) -
- DateTime.Parse(ultraGrid2.Rows[j].Cells["LogsEnd"].Value.ToString());
- ultraGrid2.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
- }
- }
- if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
- {
- string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString();
- string logsEnd = ultraGrid2.Rows[i - 1].Cells["LogsEnd"].Value.ToString();
- if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0)
- {
- if (TubeRoll.JudgeTime(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0)
- {
- flag1 = 1;//时间差
- }
- }
- else if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0)
- {
- flag = 2;
- }
- TimeSpan timeSpan = DateTime.Parse(logsBeg) - DateTime.Parse(logsEnd);
- ultraGrid1.Rows[0].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
- }
- }
- catch (Exception ex)
- {
- // MessageUtil.ShowTips(ex.Message);
- MessageUtil.ShowTips("开始时间或结束时间不能为空!");
- }
- }
- private string DateDiff(DateTime DateTime1, DateTime DateTime2)
- {
- string dateDiff = null;
- try
- {
- TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
- TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
- TimeSpan ts = ts1.Subtract(ts2).Duration();
- dateDiff = ts.Minutes.ToString();
- }
- catch
- {
- }
- return dateDiff;
- }
- /// <summary>
- ///确认
- /// </summary>
- private void doConfirm()
- {
- UltraGridRow uow = ultraGrid1.ActiveRow;
- if (uow == null) { MessageUtil.ShowTips("无数据!"); return; }
- ArrayList list = new ArrayList();
- string date = DateTime.Now.ToString();
- int count = 0;
- if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
- if (flag1 == 1) { MessageUtil.ShowTips("有停机记录未新增,不允许此操作!"); return; }
- if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsBeg"].Value.ToString().Equals(""))
- {
- MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return;
- }
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsEnd"].Value.ToString().Equals(""))
- {
- MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return;
- }
- }
- ultraGrid1.UpdateData();
- int seqmin1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count();
- if (seqmin1 < 1)
- {
- MessageUtil.ShowTips("没有选中要确认的数据!"); return;
- }
- if (seqmin1 > 0 && ultraGrid1.Rows.Count > 0)
- {
- int seqmin = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Min();
- for (int i = 0; i < seqmin; i++)
- {
- if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认"))
- {
- MessageBox.Show("前面有未确认的数据,请先确认!");
- return;
- }
- }
- }
- //if (flag2 == 1) { MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return; }
- //if (flag2 == 2) { MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return; }
- //判断上班是否有未确认的数据
- if (ultraGrid2.Rows.Count() < 1)
- {
- MessageBox.Show("上班有停机记录未新增!");
- return;
- }
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认"))
- {
- MessageBox.Show("上班有未确认的数据,请先确认!");
- return;
- }
- }
- string startdate = "";
- string endDate = "";
- if (chkDate.Checked)
- {
- startdate = cmbDate.Value.ToString("yyyyMMdd1800");
- }
- else
- {
- MessageUtil.ShowTips("请选择日期!");
- return;
- //startdate = cmbDate.Value.ToString("199901012100");
- //endDate = cmbEndDate.Value.ToString("203901012100");
- }
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- if (ugr.Cells["ProType"].Text.ToString().Trim().Equals("停机"))
- {
- if (ugr.Cells["StopType"].Value.Equals("") || ugr.Cells["StopSmall"].Value.Equals("") || ugr.Cells["StopReason"].Value.Equals(""))
- {
- MessageUtil.ShowTips("停机大类,停机小类,停机原因不能为空!");
- return;
- }
- }
- string shift = ugr.Cells["ProBc"].Value.ToString();
- string group = ugr.Cells["ProBz"].Value.ToString();
- if (shift != this.UserInfo.GetUserOrder() || group != this.UserInfo.GetUserGroup())
- {
- MessageUtil.ShowTips("您登录的班次班组与要确认的数据班次班组不符,请重新确认!");
- return;
- }
- count += 1;
- ArrayList list1 = new ArrayList();
- list1.Add(ugr.Cells["ControlId"].Text.ToString());
- list1.Add(this.UserInfo.GetUserName());
- list1.Add(date);
- list1.Add(this.UserInfo.GetUserOrder());
- list1.Add(this.UserInfo.GetUserGroup());
- list1.Add(plineCode);
- list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list1.Add(startdate);
- list1.Add(endDate);
- list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString());
- list.Add(list1);
- }
- }
- if (count == 0)
- {
- MessageUtil.ShowTips("请选中要确认的数据!");
- return;
- }
- string intCount = "0";//是否选择确认
- if (MessageUtil.ShowYesNoAndQuestion("是否只确认选中行数据?") == DialogResult.No)
- {
- intCount = "0";
- if (count == 2)
- {
- MessageUtil.ShowTips("请选择一条数据!");
- return;
- }
- }
- else
- {
- intCount = "1";
- }
- //if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == DialogResult.No)
- //{
- // return;
- //}
- UltraGridRow ugr1 = ultraGrid1.ActiveRow;
- if (ugr1 != null)
- {
- string logbeg = ugr1.Cells["LogsBeg"].Value.ToString();
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "confirmMilControlLog";
- ccp.ServerParams = new object[] { list, intCount };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("确认成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- /// <summary>
- ///取消确认
- /// </summary>
- private void UpConfirm()
- {
- UltraGridRow uow = ultraGrid1.ActiveRow;
- if (uow == null) { MessageUtil.ShowTips("无数据!"); return; }
- ultraGrid1.UpdateData();
- int seqmax1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count();
- if (seqmax1 < 1)
- {
- MessageUtil.ShowTips("没有选中要确认的数据!"); return;
- }
- if (seqmax1 > 0 && ultraGrid1.Rows.Count() > 0)
- {
- int seqmax = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Max();
- for (int i = seqmax + 1; i < ultraGrid1.Rows.Count(); i++)
- {
- if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("已确认"))
- {
- MessageBox.Show("后面有已确认的数据,请先取消确认!");
- return;
- }
- }
- }
- ArrayList list = new ArrayList();
- string date = DateTime.Now.ToString();
- int count = 0;
- string startdate = "";
- string endDate = "";
- if (chkDate.Checked)
- {
- startdate = cmbDate.Value.ToString("yyyyMMdd1800");
- }
- else
- {
- MessageUtil.ShowTips("请选择日期!");
- return;
- //startdate = cmbDate.Value.ToString("199901012100");
- //endDate = cmbEndDate.Value.ToString("203901012100");
- }
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
- {
- count += 1;
- ArrayList list1 = new ArrayList();
- list1.Add(ugr.Cells["ControlId"].Text.ToString());
- list1.Add(this.UserInfo.GetUserOrder());
- list1.Add(this.UserInfo.GetUserGroup());
- list1.Add(plineCode);
- list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
- list1.Add(startdate);
- list1.Add(endDate);
- list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString());
- list.Add(list1);
- }
- }
- if (count == 0) { MessageUtil.ShowTips("请选中要取消确认的数据!"); return; }
- string intCount = "0";//是否选择取消确认
- if (MessageUtil.ShowYesNoAndQuestion("是否只取消确认选中行数据?") == DialogResult.No)
- {
- intCount = "0";
- if (count == 2)
- {
- MessageUtil.ShowTips("请选择一条数据!");
- return;
- }
- }
- else
- {
- intCount = "1";
- }
- //if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == DialogResult.No)
- //{
- // return;
- //}
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
- ccp.MethodName = "upConfirmMilControlLog";
- ccp.ServerParams = new object[] { list, intCount };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("取消确认成功!"))
- {
- doQuery();
- doAnalysis();
- }
- }
- }
- private void chkDate_CheckedChanged(object sender, EventArgs e)
- {
- if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; }
- if (chkBc.Checked) { cmbBc.Enabled = true; } else { cmbBc.Enabled = false; }
- if (chkBz.Checked) { cmbBz.Enabled = true; } else { cmbBz.Enabled = false; }
- if (chkpline.Checked) { cmbPline.Enabled = true; } else { cmbPline.Enabled = false; }
- }
- /// <summary>
- /// Grid字段修改触发事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- UltraGridRow row = ultraGrid1.ActiveRow;
- //string stratime = row.Cells["LogsBeg"].Value.ToString();
- //string endtime = row.Cells["LogsEnd"].Value.ToString();
- try
- {
- //string updateStratime = "";
- //string updateEndtime = "";
- ultraGrid1.UpdateData();
- //if (e.Cell.Column.Key.Equals("LogsEnd"))
- //{
- // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true)
- // {
- // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals(""))
- // {
- // return;
- // }
- // else
- // {
- // updateEndtime = e.Cell.Row.Cells["LogsEnd"].Value.ToString();
- // TimeSpan midTime = DateTime.Parse(updateEndtime) - DateTime.Parse(endtime);
- // stratday = midTime.Days;
- // strathours = midTime.Hours;
- // stratminutes = midTime.Minutes;
- // int i = e.Cell.Row.Index;//h获取选中行序号
- // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i + 1).First();//获取选择行下一行序号
- // DateTime time = DateTime.Parse(urg.Cells["LogsBeg"].Value.ToString()).AddDays(stratday).AddHours(strathours).AddMinutes(stratminutes);
- // urg.Cells["LogsBeg"].Value = time;
- // }
- // }
- // else
- // {
- // MessageUtil.ShowTips("请选择需要修改的数据!");
- // e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString();
- // return;
- // }
- //}
- //if (e.Cell.Column.Key.Equals("LogsBeg"))
- //{
- // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true)
- // {
- // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals(""))
- // {
- // return;
- // }
- // else
- // {
- // updateStratime = e.Cell.Row.Cells["LogsBeg"].Value.ToString();
- // TimeSpan midTime = DateTime.Parse(updateStratime) - DateTime.Parse(stratime);
- // endday = midTime.Days;
- // endhours = midTime.Hours;
- // endminutes = midTime.Minutes;
- // int i = e.Cell.Row.Index;//h获取选中行序号
- // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i -1).First();//获取选择行上一行序号
- // //if (urg.Index < 0) return;
- // DateTime time = DateTime.Parse(urg.Cells["LogsEnd"].Value.ToString()).AddDays(endday).AddHours(endhours).AddMinutes(endminutes);
- // urg.Cells["LogsEnd"].Value = time;
- // }
- // }
- // else
- // {
- // MessageUtil.ShowTips("请选择需要修改的数据!");
- // e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString();
- // return;
- // }
- //}
- if (e.Cell.Column.Key.Equals("QualifiedNum"))
- {
- if (e.Cell.Row.Cells["QualifiedNum"].Value == null)
- {
- e.Cell.Row.Cells["QualifiedNum"].Value = "0";
- }
- else
- {
- string actCount = e.Cell.Row.Cells["QualifiedNum"].Value.ToString();
- if (!StringUtil.IsInt(actCount) || actCount == "0")//actCount == "" || int.Parse(actCount)==0
- {
- e.Cell.Row.Cells["QualifiedNum"].Value = "0";
- }
- }
- }
- if (e.Cell.Column.Key.Equals("QualifiedWt"))
- {
- if (e.Cell.Row.Cells["QualifiedWt"].Value == null)
- {
- e.Cell.Row.Cells["QualifiedWt"].Value = "0";
- }
- else
- {
- string actWt = e.Cell.Row.Cells["QualifiedWt"].Value.ToString();
- if (!StringUtil.IsDouble(actWt) || actWt == "0")//actCount == "" || int.Parse(actCount)==0
- {
- e.Cell.Row.Cells["QualifiedWt"].Value = "0";
- }
- }
- }
- if (e.Cell.Column.Key.Equals("ScrapNum"))
- {
- if (e.Cell.Row.Cells["ScrapNum"].Value == null)
- {
- e.Cell.Row.Cells["ScrapNum"].Value = "0";
- }
- else
- {
- string scrpNum = e.Cell.Row.Cells["ScrapNum"].Value.ToString();
- if (!StringUtil.IsInt(scrpNum) || scrpNum == "0")//actCount == "" || int.Parse(actCount)==0
- {
- e.Cell.Row.Cells["ScrapNum"].Value = "0";
- }
- }
- }
- if (e.Cell.Column.Key.Equals("ScrapWt"))
- {
- if (e.Cell.Row.Cells["ScrapWt"].Value == null)
- {
- e.Cell.Row.Cells["ScrapWt"].Value = "0";
- }
- else
- {
- string scrpwt = e.Cell.Row.Cells["ScrapWt"].Value.ToString();
- if (!StringUtil.IsDouble(scrpwt) || scrpwt == "0")//actCount == "" || int.Parse(actCount)==0
- {
- e.Cell.Row.Cells["ScrapWt"].Value = "0";
- }
- }
- }
- if (e.Cell.Column.Key.Equals("StopType"))
- {
- e.Cell.Row.Cells["StopSmall"].Value = "";
- e.Cell.Row.Cells["StopReason"].Value = "";
- }
- if (e.Cell.Column.Key.Equals("StopSmall"))
- {
- e.Cell.Row.Cells["StopReason"].Value = "";
- }
- }
- catch (Exception ex)
- {
- //MessageUtil.ShowTips("您输入的时间格式不正确!");
- //e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString();
- //e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString();
- return;
- }
- }
- private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
- {
- e.RaiseErrorEvent = false;
- MessageUtil.ShowTips("您输入的时间格式不正确!");
- }
- /// <summary>
- /// 停机原因
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cmbStopReason_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- UltraGridRow row = ultraGrid1.ActiveRow;
- if (row == null) return;
- string stopSallm = basecodeSamll;
- if (!row.Cells["StopSmall"].Text.Equals("")) { stopSallm = row.Cells["StopSmall"].Text; }
- FrmStopSamll fpdc = new FrmStopSamll(basecodeSamll, ob);
- fpdc.AutoSize = true;
- fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fpdc.Text = "停机原因";
- fpdc.ShowDialog();
- if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
- {
- //获取弹出窗体的属性值
- row.Cells["StopReasonm"].Value = fpdc.Basename;
- //cmbStopReason.Value = fpdc.Basename;
- basecodeReason = fpdc.Basecode;
- }
- }
- /// <summary>
- /// 停机小类
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cmbStopSmall_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- UltraGridRow row = ultraGrid1.ActiveRow;
- string stoptype = "";
- if (!row.Cells["StopType"].Text.Trim().Equals(""))
- {
- stoptype = row.Cells["StopType"].Value.ToString();
- }
- FrmStopSamll fpdc = new FrmStopSamll(stoptype, ob);
- fpdc.AutoSize = true;
- fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fpdc.Text = "停机小类";
- fpdc.ShowDialog();
- if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
- {
- //获取弹出窗体的属性值
- row.Cells["StopSmallm"].Value = fpdc.Basename;
- //cmbStopSmall.Value = fpdc.Basename;
- basecodeSamll = fpdc.Basecode;
- }
- }
- /// <summary>
- /// 班次中文
- /// </summary>
- /// <param name="dtShift"></param>
- /// <returns></returns>
- private string changeShift(string dtShift)
- {
- switch (dtShift)
- {
- case "1":
- dtShift = "早班";
- break;
- case "2":
- dtShift = "中班";
- break;
- case "3":
- dtShift = "夜班";
- break;
- }
- return dtShift;
- }
- /// <summary>
- /// 班组中文
- /// </summary>
- /// <param name="dtGroup"></param>
- /// <returns></returns>
- private string changeGroup(string dtGroup)
- {
- switch (dtGroup)
- {
- case "1":
- dtGroup = "甲班";
- break;
- case "2":
- dtGroup = "乙班";
- break;
- case "3":
- dtGroup = "丙班";
- break;
- case "4":
- dtGroup = "丁班";
- break;
- }
- return dtGroup;
- }
- }
- }
|