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 Pur.Entity;
using Pur.Entity.pur_orderEntiy;
using Core.Mes.Client.Comm.Control;
using Pur.Entity.configureEntity;
using Infragistics.Win.UltraWinEditors;
using com.hnshituo.pur.vo;
using Core.Mes.Client.Comm.Tool;
using System.Collections;
using Infragistics.Win;
using Pur.Entity.ck;
using Infragistics.Win.UltraWinGrid;
using Pur.configure;
using Core.Mes.Client.Comm.Server;
using Pur.PublicTools;
namespace Pur.Pop_upWindow
{
public partial class FrmPopConfirmGoods : FrmBase
{
public string QstrInstockNo = "";
public FrmPopConfirmGoods()
{
InitializeComponent();
}
///
///
///
///
///
private void FrmPopConfirmGoods_Load(object sender, EventArgs e)
{
QcreateTime_BeginNoJL.Value = DateTime.Now.AddMonths(-1);
QcreateTime_EndNoJL.Value = DateTime.Now.AddDays(2);
QcreateTime_BeginNoJL.Enabled = true;
QcreateTime_EndNoJL.Enabled = true;
ck_createTimeNoJL.Checked = true;
txt_status.SelectedIndex = 0;
GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] {"Check"});
PublicPur.InitCellEdit(new UltraGrid[] { ultraGrid1 }, new string[] {"remark2", "SHIPQTY", "RECQTY" });
PublicPur.InitCellPositionRight(new UltraGrid[] { ultraGrid1 }, new string[] { "SHIPQTY", "RECQTY" });
PublicPur.InitColumnShowLength(new UltraGrid[] { ultraGrid1 }, 0, new string[] { "SHIPQTY", "RECQTY" }, 3, false);
}
//菜单按钮事件
#region toolbar工具
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
Get_PUR_EXC_DELIVERY_M();
break;
case "conFirmation":
setRecList();//收货
break;
case "QuitCheckAgain"://撤销复检
QuitCheckAgain();
break;
case "ESC":
this.Close();
break;
}
}
///
/// 查询送货通知单主表
///
private void Get_PUR_EXC_DELIVERY_M()
{
try
{
this.Cursor = Cursors.WaitCursor;
//查询发货通知单行表
dataSet1.Clear();
Hashtable map = new Hashtable();
map.Add("deliverySubId", txt_DELIVERY_ID.Text);
map.Add("orderId", COP_OrderId.Text);
map.Add("suppName", QsuppNameNoJL.Text.Trim());
map.Add("statusFJ", txt_status.Value == null ? "" : txt_status.Value.ToString());
map.Add("invPhysicName", QInphysicNoJL.Text.Trim());
map.Add("deliveryLocation", QLocationNoJL.Text.Trim());
if (ck_createTimeNoJL.Checked)
{
if (QcreateTime_BeginNoJL.Value != null)//创建开始时间
{
map.Add("createTimeBegin", Convert.ToDateTime(QcreateTime_BeginNoJL.Value));
}
if (QcreateTime_EndNoJL.Value != null)//创建结束时间
{
map.Add("createTimeEnd", Convert.ToDateTime(QcreateTime_EndNoJL.Value));
}
}
DataTable dt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
GridHelper.CopyDataToDatatable(dt, dataTable1, true);
GridHelper.RefreshAndAutoSize(ultraGrid4);
}
catch (Exception ex)
{
MessageUtil.ShowTips("加载数据异常:" + ex.Message);
}
finally
{
this.Cursor = Cursors.Default;
}
}
///
/// 生成收货单,2016-6-6 收货界面跟换成编辑框形式,tips:0为收货,1为退货
///
private void setRecList()
{
ultraGrid1.UpdateData();
ArrayList al = new ArrayList();
ArrayList al_ExcDeliveryException = new ArrayList();//送货单行
ExcDeliverySubC subc=new ExcDeliverySubC();
ExcDeliverySubM subM=new ExcDeliverySubM();
for (int j = 0; j < ultraGrid1.Rows.Count; j++)
{
String strSubSqe = ultraGrid1.Rows[j].Cells["DeliverySubLineSqe"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strSubSqe))
{
MessageUtil.ShowTips("异常,送货单行号为空");
}
if (!testDeliveryStatus(strSubSqe,1,ref subc, ref subM))
{
return;
}
double b_Qty = 0; //送货量
double.TryParse(ultraGrid1.Rows[j].Cells["QTY"].Value.ToString().Trim(), out b_Qty);
double b_ReceivedQty = 0; //收货量
double.TryParse(ultraGrid1.Rows[j].Cells["SHIPQTY"].Value.ToString().Trim(), out b_ReceivedQty);
double b_RECQty = 0; //待处置量
double.TryParse(ultraGrid1.Rows[j].Cells["RECQTY"].Value.ToString().Trim(), out b_RECQty);
b_Qty = Math.Round(b_Qty,3);
b_ReceivedQty = Math.Round(b_ReceivedQty,3);
b_RECQty = Math.Round(b_RECQty,3);
String strRemark = ultraGrid1.Rows[j].Cells["remark2"].Value.ToString().Trim();
if (b_RECQty > 0 && String.IsNullOrEmpty(strRemark))
{
MessageUtil.ShowTips("若送货单行:" + strSubSqe + "存在待处置物料,请输入待处置原因或意见");
ultraGrid1.Rows[j].Activate();
return;
}
if (b_ReceivedQty<=0)
{
if(MessageUtil.ShowYesNoAndQuestion("送货单行:" + strSubSqe + "确定收货数量为0?若存在存在异常单,请填写异常单量")!=DialogResult.Yes)
ultraGrid1.Rows[j].Activate();
return;
}
ExcDeliverySubC EdC = new ExcDeliverySubC();
EdC.DeliverySubLineSqe = strSubSqe;
EdC.Status = "3";
EdC.ShipQty = b_ReceivedQty;//收货量
EdC.ReceivedQty = b_RECQty;//待处置
EdC.Remark = strRemark;
EdC.FjName = UserInfo.GetUserName();
EdC.FjUserid = UserInfo.GetUserID();
EdC.FjTime = System.DateTime.Now;
al.Add(EdC);
}
if (al.Count < 1)
{
MessageUtil.ShowTips("没有需要仓储复检送货单");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确认复检?若存在待处置量,请及时通知业务员进行异常单处理。").Equals(DialogResult.Yes))
{
CoreResult crt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "AddCheckAgain", new object[] { al});
if (crt.Resultcode == 0)
{
MessageUtil.ShowTips("复检成功");
Get_PUR_EXC_DELIVERY_M();
}
else
{
MessageUtil.ShowTips("复检失败");
}
}
}
///
/// 撤销仓储复检
///
private void QuitCheckAgain()
{
ExcDeliverySubC subc = new ExcDeliverySubC();
ExcDeliverySubM subM = new ExcDeliverySubM();
ArrayList al = new ArrayList();
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
String strSubSqe = ugr.Cells["DeliverySubLineSqe"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strSubSqe))
{
MessageUtil.ShowTips("异常,送货单行号为空");
}
if (!testDeliveryStatus(strSubSqe,2, ref subc, ref subM))
{
return;
}
ExcDeliverySubC Edc = new ExcDeliverySubC();
Edc.DeliverySubLineSqe = strSubSqe;
Edc.FjName = UserInfo.GetUserName();
Edc.FjUserid = UserInfo.GetUserID();
Edc.FjTime = System.DateTime.Now;
al.Add(Edc);
}
if (al.Count <= 0)
{
MessageUtil.ShowTips("没有找到须要撤销的送货单行");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确认撤销?").Equals(DialogResult.Yes))
{
CoreResult cr = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "QuitCheckAgain", new object[] { al });
if (cr.Resultcode == 0)
{
MessageUtil.ShowTips("撤销成功");
Get_PUR_EXC_DELIVERY_M();
}
else
{
MessageUtil.ShowTips("撤销失败");
return;
}
}
}
#endregion
#region 界面事件
///
/// 选择送货单主表
///
///
///
private void ultraGrid4_CellChange(object sender, CellEventArgs e)
{
try
{
if (e.Cell.Column.Key == "Check")
{
getSubM();
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("加载行信息异常:"+ex.Message);
}
}
private void ultraGrid4_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
{
try
{
if (e.Column.Key == "Check")
{
getSubM();
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("加载行信息异常:" + ex.Message);
}
}
private void getSubM()
{
ultraGrid4.UpdateData();
ExcDeliverySubC edsc = new ExcDeliverySubC();
List l = new List();
foreach (UltraGridRow ugr in ultraGrid4.Rows)
{
if ((bool)ugr.Cells["Check"].Value)
{
l.Add(ugr.Cells["DeliverySubId"].Value.ToString());
}
}
edsc.Col = l.ToArray();
Get_PUR_EXC_DELIVERY_C(edsc);
}
private void ck_createTimeNoJL_CheckedChanged(object sender, EventArgs e)
{
QcreateTime_BeginNoJL.Enabled = ck_createTimeNoJL.Checked;
QcreateTime_EndNoJL.Enabled = ck_createTimeNoJL.Checked;
}
#endregion
#region 公共函数
///
/// 送货单行状态校验
///
///
///
///
private bool testDeliveryStatus(String deliverySubId, int p, ref ExcDeliverySubC subc, ref ExcDeliverySubM subM)
{
if (String.IsNullOrEmpty(deliverySubId))
{
MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
return false;
}
subc = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { deliverySubId });
if (subc == null)
{
MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
return false;
}
if (subc.Validflag != "1")
{
MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
return false;
}
String testStatus = subc.Status;
if (String.IsNullOrEmpty(subc.DeliverySubId))
{
MessageUtil.ShowTips("未找到送货单行的头信息");
return false;
}
subM = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { subc.DeliverySubId });
if (subM == null)
{
MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
return false;
}
if (subM.Validflag != "1")
{
MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
return false;
}
if (subM.ReceiveType!= "110107")
{
MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 为非JIT送货单,无操作权限");
return false;
}
//复检
if (p == 1)
{
if (testStatus != "2")
{
MessageUtil.ShowTips("送货单行:" + deliverySubId + " 不在待复检状态");
return false;
}
}
//取消复检
else if (p == 2)
{
if (testStatus != "3")
{
MessageUtil.ShowTips("送货单行:" + deliverySubId + " 不在已复检状态");
return false;
}
}
else
{
MessageUtil.ShowTips("未知参数:" + p);
return false;
}
return true;
}
///
/// 查询送货通知单行表
///
private void Get_PUR_EXC_DELIVERY_C(ExcDeliverySubC EdC)
{
EdC.Validflag = "1";
dataTable2.Rows.Clear();
EdC.CreateUserid = this.UserInfo.GetUserID();//控制当前仓库人员登录只能看到自己所维护的库区
EdC.Status = txt_status.Value == null ? "" : txt_status.Value.ToString();
if (EdC.Col.Length > 0)
{
DataTable dt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdC });
GridHelper.CopyDataToDatatable(dt, dataTable2, true);
GridHelper.RefreshAndAutoSize(ultraGrid1);
}
}
#endregion
}
}