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 CoreFS.CA06;
using Core.StlMes.Client.YdmBase;
using Core.Mes.Client.Comm.Tool;
using System.Collections;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
using Infragistics.Win.UltraWinGrid;
using System.Text.RegularExpressions;
using Core.StlMes.Client.YdmPipeManage.Tool;
using Core.StlMes.Client.SaleOrder.ReviewForm;
using Core.StlMes.Client.YdmPipeManage;
using Core.Mes.Client.Comm;
namespace Core.StlMes.Client.PipeLeaveFactory
{
public partial class frmPipeLoad : FrmBase
{
///
/// 获取仓库权限
///
private string[] _storagerPur;
private string strBill = "";//提货单号
private string strLoad = "";//装车单号
private string strCar = "";//车号
private string strReceiv = "";//收货单位
string index = "";//定位
public frmPipeLoad()
{
InitializeComponent();
this.IsLoadUserView = true;
}
private void frmPipeLoad_Load(object sender, EventArgs e)
{
//收货单位
YdmBaseClass.InitComboEditor(cmbReceiv, "com.steering.pss.ydm.pipeleavefactory.FrmPipeSendList.queryCustomer", "CUSTOMER_NO", ob, true);
DateTime now = DateTime.Now;
DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
OutEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
OutStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
_storagerPur = BaseMethod.WarehousePermissions("", this.ValidDataPurviewIds, ob);
BaseMethod.InitStorage(cmbStorager, "", this.ValidDataPurviewIds, ob);
ClsBaseInfo.FillComBaseInfo(ucType, "8021", ob, false);
ultraExpandableGroupBox3.Visible = false;
GridHelper.SetColumnsActivateAndColor(ultraGrid3.Rows.Band, "HOOK_WEIGHT");
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
doQuery();
break;
case "Update":
doUpdate();
break;
case "GetUpdateNetWeight":
GetUpdateNetWeight();
break;
case "Confirm"://确认有效
doConfirm();
break;
case "CancelConfirm"://取消确认
doCancelConfirm();
break;
case "Refresh":
doRefresh();
break;
case "Export":
GridHelper.ulGridToExcel(ultraGrid1, "理货单信息");
break;
case "LoadPrint"://装车单打印
doLoadPrint();
break;
case "LoadPrint2"://装车单二维码打印
doLoadPrint2();
break;
case "Close":
this.Close();
break;
case "Zbs"://随车质保书
doZbsPrint();
break;
}
}
private void GetUpdateNetWeight()
{
UltraGridRow ugr = this.ultraGrid1.ActiveRow;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad";
ccp.MethodName = "GetUpdateNetWeight";
ccp.ServerParams = new object[] { ugr.Cells["BILL_NO"].Value.ToString(), ugr.Cells["TALLYSHEET_NO"].Value.ToString(), ugr.Cells["VEHICLE_NO"].Value.ToString(), this.UserInfo.GetUserName() };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("获取成功!"))
{
doQuery();
}
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "doConfirm_HW":
doConfirm_HW(sender,e);
break;
}
}
private void doConfirm_HW(object sender, EventArgs e)
{
this.ultraGrid3.UpdateData();
if (ultraGrid3.Rows.Count == 0) {
MessageBox.Show("请选择操作记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//foreach (UltraGridRow row in ultraGrid2.Rows)
//{
// if (!row.Cells["PONDER_NO"].Text.Trim().Equals(""))
// {
// MessageUtil.ShowTips("已过磅,不能确认钩子称!");
// return;
// }
//}
foreach (UltraGridRow row in ultraGrid3.Rows)
{
if (row.Cells["HOOK_WEIGHT"].Value.ToString().Trim() == "") {
MessageUtil.ShowTips("炉号:"+row.Cells["JUDGE_STOVE_NO"].Text.Trim()+"钩子称重量不能为空,请输入!");
return;
}
//if (double.Parse(row.Cells["HOOK_WEIGHT"].Value.ToString().Trim()) == 0) {
// MessageUtil.ShowTips("炉号:"+row.Cells["JUDGE_STOVE_NO"].Text.Trim()+ "钩子称重量为零,请重新输入!");
// return; }
}
foreach (UltraGridRow row in ultraGrid3.Rows)
{
ArrayList all = new ArrayList();
all.Add(row.Cells["BILL_NO"].Value.ToString().Trim());
all.Add(row.Cells["TALLYSHEET_NO"].Value.ToString().Trim());
all.Add(row.Cells["LOADVEHICLE_NO"].Value.ToString().Trim());
all.Add(row.Cells["JUDGE_STOVE_NO"].Value.ToString().Trim());
all.Add(row.Cells["BATCH_NO"].Value.ToString().Trim());
all.Add(row.Cells["GROUP_NO"].Value.ToString().Trim());
all.Add(row.Cells["SEND_NUM"].Value.ToString().Trim());
all.Add(row.Cells["THEORY_WEIGHT"].Value.ToString().Trim());
all.Add(row.Cells["HOOK_WEIGHT"].Value.ToString().Trim());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad";
ccp.MethodName = "insertHookWeight";
ccp.ServerParams = new object[] { all };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
}
MessageBox.Show("增加成功!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
ultraGrid2_AfterRowActivate(sender,e);
}
///
/// 装车单二维码打印
///
private void doLoadPrint2()
{
string LoadNo = "";
UltraGridRow ugr = this.ultraGrid1.ActiveRow;
if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; }
int count = 0;
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
{
count += 1;
LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim();
}
}
if (count == 0)
{
MessageUtil.ShowTips("请选择要打印的装车单号!");
return;
}
if (count > 1)
{
MessageUtil.ShowTips("请勾选一个装车单打印!");
return;
}
string LOADVEHICLE_NO = "T:" + LoadNo;
string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpOutList2.cpt&OUTSTOCK_DOC=" + LOADVEHICLE_NO;
FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl);
fBug.AutoSize = true;
fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
//fBug.WindowState = FormWindowState.Maximized;
fBug.Text = "二维码";
fBug.ShowDialog();
doQuery();
}
private void doZbsPrint()
{
string LoadNo = "";
string metricSystemNo = "";
string zbsEdition = "";
string isVehicleNo = "";
string tsMemo = "";
string address = "";
UltraGridRow ugr = this.ultraGrid1.ActiveRow;
if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; }
int count = 0;
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
{
count += 1;
LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim();
}
}
if (count == 0)
{
MessageUtil.ShowTips("请选择要打印的装车单号!");
return;
}
if (count > 1)
{
MessageUtil.ShowTips("请勾选一个装车单打印!");
return;
}
ArrayList list = new ArrayList();
list.Add(ugr.Cells["LOADVEHICLE_NO"].Text.Trim());
list.Add(ugr.Cells["BILL_NO"].Text.Trim());
list.Add(ugr.Cells["VEHICLE_NO"].Text.Trim());
list.Add(ugr.Cells["TALLYSHEET_NO"].Text.Trim());
DataTable dt1 = ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.queryMativery", new object[] { list }, ob);
if (dt1.Rows.Count == 0)
{
MessageUtil.ShowTips("发货实绩无数据,不能打印!");
return;
}
string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepCertificateOfProductQualityTHOutBill.cpt&"
+ "&OUT_BILLNO=" + LoadNo + "&ORD_LN_PK=" + dt1.Rows[0]["ORD_LN_PK"].ToString() + "&ASK_ITEM_NO=" + 1210070400000001 + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ZBS_EDITION=" + zbsEdition + "&TYPE=ZB&ORD_LN_DLY_PK=" + dt1.Rows[0]["ORD_LN_DLY_PK"].ToString() + "&IS_VEHICLE_NO=" + isVehicleNo + "&TS_MEMO=" + tsMemo + "&ADDRESS=" + address;
FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl);
fBug.AutoSize = true;
fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
//fBug.WindowState = FormWindowState.Maximized;
fBug.Text = "随车质保书打印";
fBug.ShowDialog();
doQuery();
}
private void doLoadPrint()
{
string LoadNo = "";
UltraGridRow ugr = this.ultraGrid1.ActiveRow;
if (ugr == null) { MessageUtil.ShowTips("无数据,请确认!"); return; }
int count = 0;
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
{
count += 1;
LoadNo = row.Cells["LOADVEHICLE_NO"].Text.Trim();
}
}
if (count == 0)
{
MessageUtil.ShowTips("请选择要打印的装车单号!");
return;
}
if (count >1)
{
MessageUtil.ShowTips("请勾选一个装车单打印!");
return;
}
string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepYdmLoad.cpt&op=view"+"&no="+LoadNo;
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
ServerHelper.SetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.updatePintFlag", new object[] { time, LoadNo }, ob);
FrmDocPrintExcel fBug = new FrmDocPrintExcel(ob, strurl);
fBug.AutoSize = true;
fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
//fBug.WindowState = FormWindowState.Maximized;
fBug.Text = "装车单打印";
fBug.ShowDialog();
doQuery();
}
//确认有效
private void doConfirm()
{
ArrayList list = new ArrayList();
UltraGridRow ugr = this.ultraGrid1.ActiveRow;
if (ugr == null)
{
MessageUtil.ShowTips("请选择要操作的记录数!");
return;
}
UltraGridRow ugr2 = this.ultraGrid2.ActiveRow;
if (ugr2 != null && ugr2.Cells["SUPPLY_UNIT"].Value.ToString().Equals("120504"))
{
string billNo = "";
string tallysheetNo = "";
string loadvehicleNo = "";
string judgeStoveNo = "";
string batchNo = "";
string groupNo = "";
int i = 0;
int countHW = 0;
foreach (UltraGridRow row in ultraGrid2.Rows)
{
//if (row.Cells["PONDER_NO"].Text.Trim().Equals("")) {
// MessageUtil.ShowTips("未过磅不能确认!");
// return;
//}
billNo = row.Cells["BILL_NO"].Text.Trim();
tallysheetNo = row.Cells["TALLYSHEET_NO"].Text.Trim();
loadvehicleNo = row.Cells["LOADVEHICLE_NO"].Text.Trim();
judgeStoveNo = row.Cells["JUDGE_STOVE_NO"].Text.Trim();
batchNo = row.Cells["BATCH_NO"].Text.Trim();
groupNo = row.Cells["GROUP_NO"].Text.Trim();
ArrayList all = new ArrayList();
all.Add(billNo);
all.Add(tallysheetNo);
all.Add(loadvehicleNo);
all.Add(judgeStoveNo);
all.Add(batchNo);
all.Add(groupNo);
countHW += int.Parse(ServerHelper.GetData("com.steering.pss.ydm.pipeleavefactory.FrmPipeLoad.selCountHookWeight", new Object[] { all }, this.ob).Rows[0][0].ToString());
i++;
}
//if (countHW != i) {
// MessageUtil.ShowTips("未保存钩子称重量!");
// return;
//}
}
string[] judgeStates;
if (ucType.Value == null)
{
judgeStates = new string[0];
}
else
{
judgeStates = ((List