using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.ZGMil.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.ZGMil.Report
{
public partial class FrmUpdateBalYearMonth : FrmBase
{
private string departm = "";
private string plineCode = "";
public FrmUpdateBalYearMonth()
{
InitializeComponent();
this.IsLoadUserView = true;
}
private void FrmUpdateBalYearMonth_Load(object sender, EventArgs e)
{
NativeMethodNew na = new NativeMethodNew(this.ob);
departm = UserInfo.GetDepartment();
plineCode = na.GetPCode(departm);//获取 用户 对应的产线
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
doQuery();
break;
case "Update":
doUpdate();
break;
case "Export":
ExportData();
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询
///
private void doQuery()
{
//string date = "";
//string endDate = "";
string JudgeStoveNo = "";
//string LotNo = "";
string barYearMonth = "";
//string ContractNo = "";
if (chkJudgeStoveNo.Checked)
{
if (uteJudgeStoveNo.Text.Trim() == "")
{
JudgeStoveNo = "";
}
else
{
JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
}
}
//if (chkLotNo.Checked)
//{
// if (uteLotNo.Text.Trim() == "")
// {
// LotNo = "";
// }
// else
// {
// LotNo = uteLotNo.Value.ToString();
// }
//}
if (chkBalYearMonth.Checked)
{
if (BAL_YEAR_MONTH.Text.Trim() == "")
{
barYearMonth = "";
}
else
{
barYearMonth = BAL_YEAR_MONTH.Value.ToString("yyyyMM");
}
}
WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getBalYearMonth", new Object[] { barYearMonth, JudgeStoveNo, getPlineCode() }, this.ob);
GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
GridHelper.RefreshAndAutoSize(this.ultraGrid1);
wf.Close();
}
///
/// 调整结转年月
///
private void doUpdate()
{
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;
//int actCount = 0;
if (!ugr.Cells["ACT_COUNT"].Text.ToString().Equals(""))
{
if (!StringUtil.IsInteger(ugr.Cells["ACT_COUNT"].Text.ToString()) || ugr.Cells["ACT_COUNT"].Text.ToString() == "0")
{
MessageUtil.ShowTips("请输入正确的数字!");
return;
}
if (Int32.Parse(ugr.Cells["ACT_COUNT"].Value.ToString2()) > Int32.Parse(ugr.Cells["ACT_COUNT1"].Value.ToString2()))
{
MessageUtil.ShowTips("输入的支数不能大于实际的支数!");
return;
}
//actCount = Int32.Parse(ugr.Cells["ACT_COUNT"].Value.ToString());
}
if (ugr.Cells["BAL_YEAR_MONTH"].Text.ToString().Equals(""))
{
MessageUtil.ShowTips("请输入正确的时间!");
return;
}
else
{
if (!StringUtil.IsNumber(ugr.Cells["BAL_YEAR_MONTH"].Text.ToString()))
{
MessageUtil.ShowTips("请输入正确的时间!");
return;
}
}
ArrayList pram = new ArrayList();
pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString());
pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
pram.Add(ugr.Cells["ACT_COUNT"].Value.ToString());
pram.Add(ugr.Cells["BAL_YEAR_MONTH"].Value.ToString());
list.Add(pram);
}
}
if (count == 0 || count > 1)
{
MessageUtil.ShowTips("请选择一条需要修改的数据!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { list };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("修改成功!"))
{
doQuery();
}
}
}
///
/// 导出
///
private void ExportData()
{
GridHelper.ulGridToExcel(ultraGrid1, "轧管投入产出报表");
}
///
/// 非250、258、168、460的产线代码都为空
///
///
private string getPlineCode()
{
if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017"))
{
return plineCode;
}
else
{
return "";
}
}
///
/// 查询条件
///
///
///
private void chkDate_CheckedChanged(object sender, EventArgs e)
{
if (chkBalYearMonth.Checked) { BAL_YEAR_MONTH.Enabled = true; } else { BAL_YEAR_MONTH.Enabled = false; }
//if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
}
}
}