using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; 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; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类; using Core.Mes.Client.Comm.Format; using System.Collections; namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec.数据管理.钢管实验管理 { public partial class FrmSaveRecords : FrmBase { public FrmSaveRecords() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); InitColumns(); } private void InitColumns() { DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, 1); cmbDate.Value = DateTime.Parse(date.ToString("yyyy-MM-dd 00:00:00")); cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Update": doUpdate(); break; case "Delete": doDelete(); break; case "Destroy": doDestroy(); break; case "Print": DoPrint(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "力学金相试验保存销毁记录"); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void doQuery() { string date = ""; string endDate = ""; string CHECK_NO = ""; string CONTRACT_NO = ""; string HEAT_NO = ""; string PLINE_CODE = ""; 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(); endDate = cmbEndDate.Value.ToString(); } } if (chkCHECK_NO.Checked) { if (ultraCHECK_NO.Text.Trim() == "") { CHECK_NO = ""; } else { CHECK_NO = ultraCHECK_NO.Value.ToString(); } } if (chkHEAT_NO.Checked) { if (ultraHEAT_NO.Text.Trim() == "") { HEAT_NO = ""; } else { HEAT_NO = ultraHEAT_NO.Value.ToString(); } } if (CHECK_NO + CONTRACT_NO + HEAT_NO + PLINE_CODE + date == "") { MessageBox.Show("请输入查询条件"); return; } List listSource = EntityHelper.GetData ("com.steering.lims.data.pipe.FrmSaveRecords.doQueryData", new object[] { date, endDate, CHECK_NO, HEAT_NO }, this.ob); bindingSource1.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid1); this.ultraGrid1.DisplayLayout.Bands[0].Columns["SaveTime"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SaveTime"].MaskInput = "yyyy-mm-dd"; this.ultraGrid1.DisplayLayout.Bands[0].Columns["DestroyTime"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin; this.ultraGrid1.DisplayLayout.Bands[0].Columns["DestroyTime"].MaskInput = "yyyy-mm-dd"; } /// /// 保存 /// private void doUpdate() { ultraGrid1.UpdateData(); ArrayList pram = new ArrayList(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要保存的记录!"); return; } foreach (UltraGridRow uRow in checkMagRows) { PipeCheckconsignSaveRecordsEntity stlControlLogEntity = (PipeCheckconsignSaveRecordsEntity)uRow.ListObject; if (ultraSaveName.Text.Trim() != "") { stlControlLogEntity.SaveName = ultraSaveName.Text.Trim().ToString(); } if (ultraDestroyName.Text.Trim() != "") { stlControlLogEntity.DestroyName = ultraDestroyName.Text.Trim().ToString(); } string matZcTity = JSONFormat.Format(stlControlLogEntity); pram.Add(matZcTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmSaveRecords"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("保存成功!")) { doQuery(); } } } /// /// 删除 /// private void doDelete() { ultraGrid1.UpdateData(); ArrayList pram = new ArrayList(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要删除的记录!"); return; } foreach (UltraGridRow uRow in checkMagRows) { PipeCheckconsignSaveRecordsEntity stlControlLogEntity = (PipeCheckconsignSaveRecordsEntity)uRow.ListObject; string matZcTity = JSONFormat.Format(stlControlLogEntity); pram.Add(matZcTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmSaveRecords"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除成功!")) { doQuery(); } } } /// /// 销毁 /// private void doDestroy() { ultraGrid1.UpdateData(); ArrayList pram = new ArrayList(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要销毁的记录!"); return; } foreach (UltraGridRow uRow in checkMagRows) { PipeCheckconsignSaveRecordsEntity stlControlLogEntity = (PipeCheckconsignSaveRecordsEntity)uRow.ListObject; if (ultraDestroyName.Text.Trim() != "") { stlControlLogEntity.DestroyName = ultraDestroyName.Text.Trim().ToString(); } else { stlControlLogEntity.DestroyName = this.UserInfo.GetUserName(); } stlControlLogEntity.DestroyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string matZcTity = JSONFormat.Format(stlControlLogEntity); pram.Add(matZcTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmSaveRecords"; ccp.MethodName = "doDestroy"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("销毁成功!")) { doQuery(); } } } private void chkDate_CheckedChanged(object sender, EventArgs e) { if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; } if (chkDate.Checked) { cmbEndDate.Enabled = true; } else { cmbEndDate.Enabled = false; } if (chkCHECK_NO.Checked) { ultraCHECK_NO.Enabled = true; } else { ultraCHECK_NO.Enabled = false; } if (chkHEAT_NO.Checked) { ultraHEAT_NO.Enabled = true; } else { ultraHEAT_NO.Enabled = false; } } private void FrmSaveRecords_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } /// /// 打印 /// private void DoPrint() { string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPipeSaveRecords.cpt&op=view&SAVE_TIME1=" + cmbDate.Value.ToString("yyyy-MM-dd") + "&SAVE_TIME2=" + cmbEndDate.Value.ToString("yyyy-MM-dd"); FrmExcel fre = new FrmExcel(this.ob, url); fre.AutoSize = true; fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.WindowState = FormWindowState.Maximized; fre.Show(); } } }