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 QMAPP.ServicesAgent;
using QMAPP.Entity;
using QMAPP.FJC.Entity.ProduceManage;
namespace QMAPP.WinForm.Forms.Mend
{
public partial class MendStaticForm : Form
{
private ServiceAgent wcfAgent = null;
public MendStaticForm()
{
InitializeComponent();
Init();
}
private void tsbSearch_Click(object sender, EventArgs e)
{
BindDataGrid();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
this.Close();
}
private void Init()
{
DGData.AutoGenerateColumns = false;
wcfAgent = ClientContext.GetServiceAgent();
DateTime dtStart = DateTime.Now;
if (dtStart < Convert.ToDateTime(dtStart.ToShortDateString() + " 7:30:00"))
{
dpOpeStart.Value = dtStart;
dpOpeEnd.Value = dtStart;
comHourStart.Text = "0";
comHourEnd.Text = "7";
comMinuteStart.Text = "0";
comMinuteEnd.Text = "30";
}
else if (dtStart > Convert.ToDateTime(dtStart.ToShortDateString() + " 7:30:00") && dtStart.Hour < 16)
{
dpOpeStart.Value = dtStart;
dpOpeEnd.Value = dtStart;
comHourStart.Text = "7";
comMinuteStart.Text = "30";
comHourEnd.Text = "16";
comMinuteEnd.Text = "0";
}
else if (dtStart.Hour >= 16)
{
dpOpeStart.Value = dtStart;
dpOpeEnd.Value = dtStart.AddDays(1);
comHourStart.Text = "16";
comHourEnd.Text = "0";
comMinuteStart.Text = "0";
comMinuteEnd.Text = "0";
}
//this.dateOpeStart.ValueX = dtStart;
//this.dateOpeEnd.ValueX = dtEnd;
BindDataGrid();
}
///
/// 绑定数据
///
private void BindDataGrid()
{
MendRecorder condtion = new MendRecorder();
condtion.CREATEDATESTART = Convert.ToDateTime(dpOpeStart.Value.ToString("yyyy-MM-dd") + " " + comHourStart.Text.ToString() + ":" + comMinuteStart.Text.ToString() + ":00").ToString("yyyy-MM-dd HH:mm:ss");
condtion.CREATEDATEEND = Convert.ToDateTime(dpOpeEnd.Value.ToString("yyyy-MM-dd") + " " + comHourEnd.Text.ToString() + ":" + comMinuteEnd.Text.ToString() + ":00").ToString("yyyy-MM-dd HH:mm:ss");
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.B9IPCService.MendRecorderBLL_GetListForstatistic.ToString(),
condtion);
if (!dataResult.IsSuccess)
{
MessageBox.Show(dataResult.Msg);
}
DataTable dt = dataResult.Result;
DGData.DataSource = dt;
DGData.ClearSelection();
//设置数值型局右显示
labelSum.Text = "";
if (dt.Rows.Count > 0)
{
int sum = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
sum += Convert.ToInt32(dr["MENDSUM"]);
}
labelSum.Text = sum.ToString();
}
}
}
}