天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

244 lines
8.4 KiB

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using QMAPP.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Equipment;
using QMAPP.FJC.Entity.MachineCheck;
using QMAPP.MD.Entity;
using QMAPP.ServicesAgent;
using QMAPP.WinForm.Common;
using QMAPP.WinForm.Forms.Injection;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
namespace QMAPP.WinForm.Forms.MachineCheck
{
/// <summary>
/// 模块编号:
/// 作 用:设备点检
/// 作 者:周晓东
/// 编写日期:2017年11月29日
///</summary>
public partial class MachineCheckForm : Form
{
MachineCheckEntity searchModel = new MachineCheckEntity(); //查询条件
public MachineCheckForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
#region 绑定下拉列表
BasicData basicData = new BasicData();
//初始化控件属性
this.DGView.AutoGenerateColumns = false;
//加载所有班次下拉列表
this.comShift.DataSource = basicData.GetShiftComboxSource();
this.comShift.DisplayMember = "SHIFT_NAME";
this.comShift.ValueMember = "SHIFT_CODE";
comStatus.Items.Add("");
comStatus.Items.Add("初始化");
comStatus.Items.Add("点检完成");
//加载日期
DateTime dtStart = DateTime.Now;
dtpStart.Value = dtStart.AddDays(-2);
dtpEnd.Value = dtStart.AddDays(1);
#endregion
//初始化分页
this.pager1.Init();
//加载默认查询条件
SetSearchModel();
BindGirdData();
}
#endregion
#region 绑定数据
private DataPage BindGirdData()
{
List<MachineCheckEntity> recorders = null; //查询结果列表
DataPage dataPage = new DataPage();
//获取前台分页设置信息
dataPage = pager1.DataPage;
try
{
#region 服务查询
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dataPage = agent.InvokeServiceFunction<DataPage>("MachineCheckBLL_GetList", searchModel, dataPage);
recorders = JsonConvertHelper.GetDeserialize<List<MachineCheckEntity>>(dataPage.Result.ToString());
#endregion
this.DGView.DataSource = recorders;
this.pager1.DataPage = dataPage;
}
catch (Exception ex)
{
throw ex;
}
return dataPage;
}
#endregion
/// <summary>
/// 分页事件
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
private DataPage pager1_EventPaging(Controls.EventPagingArg e)
{
return BindGirdData();
}
/// <summary>
/// 查询事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
SetSearchModel();
this.pager1.Init();
BindGirdData();
}
/// <summary>
/// 设置查询条件
/// </summary>
private void SetSearchModel()
{
searchModel = new MachineCheckEntity();
//班次
if (this.comShift.SelectedValue != null &&
string.IsNullOrEmpty(this.comShift.SelectedValue.ToString().Trim()) == false)
{
searchModel.SHIFT_CODE = this.comShift.SelectedValue.ToString().Trim();
}
//状态
if (comStatus.SelectedIndex > 0)
{
searchModel.CHECKSTATUS = (comStatus.SelectedIndex - 1).ToString();
}
//开始时间
searchModel.STARTCHECKDATE = Convert.ToDateTime(dtpStart.Value.ToString("yyyy-MM-dd") + " 00:00:00");
searchModel.ENDCHECKDATE = Convert.ToDateTime(dtpEnd.Value.ToString("yyyy-MM-dd") + " 00:00:00");
//if (string.IsNullOrEmpty(this.dtpStart.Text.Trim()) == false &&
// string.IsNullOrEmpty(this.dtpEnd.Text.Trim()) == false)
//{
// searchModel.STARTCHECKDATE = Convert.ToDateTime(this.dtpStart.Text);
// searchModel.ENDCHECKDATE = Convert.ToDateTime(this.dtpEnd.Text);
//}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbDelete_Click(object sender, EventArgs e)
{
if (this.DGView.SelectedRows.Count <= 0)
return;
if (MessageBox.Show(Resource1.ConfirmDelete, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) !=
DialogResult.OK)
return;
#region 删除
string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//删除
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>("MachineCheckBLL_Delete", selectKey);
//MessageBox.Show(result.Msg);
if (result.IsSuccess)
{
BindGirdData();
}
#endregion
}
/// <summary>
/// 打开维护页面-新增
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbAdd_Click(object sender, EventArgs e)
{
MachineCheckEditForm editForm = new MachineCheckEditForm();
DialogResult result = editForm.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK) //判断是否操作成功
{
this.pager1.Init();
BindGirdData();
//打开网页
//string machineCheckUrl = System.Configuration.ConfigurationManager.AppSettings["MachineCheckUrl"];
var machineCheckUrl = editForm._machineCheckUrl;
if (string.IsNullOrEmpty(machineCheckUrl))
{
MessageBox.Show("没找到点检连接,无法打开。");
return;
}
//Process.Start("iexplore.exe", machineCheckUrl);
try
{
Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", machineCheckUrl);//谷歌浏览器
}
catch (Exception)
{
Process.Start("iexplore.exe", machineCheckUrl);
}
}
}
/// <summary>
/// 打开维护页面-更新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbEdit_Click(object sender, EventArgs e)
{
if (this.DGView.SelectedRows.Count > 0)
{
string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result;//判断是否成功
result = agent.InvokeServiceFunction<DataResult<int>>("MachineCheckBLL_Update", selectKey);
if (result.IsSuccess)
{
this.pager1.Init();
BindGirdData();
}
MessageBox.Show(result.Msg);
}
}
/// <summary>
/// 行序号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGView.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
}
}