using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.YdmBcPipeManage.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.YdmBcPipeManage { public partial class FrmScrapApplyFrim : FrmBase { public FrmScrapApplyFrim() { InitializeComponent(); } private void FrmScrapApplyFrim_Load(object sender, EventArgs e) { DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); this.StartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); initDepartMent(); } /// /// 所属权 /// private void initDepartMent() { DataTable ds = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.doQueryDepartM", new object[] { }, ob); if (ds.Rows.Count > 0) { this.cmbDepartMent.DataSource = ds; cmbDepartMent.DisplayMember = "DEPARTMENT_NAME_P"; cmbDepartMent.ValueMember = "DEPARTMENT_CODE_P"; } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": doQuery(); break; case "FrimScarpApply": frimScarpApply(); break; case "FrimScarpApplyNot": frimScarpApplyNot(); break; case "CancelFrimScarpApply": cancelFrimScrapApply(); break; case "Export": exportData(); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void doQuery() { string bathYear = ""; string txtJudgeNo = ""; string startTime = ""; string endTim = ""; if (this.chkTim.Checked) { bathYear = this.StartTime.Value.ToString("yyyyMM"); } if (this.chkJugeHeatNo.Checked && this.txtJugeNo.Text.Trim() != "") { txtJudgeNo = this.txtJugeNo.Text.Trim(); } if (this.chkRegTime.Checked) { startTime = this.RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } ArrayList parmList = new ArrayList(); parmList.Add(bathYear); parmList.Add(txtJudgeNo); parmList.Add(startTime); parmList.Add(endTim); List listSource = EntityHelper.GetData( "com.steering.ydm.bc.FrmScrapApplyFrim.doQueryApply", new object[] { parmList, ultraOptionSet1.CheckedItem.DataValue.ToString(), this.CustomInfo, this.ValidDataPurviewIds }, this.ob); foreach(YdmBcScrapfrimEntity YdmBcScrapfrimEntity in listSource) { if (String.IsNullOrWhiteSpace(YdmBcScrapfrimEntity.FrimTime)) { YdmBcScrapfrimEntity.TimeDiffe = "0.0天"; } else { TimeSpan ts1 = new TimeSpan(DateTime.ParseExact(YdmBcScrapfrimEntity.FrimTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks); TimeSpan ts2 = new TimeSpan(DateTime.ParseExact(YdmBcScrapfrimEntity.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks); YdmBcScrapfrimEntity.TimeDiffe = ts1.Subtract(ts2).TotalDays.ToString("0.0") + "天"; } } ydmBcScrapfrimEntityBindingSource.DataSource = listSource; } /// /// 审核 /// private void frimScarpApply() { this.ultraGrid2.UpdateData(); IQueryable checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要审核的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject; matBcEntity.BelongCodeResponse = row.Cells["BelongCodeResponse"].Value.ToString(); matBcEntity.BelongNameResponse = row.Cells["BelongCodeResponse"].Text; matBcEntity.FrimName = UserInfo.GetUserName(); if (matBcEntity.BelongCodeResponse == "") { MessageUtil.ShowTips("审核时请确定责任单位!"); return; } string ydmFrimEntity = JSONFormat.Format(matBcEntity); parmList.Add(ydmFrimEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim"; ccp.MethodName = "frimScarpApply"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("审核成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 审核不通过 /// private void frimScarpApplyNot() { this.ultraGrid2.UpdateData(); IQueryable checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要审核的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject; matBcEntity.FrimName = UserInfo.GetUserName(); string ydmFrimEntity = JSONFormat.Format(matBcEntity); parmList.Add(ydmFrimEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim"; ccp.MethodName = "frimScarpApplyNot"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("审核成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 撤销废品的审核 /// private void cancelFrimScrapApply() { this.ultraGrid2.UpdateData(); string date = DateTime.Now.ToString("yyyyMM"); IQueryable checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要撤销审核的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject; string ydmFrimEntity = JSONFormat.Format(matBcEntity); parmList.Add(ydmFrimEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim"; ccp.MethodName = "cancelFrimScrapApply"; ccp.ServerParams = new object[] { parmList, date }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 导出 /// private void exportData() { GridHelper.ulGridToExcel(ultraGrid2, "已审核废品数据汇总"); } private void chkJugeHeatNo_CheckedChanged(object sender, EventArgs e) { this.txtJugeNo.Enabled = this.chkJugeHeatNo.Checked; } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked; } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow uRow = this.ultraGrid2.ActiveRow; if (uRow.Cells["CraftNo"].Text.Trim() == "" || uRow.Cells["CraftPath"].Text.Trim() == "") { return; } BaseMethod.ViewCarft_No(uRow.Cells["CraftPath"].Text.Trim()); } } }