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 Core.Mes.Client.Comm.Control;
using Pur.Entity.ck;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using Core.Mes.Client.Comm.Tool;
using com.hnshituo.pur.vo;
using Core.Mes.Client.Comm.Server;
using com.hnshituo.ck;
using Pur.Pop_upWindow;
using Infragistics.Win.UltraWinEditors;
using Pur.configure;
using Infragistics.Win;
using Pur.Entity.configureEntity;
namespace Pur.ck
{
public partial class ExcDeliveryManagNew : FrmPmsBase
{
private ArrayList list1 = new ArrayList();
private string v_Mic="";
private string v_Mic_desc="";
private DataTable dt_addItem = new DataTable();
private String fileName="";
public ExcDeliveryManagNew()
{
InitializeComponent();
this.IsLoadUserView = true;
}
private void ExcDeliveryManagNew_Load(object sender, EventArgs e)
{
txt_judgeTypeHY.SelectedIndex = 0;
ck_Ctime.Checked = true;
txt_CreateTimeS.Value = DateTime.Now.AddMonths(-1);
txt_CreateTimeS.Enabled = true;
txt_CreateTimeE.Value = Convert.ToDateTime(DateTime.Now.ToShortDateString()).AddHours(23).AddMinutes(59);
txt_CreateTimeE.Enabled = true;
txt_status.SelectedIndex = 1;//默认待收货状态
ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true;
GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "CHK" });
GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] {"REMARK", "JUDGETYPE" });
GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] {});
GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "CHK", "RECQTY", "carNum", "shipQty", "checkMsg","meteringFlag","pcFlag"});
//
this.ultraGrid2.DisplayLayout.ValueLists.Add("checkList1");
this.ultraGrid2.DisplayLayout.ValueLists["checkList1"].ValueListItems.Add("否", "否");
this.ultraGrid2.DisplayLayout.ValueLists["checkList1"].ValueListItems.Add("是", "是");
this.ultraGrid2.DisplayLayout.ValueLists["checkList1"].DisplayStyle = ValueListDisplayStyle.DisplayText;
this.ultraGrid2.DisplayLayout.Bands[0].Columns["meteringFlag"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
this.ultraGrid2.DisplayLayout.Bands[0].Columns["meteringFlag"].ValueList = this.ultraGrid2.DisplayLayout.ValueLists["checkList1"];
this.ultraGrid2.DisplayLayout.Bands[0].Columns["pcFlag"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
this.ultraGrid2.DisplayLayout.Bands[0].Columns["pcFlag"].ValueList = this.ultraGrid2.DisplayLayout.ValueLists["checkList1"];
ultraExpandableGroupBox4.Expanded = true;
ultraExpandableGroupBox3.Expanded = true;
ultraGrid3.DisplayLayout.Bands[0].Columns["JUDGETYPECODE"].EditorComponent = ultraJUDGE_TYPE;
ultraGrid3.DisplayLayout.Bands[0].Columns["JUDGETYPECODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
Get_ExcSubM();
}
#region toolbar工具栏
///
/// 菜单栏
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
Get_ExcSubM();
break;
case "doPrint":
doPrint();
break;
case "Close":
this.Close();
break;
case "conFirmation":// 初检完成
setRecList();
break;
case "cancelConFirmation":// 取消初检
cancelRecList();
break;
case "QuitRec"://退货
QuitRec();
break;
case "doSplit"://拆分入库
doSplit();
break;
case "Delete"://delete'
doDeleteBill();
break;
}
}
///
/// 删除
///
private void doDeleteBill()
{
if (list1.Count <= 0)
{
MessageUtil.ShowTips("请勾选需退货的送货单头");
return;
}
String[] ls = (String[])list1.ToArray(typeof(string));
String str1 = String.Join(";", ls);
if (str1.ToLower().Contains("rb"))
{
if (MessageUtil.ShowYesNoAndQuestion("选择的送货单[" + str1 + "]中存在让步接收单,确定删除?") != DialogResult.Yes)
{
return;
}
}
else
{
if (MessageUtil.ShowYesNoAndQuestion("确定删除送货单:" + str1 + "?") != DialogResult.Yes)
{
return;
}
}
CoreResult cr = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "delete_bill", new object[] { list1,UserInfo.GetUserID(),UserInfo.GetUserName()});
if (cr.Resultcode == 0)
{
MessageUtil.ShowTips("操作成功");
Get_ExcSubM();
return;
}
else
{
MessageUtil.ShowTips("操作失败" + cr.Resultmsg);
return;
}//this.UseWaitCursor
}
///
/// 拆分入库
///
private void doSplit()
{
if (ultraGrid2.ActiveRow == null)
{
MessageUtil.ShowTips("请选择送货单行进行操作!");
return;
}
UltraGridRow row = ultraGrid2.ActiveRow;
String strDeliverySubLineSqe = row.GetCellValue("deliverySubLineSqe").ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("选择待拆分的送货单行号为空");
return;
}
frmPopDeliverySubSplit FPRD = new frmPopDeliverySubSplit(this.ob, strDeliverySubLineSqe);
FPRD.ShowDialog();
if (FPRD.tips == "1")
{
doQuerySubLineByList(list1);
return;
}
}
///
/// 退货
///
private void QuitRec()
{
if (list1.Count <= 0)
{
MessageUtil.ShowTips("请勾选需退货的送货单头");
return;
}
String[] ls = (String[])list1.ToArray(typeof(string));
String str1 = String.Join(";", ls);
if (MessageUtil.ShowYesNoAndQuestion("确定对勾选的送货单:" + str1 + "进行全部退货操作?") != DialogResult.Yes)
{
return;
}
CoreResult cr = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "QuitRec", new object[] { list1 });
if (cr.Resultcode == 0)
{
MessageUtil.ShowTips("操作成功");
Get_ExcSubM();
return;
}
else
{
MessageUtil.ShowTips("操作失败" + cr.Resultmsg);
return;
}//this.UseWaitCursor
}
///
/// 取消初检
///
private void cancelRecList()
{
ultraGrid2.UpdateData();
ArrayList al = new ArrayList();
for (int j = 0; j < ultraGrid2.Rows.Count; j++)
{
ExcDeliverySubC EdC = new ExcDeliverySubC();
EdC.DeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString();
EdC.DeliverySubLineSqe = ultraGrid2.Rows[j].Cells["DELIVERYSUBLINESQE"].Value.ToString();//送货通知单行号
//校验数据
if (testDeliveryStatus(EdC.DeliverySubLineSqe, 2,"","") == false)
{
return;
}
EdC.Status = "1";
EdC.CreateName = UserInfo.GetUserName();
EdC.CreateUserid = UserInfo.GetUserID();
EdC.CreateTime = DateTime.Now;
al.Add(EdC);
}
if (list1.Count <= 0)
{
MessageUtil.ShowTips("请勾选需取消初检的送货单头");
return;
}
String[] ls = (String[])list1.ToArray(typeof(string));
String str1 = String.Join(";", ls);
if (MessageUtil.ShowYesNoAndQuestion("确定对选择的送货单:" + str1 + "进行取消初检操作?") != DialogResult.Yes)
{
return;
}
CoreResult crt = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "checkBill", new object[] { al });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("取消初检失败 " + crt.Resultmsg);
return;
}
MessageUtil.ShowTips("操作成功");
Get_ExcSubM();
}
///
/// 初检完成
///
private void setRecList()
{
double b_INNUM = 0; //收货量
ultraGrid2.UpdateData();
ArrayList al = new ArrayList();
for (int j = 0; j < ultraGrid2.Rows.Count; j++)
{
ExcDeliverySubC EdC = new ExcDeliverySubC();
ExcDeliverySubM subMOld = new ExcDeliverySubM();
double.TryParse(ultraGrid2.ActiveRow.Cells["shipQty"].Value.ToString().Trim(), out b_INNUM);
String strSubSqe = ultraGrid2.ActiveRow.Cells["deliverySubLineSqe"].Value.ToString();
EdC = this.GetJsonService().execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strSubSqe });
//交货量差控制
//if (testDeliveryQtyCtrl(subMOld, EdC, b_INNUM) == false)
//{
// return;
//}
EdC.DeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString();
EdC.DeliverySubLineSqe = ultraGrid2.Rows[j].Cells["DELIVERYSUBLINESQE"].Value.ToString();//送货通知单行号
EdC.CarNum = ultraGrid2.Rows[j].Cells["carNum"].Value.ToString();
EdC.Status = "2";
EdC.ShipQty = Math.Round(ultraGrid2.Rows[j].Cells["shipQty"].Value.ToString() == "" ? 0 : double.Parse(ultraGrid2.Rows[j].Cells["shipQty"].Value.ToString()),3);
EdC.ReceivedQty = Math.Round(ultraGrid2.Rows[j].Cells["RECQTY"].Value.ToString() == "" ? 0 : double.Parse(ultraGrid2.Rows[j].Cells["RECQTY"].Value.ToString()),3);//待处置量
EdC.CarNum = ultraGrid2.Rows[j].Cells["CarNum"].Value == null ? "" : ultraGrid2.Rows[j].Cells["CarNum"].Value.ToString();
EdC.Remark = ultraGrid2.Rows[j].Cells["checkMsg"].Value == null ? "" : ultraGrid2.Rows[j].Cells["checkMsg"].Value.ToString();
EdC.CreateName = UserInfo.GetUserName();
EdC.CreateUserid = UserInfo.GetUserID();
EdC.CreateTime = DateTime.Now;
EdC.MeteringFlag = ultraGrid2.Rows[j].Cells["meteringFlag"].Value.ToString().Trim() == "是" ? "1" : "0";
EdC.PcFlag = ultraGrid2.Rows[j].Cells["pcFlag"].Value.ToString().Trim()=="是"?"1":"0";
//校验数据
if (testDeliveryStatus(EdC.DeliverySubLineSqe, 1, EdC.MeteringFlag, EdC.PcFlag) == false)
{
return;
}
//if (EdC.ShipQty < EdC.ReceivedQty)
//{
// MessageUtil.ShowTips("送货单行:" + EdC.DeliverySubLineSqe + "的实送数量需大于待处置量数量");
// return;
//}
//if (EdC.ShipQty == EdC.ReceivedQty)
//{
// MessageUtil.ShowTips("送货单行:" + EdC.DeliverySubLineSqe + "的实送数量等于处置量数量,该送货单行将标识为异常单。若存在异常量,请及时进行异常单处理");
// return;
//}
if (EdC.ReceivedQty > 0 && String.IsNullOrEmpty(EdC.Remark))
{
MessageUtil.ShowTips("若送货单行:" + EdC.DeliverySubLineSqe + "存在待处置物料,请输入待处置原因或意见");
return;
}
al.Add(EdC);
}
if (list1.Count <= 0)
{
MessageUtil.ShowTips("请勾选送货单头");
return;
}
if (al.Count <= 0)
{
MessageUtil.ShowTips("无可初检送货单行");
return;
}
String[] ls = (String[])list1.ToArray(typeof(string));
String str1 = String.Join(";", ls);
if (MessageUtil.ShowYesNoAndQuestion("确定对已勾选的送货单:" + str1 + "进行初检操作?若存在待处置量,请及时进行异常单处置。") != DialogResult.Yes)
{
return;
}
CoreResult crt = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "checkBill", new object[] { al });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("初检失败 " + crt.Resultmsg);
return;
}
MessageUtil.ShowTips("已完成初检");
Get_ExcSubM();
}
private DateTime setCreateTimeEnd(Object value)
{
DateTime time = Convert.ToDateTime(value);
DateTime endtime = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
return endtime;
}
#region 交货量差控制
private bool testDeliveryQtyCtrl(ExcDeliverySubM subMOld, ExcDeliverySubC EdC, double b_INNUM)
{
String strSupp = subMOld.SuppCode;
String strItemCode = EdC.ItemCode;
Entity_SuppGrade grade = new Entity_SuppGrade();
grade.SuppCode = strSupp;
grade.ItemCode = strItemCode;
double qty = (double)EdC.Qty;
List listGrade = this.execute>("com.hnshituo.pur.configure.service.SuppGradeService", "find", new object[] { grade, 0, 0 });//添加操作
if (listGrade != null && listGrade.Count >= 1)
{
grade = listGrade[0];
if (grade.DelvryRangeTpe == "0")
{
return true;
}
else if (grade.DelvryRangeTpe == "1")//绝对值
{
double maxQty = (double)grade.DelvryRangeMax + qty;
double minQty = qty - (double)grade.DelvryRangeMin;
if (b_INNUM > maxQty)
{
MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的入库量已经超出交货量上限为:" + maxQty);
return false;
}
if (b_INNUM < minQty)
{
MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的入库量已经超出交货量下限为:" + minQty);
return false;
}
}
else if (grade.DelvryRangeTpe == "2")//百分比
{
double maxQty = Math.Round(qty * (1 + (double)grade.DelvryRangeMax / 100), 3);
double minQty = Math.Round(qty * (1 - (double)grade.DelvryRangeMax / 100), 3);
if (b_INNUM > maxQty)
{
MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的入库量已经超出交货量上限为:" + maxQty);
return false;
}
if (b_INNUM < minQty)
{
MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的入库量已经超出交货量下限为:" + minQty);
return false;
}
}
else if (grade.DelvryRangeTpe == "2") //不允许
{
if (b_INNUM != qty)
{
MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的入库量不允许有交货量差,入库量和和要求送货量必须一致");
return false;
}
}
else
{
MessageUtil.ShowTips("请维护供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的交货量差方式");
return false;
}
}
else
{
MessageUtil.ShowTips("请维护供应商:" + subMOld.SuppName + "的物料:" + EdC.ItemName + "的交货量差");
return false;
}
return true;
}
#endregion
///
/// 查询
///
private void Get_ExcSubM()
{
try
{
this.Cursor = Cursors.WaitCursor;
list1.Clear();
dataTable1.Clear();
dataTable4.Clear();
dataTable2.Clear();
clearSampleTabHY();
Hashtable map = new Hashtable();
map.Add("deliverySubId", txt_deliverySubId.Text.Trim());
map.Add("orderId", txt_OrderId.Text.Trim());
map.Add("supperId", txt_suppCode.Text.Trim());
map.Add("validDataPurviewIds", this.ValidDataPurviewIds);
if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeS.Text))
{
map.Add("createTimeBegin", Convert.ToDateTime(txt_CreateTimeS.Value).ToString());
}
if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeE.Text))
{
map.Add("createTimeEnd", setCreateTimeEnd(txt_CreateTimeE.Value));
}
if (txt_status.SelectedIndex != -1)
{
map.Add("statusCJ", txt_status.Value.ToString().Trim());
}
DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
GridHelper.CopyDataToDatatable(dt, dataTable1, true);
GridHelper.RefreshAndAutoSize(ultraGrid1);
}
catch (Exception ex)
{
MessageUtil.ShowTips("查询送货单主表数据失败:" + ex.Message);
}
finally
{
this.Cursor = Cursors.Default;
}
}
///
/// 打印检化验委托单
///
private void doPrint()
{
try
{
this.Cursor = Cursors.WaitCursor;
if (ultraGrid2.ActiveRow == null)
{
MessageUtil.ShowTips("请选择发货单行进行操作!");
return;
}
String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单行号为空");
}
ExcDeliverySubC dsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
if (!String.IsNullOrEmpty(dsc.CheckNo))
{
string strurl = "";
DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1223" }, this.ob);
DataRow[] drArr = dt.Select("validflag='1'");
if (drArr.Length != 1)
{
MessageUtil.ShowTips("基础数据维护错误:报表系统需维护有效的Ip且只能维护一个有效ip!");
return;
}
String TipsEnv = drArr[0]["baseName"].ToString();
String strUrlPort = "http://172.54.10.42:8080";//报表系统IP
String[] str = strUrlPort.Split(':');
String strUrl = str[0] + ":" + str[1];
if (ob.MainUrl.StartsWith(strUrl))
{
//测试环境
if (TipsEnv == "2")
{
strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrderDev.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
}
//生产环境
else
{
strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrder.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
}
}
else
{
//测试环境
if (TipsEnv == "2")
{
strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrderDev.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
}
//生产环境
else
{
strurl = strUrlPort + "/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrder.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
}
}
//if (ob.MainUrl.StartsWith("http://127.0.0.1"))
//{
// strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrderDev.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
//}
//else
//{
// strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPurMatCheckTaskOrderDev.cpt&op=view" + "&CHECK_NO=" + dsc.CheckNo;
//}
FrmRepExcel fBug = new FrmRepExcel(ob, strurl);
fBug.AutoSize = true;
fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fBug.WindowState = FormWindowState.Maximized;
fBug.Text = "TPCO理化检验任务单";
fBug.Show();
}
else
{
MessageUtil.ShowTips("暂未绑定送检号!");
}
}
finally
{
this.Cursor = Cursors.Default;
}
}
#endregion
#region 界面事件
///
/// grid1选择事件控制
///
///
///
private void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
try
{
list1.Clear();
ultraGrid1.UpdateData();
String noticeId = "";
int i = 0;
if (e.Cell.Column.Key == "CHK")
{
clearSampleTabHY();
dataTable2.Clear();
dataTable4.Clear();
dataSet3.Clear();
dataSet4.Clear();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
String strDeliverySubId = row.Cells["DeliverySubId"].Value.ToString();
String strnoticeId = row.Cells["noticeId"].Value.ToString();
if (!String.IsNullOrEmpty(strDeliverySubId))
{
if (i == 0)
{
noticeId = strnoticeId;
}
else
{
if (noticeId != strnoticeId)
{
MessageUtil.ShowTips("请选择同通知单下送货单进行操作!");
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
}
list1.Add(strDeliverySubId);
i = i + 1;
}
}
}
dataTable2.Rows.Clear();
}
if (list1.Count > 0)
{
doQuerySubLineByList(list1);
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("查询送货单行信息失败:" + ex.Message);
}
}
///
/// grid2组批事件控制
///
///
///
private void ultraGrid2_CellChange(object sender, CellEventArgs e)
{
if (ck_isBatch.Checked)
{
if (e.Cell.Column.Key == "CHK")
{
txt_carNumHY.Clear();
ultraGrid2.UpdateData();
int i = 0;
double qtySum = 0;
string noticeId = "";
string batchNo = "";
String itemUnique = "";
String SubLineId = "";
String orderId = "";
StringBuilder carNumCol = new StringBuilder("");
dataSet3.Clear();
dataSet4.Clear();
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
double dbQty = Convert.ToDouble(row.GetCellValue("qty"));
String strcarNum = row.Cells["carNum"].Value.ToString();
String strnoticeId = row.Cells["noticeId"].Value.ToString();
String strBatchNo = row.Cells["batchNo"].Value.ToString();
String strOrderId = row.Cells["orderId"].Value.ToString();
String stritemUnique = row.Cells["itemUnique"].Value.ToString();
String strDeliverySubLineSqe = row.GetCellValue("deliverySubLineSqe").ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单行号为空");
}
if (testSubC(strDeliverySubLineSqe) == false)
{
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
qtySum = qtySum + dbQty;
if (i == 0)
{
noticeId = strnoticeId;
itemUnique = stritemUnique;
SubLineId = strDeliverySubLineSqe;
batchNo = strBatchNo;
orderId = strOrderId;
}
else
{
if (strnoticeId != noticeId)
{
MessageUtil.ShowTips("请选择同通知单物料进行操作!");
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
if (batchNo != strBatchNo)
{
MessageUtil.ShowTips("请选择同生产批次进行操作!");
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
if (itemUnique != stritemUnique)
{
MessageUtil.ShowTips("请选择同物料进行操作!");
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
if (orderId != strOrderId)
{
MessageUtil.ShowTips("请选择同合同物料进行操作!");
e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK"));
return;
}
}
if (!String.IsNullOrEmpty(strcarNum))
{
if (carNumCol.Length > 1)
{
carNumCol.Append(",").Append(strcarNum);
}
else
{
carNumCol.Append(strcarNum);
}
}
else
{
MessageUtil.ShowTips("供应商未填写车号,请填写车号!");
}
i = i + 1;
}
}
if (i <= 0)
{
return;
}
clearSampleTabHY();
ExcDeliverySubC dsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { SubLineId });
if (dsc != null)
{
//检化验数据加载
if (!String.IsNullOrEmpty(dsc.CheckNo))
{
String strCheckNo = dsc.CheckNo;
if (String.IsNullOrEmpty(strCheckNo))
{
//待检检验项目
queryItemList(dsc);
}
else
{
//已委托检验项目
querySampleList(strCheckNo);
}
GridHelper.RefreshAndAutoSize(ultraGrid3);
}
//加载合同附件
getOrderAppend(dsc.DeliverySubLineSqe, "");
}
txt_carNumHY.Text = carNumCol.ToString();
txt_QtyHY.Text = qtySum + "";
ck_pcFlag.Checked = dsc.PcFlag == null ? false : (dsc.PcFlag == "1" ? true : false);
txt_UOM.Text = dsc.ItemUom;
if (ck_pcFlag.Checked)
{
ck_pcFlag.Enabled = false;
}
else
{
ck_pcFlag.Enabled = true;
}
}
}
}
///
/// 激活行
///
///
///
private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
{
//根据物送货单行的检验编号查询
try
{
if (ck_isBatch.Checked)
{
return;
}
ultraGrid2.UpdateData();
clearSampleTabHY();
dataSet3.Clear();
dataSet4.Clear();
String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
String strDeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubId))
{
MessageUtil.ShowTips("送货单号为空");
}
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单行号为空");
}
ExcDeliverySubM dsm = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { strDeliverySubId });
ExcDeliverySubC dsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
if (dsc != null && dsm != null)
{
//检化验数据加载
String strCheckNo = dsc.CheckNo;
if (String.IsNullOrEmpty(strCheckNo))
{
//待检检验项目
queryItemList(dsc);
}
else
{
//已委托检验项目
querySampleList(strCheckNo);
}
GridHelper.RefreshAndAutoSize(ultraGrid3);
//加载附件
getOrderAppend(strDeliverySubLineSqe, "");
if (!ck_isBatch.Checked)
{
txt_carNumHY.Text = dsc.CarNum;
txt_QtyHY.Text = dsc.Qty + "";
ck_pcFlag.Checked = dsc.PcFlag == null ? false : (dsc.PcFlag == "1" ? true : false);
txt_UOM.Text = dsc.ItemUom;
if (ck_pcFlag.Checked)
{
ck_pcFlag.Enabled = false;
}
else
{
ck_pcFlag.Enabled = true;
}
txt_CheckNo.Text = dsc.CheckNo;
}
}
}
catch (Exception ex)
{
MessageUtil.ShowTips(ex.Message);
}
}
//创建时间输入控制
private void ck_Ctime_CheckedChanged(object sender, EventArgs e)
{
txt_CreateTimeS.Enabled = ck_Ctime.Checked;
txt_CreateTimeE.Enabled = ck_Ctime.Checked;
}
private void ck_isBatch_CheckedChanged(object sender, EventArgs e)
{
dataTable4.Clear();
dataTable6.Clear();
clearSampleTabHY();
foreach (UltraGridRow row in ultraGrid2.Rows)
{
row.Cells["CHK"].Value = false;
}
if (ck_isBatch.Checked)
{
ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false;
label5.Text = "组批车号";
label8.Text = "组批重量";
}
else
{
ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true;
label5.Text = "车 号";
label8.Text = "重 量";
}
}
#endregion
#region 界面按钮
//检化验委托发送
private void tbn_sendCheck_Click(object sender, EventArgs e)
{
ultraGrid2.UpdateData();
ultraGrid3.UpdateData();
List listSubC = new List();
List listDetail = new List();
StringBuilder carNumCol = new StringBuilder("");
if (ck_isBatch.Checked)
{
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
String strDeliverySubLineSqe = row.GetCellValue("deliverySubLineSqe").ToString().Trim();
String strDeliverySubId = row.Cells["DeliverySubId"].Value.ToString().Trim();
String strCarNum = row.Cells["CarNum"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubId))
{
MessageUtil.ShowTips("送货单号为空");
row.Activated = true;
return;
}
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单行号为空");
row.Activated = true;
return;
}
if (String.IsNullOrEmpty(strCarNum))
{
MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "车号为空,请输入车号");
row.Activated = true;
return;
}
if (testSubC(strDeliverySubLineSqe) == false)
{
return;
}
ExcDeliverySubC subC = new ExcDeliverySubC();
subC.DeliverySubLineSqe = strDeliverySubLineSqe;
subC.CarNum = strCarNum;
listSubC.Add(subC);
if (carNumCol.Length > 1)
{
carNumCol.Append(",").Append(strCarNum);
}
else
{
carNumCol.Append(strCarNum);
}
}
}
if (listSubC.Count <= 0)
{
MessageUtil.ShowTips("请选择待检物料进行组批检化验!");
return;
}
}
else
{
if (ultraGrid2.ActiveRow == null)
{
MessageUtil.ShowTips("请选择待检送货单行进行操作!");
return;
}
String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
String strDeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
String strCarNum = ultraGrid2.ActiveRow.Cells["CarNum"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strDeliverySubId))
{
MessageUtil.ShowTips("送货单号为空");
return;
}
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单行号为空");
return;
}
if (String.IsNullOrEmpty(strCarNum))
{
MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "车号为空,请输入车号");
return;
}
if (testSubC(strDeliverySubLineSqe) == false)
{
return;
}
ExcDeliverySubC subC = new ExcDeliverySubC();
subC.DeliverySubLineSqe = strDeliverySubLineSqe;
subC.CarNum = strCarNum;
listSubC.Add(subC);
if (carNumCol.Length > 1)
{
carNumCol.Append(",").Append(strCarNum);
}
else
{
carNumCol.Append(strCarNum);
}
}
CoreResult re = new CoreResult();
ExcDeliverySubC dsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { listSubC[0].DeliverySubLineSqe });
ExcDeliverySubM dsm = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { dsc.DeliverySubId });
if (dsm == null)
{
MessageUtil.ShowTips("未发现送货单:" + dsc.DeliverySubId + "信息记录!");
return;
}
CheckconsignBaseinfo baseInfo = new CheckconsignBaseinfo();
if (!StringUtil.IsDouble(txt_QtyHY.Text.Trim()))
{
MessageUtil.ShowTips("请输入大于0的有效数量!");
txt_QtyHY.Focus();
return;
}
//if (String.IsNullOrEmpty(v_Mic_desc) || String.IsNullOrEmpty(v_Mic) || String.IsNullOrEmpty(txt_std.Text.Trim()))
//{
// MessageUtil.ShowTips("检验标准不能为空");
// txt_QtyHY.Focus();
// return;
//}
if (String.IsNullOrEmpty(txt_std.Text.Trim()))
{
if (MessageUtil.ShowYesNoAndQuestion("系统未维护该物料检验标准,确定继续发送?") != DialogResult.Yes)
{
return;
}
}
baseInfo.CarNo = carNumCol.ToString();
//baseInfo.StandardsCode = dsc.ItemStandardsCode;
// baseInfo.StandardsId = dsc.ItemStandardsId;
baseInfo.ProductStd = dsc.ItemStandardsCode;
baseInfo.ProductStdId = dsc.ItemStandardsId;
baseInfo.SendDept = UserInfo.GetDepartment();
baseInfo.SuppName = dsm.SuppName;
baseInfo.ArriveStationTime = ((DateTime)dsm.PlanedDeliveryDate).ToString("yyyy/MM/dd");
baseInfo.CheckCount = "0";
baseInfo.Weight = txt_QtyHY.Text.Trim();
baseInfo.MicDesc = v_Mic_desc;
baseInfo.Mic = v_Mic;
baseInfo.IsFg ="0";
baseInfo.ConsignDept = UserInfo.GetDepartment();
baseInfo.ConsignName = UserInfo.GetUserName();
baseInfo.FilePosition = "Pms/ZBS/" + dsc.DeliverySubLineSqe + "/";
baseInfo.ConsignTime = DateTime.Now;
baseInfo.DataType = "0";//默认供应部
baseInfo.Validflag = "1";
baseInfo.WeightUnit = dsc.WeightUnit;
baseInfo.GetSampleStdDesc = txt_GETSAMPLESTDDETAIL.Text.Trim(); ;
baseInfo.GetSampleStd = txt_GETSAMPLESTD.Text.Trim();
baseInfo.ZbsIsExist = "1";
baseInfo.IsJudge = "0";
baseInfo.IsUpload = "0";
baseInfo.ItemCode = dsc.ItemCode;
baseInfo.ItemName = dsc.ItemName;
baseInfo.OrderNo = dsc.OrderId;
if (txt_judgeTypeHY.SelectedIndex == -1)
{
MessageUtil.ShowTips("请选择委托类型");
txt_judgeTypeHY.Focus();
return;
}
baseInfo.JudgeTypeCode = txt_judgeTypeHY.Value.ToString().Trim();
baseInfo.JudgeType = txt_judgeTypeHY.Text.Trim();
//检验项目
foreach (UltraGridRow row in ultraGrid3.Rows)
{
CheckconsignDetail detail = new CheckconsignDetail();
String strBatchNo = String.IsNullOrEmpty(dsc.BatchNo) ? dsc.NoticeId : dsc.BatchNo;
String strMatCode = row.GetCellValue("MATCODE").ToString().Trim();
String strMatName = row.GetCellValue("MATNAME").ToString().Trim();
String strRemark = row.GetCellValue("REMARK").ToString().Trim();
String StdminSign = row.GetCellValue("STDMINSIGN").ToString();
String Stdmin = row.GetCellValue("STDMIN").ToString();
String Stdmax = row.GetCellValue("STDMAX").ToString();
String StdmaxSign = row.GetCellValue("STDMAXSIGN").ToString();
//DET.CheckCycle = ur.Cells["CHECKCYCLE"].Text.Trim();
String JudgeType = row.GetCellValue("JUDGETYPECODE").ToString();
String JudgeTYpeCode = row.Cells["JUDGETYPECODE"].Text.Trim();
//String strZbsValue = row.GetCellValue("ZBSVALUE").ToString().Trim();
detail.BatchNo = strBatchNo;
detail.MatCode = strMatCode;
detail.MatName = strMatName;
detail.Stdmax=
detail.Flag = "0";//待发送
detail.Remark = strRemark;
detail.Stdmax = Stdmax;
detail.StdmaxSign = StdmaxSign;
detail.Stdmin = Stdmin;
detail.StdminSign = StdminSign;
detail.JudgeType = JudgeType;
detail.JudgeTypeCode = JudgeTYpeCode;
//detail.ZbsValue = strZbsValue;
listDetail.Add(detail);
}
if (listDetail.Count <= 0)
{
MessageUtil.ShowTips("未维护检验项目,请维护检验基础信息或者新增检验项目");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确定为物料:" + dsc.ItemCode + "新增检验委托?") != DialogResult.Yes)
{
return;
}
re = this.execute("com.hnshituo.pur.ck.service.CheckconsignDetailService", "insert_detail1", new object[] { baseInfo, listDetail, listSubC });
if (re.Resultcode == 0)
{
MessageUtil.ShowTips("操作成功,新增检验单:" + re.Resultmsg);
//重新加载送货单行
doQuerySubLineByList(list1);
CkClassCommon.doActiveSelRow(ultraGrid2, "deliverySubLineSqe", listSubC[0].DeliverySubLineSqe);
//重新加载检验项目
ExcDeliverySubC dsc1 = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { listSubC[0].DeliverySubLineSqe });
if (!String.IsNullOrEmpty(re.Resultmsg))
{
dataTable4.Clear();
querySampleList(dsc1.CheckNo);
}
}
else
{
MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
}
}
#endregion
#region 公共用函数
private bool testSubC(string strDeliverySubLineSqe)
{
ExcDeliverySubC dsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
if (dsc == null)
{
MessageUtil.ShowTips("未发现送货单行:" + strDeliverySubLineSqe + "信息记录,可能已被删除,或请刷新界面重试");
return false;
}
if (dsc.Validflag != "1")
{
MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "信息记录可能已被删除,或请刷新界面重试");
return false;
}
if (!String.IsNullOrEmpty(dsc.CheckNo))
{
MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "已生成检化验委托,无需重复操作!");
return false;
}
return true;
}
//按照送货单集合查送货单
private void doQuerySubLineByList(ArrayList list)
{
clearSampleTabHY();
dataTable2.Clear();
dataTable4.Clear();
dataSet3.Clear();
dataSet4.Clear();
//this.Cursor = Cursors.WaitCursor;
ExcDeliverySubC EdSc = new ExcDeliverySubC();
EdSc.Col = (string[])list.ToArray(typeof(string));
EdSc.Validflag = "1";
DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
GridHelper.CopyDataToDatatable(dt, dataTable2, true);
for (int i = 0; i < dataTable2.Rows.Count; i++)
{
if (dataTable2.Rows[i]["shipQty"] == DBNull.Value)
{
dataTable2.Rows[i]["shipQty"] = dataTable2.Rows[i]["QTY"];
}
else
{
if (Convert.ToDouble(dataTable2.Rows[i]["shipQty"].ToString().Trim()) <= 0)
{
dataTable2.Rows[i]["shipQty"] = dataTable2.Rows[i]["QTY"];
}
}
}
GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["checkMsg"], ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"] });
}
//查询送货单行信息
private void doQuerySubLine(String strDeliverySubId)
{
if (String.IsNullOrEmpty(strDeliverySubId))
{
MessageUtil.ShowTips("送货单号为空");
}
clearSampleTabHY();
dataTable2.Clear();
dataTable4.Clear();
this.Cursor = Cursors.WaitCursor;
ExcDeliverySubC EdSc = new ExcDeliverySubC();
EdSc.DeliverySubId = strDeliverySubId;
EdSc.Validflag = "1";
DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
GridHelper.CopyDataToDatatable(dt, dataTable2, true);
GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["checkMsg"] });
}
//读取待检检验项目
private void queryItemList(ExcDeliverySubC dsc)
{
if (dsc.MeteringFlag == "1")
{
OrderCStdBaseinfo baseInfo = new OrderCStdBaseinfo();
baseInfo.OrderLineSqe = dsc.OrderLineSqe;
baseInfo.Validflag = "1";
List list_baseInfo = this.execute>("com.hnshituo.pur.order.service.OrderCStdBaseinfoService", "find", new object[] { baseInfo, 0, 0 });
if (list_baseInfo != null && list_baseInfo.Count > 0)
{
String mic = list_baseInfo[0].Mic;
String micDesc = list_baseInfo[0].MicDesc;
String std = list_baseInfo[0].StandardsCode;
txt_std.Text = std;
txt_statusHY.Text = "待发送";
v_Mic = mic;
v_Mic_desc = micDesc;
txt_GETSAMPLESTD.Text = list_baseInfo[0].GetSampleStd;
txt_GETSAMPLESTDDETAIL.Text = list_baseInfo[0].GetSampleStdDesc;
txt_UOM.Text = dsc.ItemUom;
//开始查询检验项目明细
OrderCStdDetail detail = new OrderCStdDetail();
detail.OrderLineSqe = dsc.OrderLineSqe;
detail.Validflag = "1";
DataTable list_detail = this.execute("com.hnshituo.pur.order.service.OrderCStdDetailService", "find", new object[] { detail, 0, 0 });
GridHelper.CopyDataToDatatable(list_detail, dataTable4, true);
}
else
{
txt_std.Text = "";
txt_statusHY.Text = "请维护检验标准";
}
}
else
{
txt_std.Text = "";
txt_statusHY.Text = "";
}
}
//读取已生成检验鲜项目从表数据
private void querySampleList(String strCheckNo)
{
try
{
CheckconsignBaseinfo tempbaseInfo = new CheckconsignBaseinfo();
tempbaseInfo.CheckNo = strCheckNo;
tempbaseInfo.Validflag = "1";
List ListBaseInfo = this.execute>("com.hnshituo.pur.ck.service.CheckconsignBaseinfoService", "find", new object[] { tempbaseInfo,0,0});
if (ListBaseInfo.Count() <= 0)
{
txt_statusHY.Text = "已作废";
}
else
{
CheckconsignBaseinfo baseInfo = ListBaseInfo[0];
txt_statusHY.Text = "已发送";
txt_std.Text = baseInfo.StandardsCode;
v_Mic = baseInfo.Mic;
v_Mic_desc = baseInfo.MicDesc;
txt_GETSAMPLESTD.Text = baseInfo.GetSampleStd;
txt_GETSAMPLESTDDETAIL.Text = baseInfo.GetSampleStdDesc;
CheckconsignDetail detail = new CheckconsignDetail();
detail.CheckNo = strCheckNo;
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CheckconsignDetailService", "find", new object[] { detail,0,0});
GridHelper.CopyDataToDatatable(dt, dataTable4, true);
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("查询检验项目失败:" + ex.Message);
}
}
//清空jhy编辑区
private void clearSampleTabHY()
{
txt_std.Clear();
txt_carNumHY.Clear();
txt_QtyHY.Clear();
txt_CheckNo.Clear();
ck_pcFlag.Checked = false;
ck_pcFlag.Enabled = true;
txt_statusHY.Clear();
v_Mic="";
v_Mic_desc="";
dt_addItem.Clear();
txt_UOM.Clear();
txt_GETSAMPLESTD.Clear();
txt_GETSAMPLESTDDETAIL.Clear();
txt_addItemHY.Clear();
txt_addItemRemark.Clear();
dt_addItem.Clear();
}
///
/// 校验检验号是否可以作废
///
///
///
private bool testSampleNo(string strCheckNo)
{
CheckconsignDetail detail = new CheckconsignDetail();
detail.CheckNo = strCheckNo;
List list = this.execute>("com.hnshituo.pur.ck.service.CheckconsignDetailService", "find", new object[] { detail, 0, 0 });
if (list != null)
{
if (list.Count > 0)
{
foreach (CheckconsignDetail det in list)
{
if (det.Flag != "-1")
{
MessageUtil.ShowTips("该检化验项委托可能已发送,不能作废!");
return false;
}
}
}
else
{
MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
return false;
}
}
else
{
MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
return false;
}
return true;
}
///
/// 初检或者取消初检校验
///
///
///
///
private bool testDeliveryStatus(String deliverySubId, int p,String meterFlag,String PcFlag)
{
if (String.IsNullOrEmpty(deliverySubId))
{
MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
return false;
}
ExcDeliverySubC subc = this.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;
}
ExcDeliverySubM subM = this.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.Status != "1")
{
MessageUtil.ShowTips("送货单:" + subc.DeliverySubId + " 可能已经收货完成,或请刷新界面重试");
return false;
}
//完成初检校验
if (p == 1)
{
if (testStatus != "1")
{
MessageUtil.ShowTips("送货单行:" + deliverySubId + " 可能已经初检完成,或请刷新界面重试");
return false;
}
if (meterFlag == "1")
{
if (subc.Ismeter == "0")
{
MessageUtil.ShowTips("物料:" + subc .ItemName+ " 为计重物料,请先计量");
return false;
}
}
if (PcFlag == "1")
{
if (String.IsNullOrEmpty(subc.CheckNo))
{
MessageUtil.ShowTips("物料:" + subc.ItemName + " 为检化验物料,请生成检化验委托并做好取样和检验准备");
return false;
}
}
}
//取消初检校验
else if (p == 2)
{
if (testStatus != "2" && testStatus != "3")
{
MessageUtil.ShowTips("送货单行:" + deliverySubId + " 可能还未完成初检或已经(待检)入库,或请刷新界面重试");
return false;
}
}
else
{
MessageUtil.ShowTips("未知参数:" + p);
return false;
}
return true;
}
#endregion
#region 新增检验项处理
private void btn_add_item_Click(object sender, EventArgs e)
{
if (dt_addItem==null||dt_addItem.Rows.Count <= 0)
{
MessageUtil.ShowTips("请选择新增检验项目");
return;
}
if (dt_addItem.Rows.Count > 0)
{
dt_addItem.Columns.Add("remark", typeof(string));
dt_addItem.Columns.Add("judgeType", typeof(string));
}
foreach (DataRow row in dt_addItem.Rows)
{
row["remark"] ="[新增项]"+txt_addItemRemark.Text.ToString();
row["judgeType"] = txt_judgeTypeHY.Value.ToString().Trim();
}
GridHelper.CopyDataToDatatable(dt_addItem, dataTable4, false);
GridHelper.RefreshAndAutoSize(ultraGrid3);
txt_addItemHY.Clear();
txt_addItemRemark.Clear();
dt_addItem.Clear();
}
private void txt_addItemHY_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
WinMatItemsSelect frm = new WinMatItemsSelect(this.ob);
frm.ShowDialog();
dt_addItem = frm.DtSelectItems;
if (dt_addItem == null)
{
return;
}
StringBuilder itemCol = new StringBuilder("");
foreach(DataRow row in dt_addItem.Rows)
{
//row["remark"] ="[新增项]"+txt_addItemRemark.Text.ToString();
String strItemName = row["MATNAME"].ToString();
if (!String.IsNullOrEmpty(strItemName))
{
if (itemCol.Length >=1)
{
itemCol.Append(";").Append(strItemName);
}
else
{
itemCol.Append(strItemName);
}
}
}
txt_addItemHY.Text = itemCol.ToString();
}
private void btn_deleteItem_Click(object sender, EventArgs e)
{
ultraGrid3.UpdateData();
if (ultraGrid3.ActiveRow == null)
{
MessageUtil.ShowTips("请选择检验项目进行删除");
return;
}
UltraGridRow uge=ultraGrid3.ActiveRow;
if (String.IsNullOrEmpty(uge.GetCellValue("flag").ToString().Trim()))
{
uge.Delete();
}
else
{
MessageUtil.ShowTips("非新增项不允许删除");
return;
}
}
#endregion
#region 附件处理
private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
try
{
UltraGridRow row = ultraGrid4.ActiveRow;
string filePathOld = row.GetValue("certPathOld");
if (e.Button.Key.ToLower().Equals("select"))
{
FrmPopFileShow down = new FrmPopFileShow(this.ob, filePathOld);
down.DeleteButton.Visible = false;
down.ShowDialog();
//String path = Environment.CurrentDirectory + "\\Tmp\\" + filePathOld;
// System.Diagnostics.Process.Start(path);
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("操作失败:" + ex);
}
}
private void txt_certPath_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
try
{
if (e.Button.Key.ToLower().Equals("insert"))
{
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = false;
DialogResult drStat;
drStat = file.ShowDialog();
if (drStat == DialogResult.OK)
{
fileName = file.FileName;
string filena = System.IO.Path.GetFileName(fileName);
txt_certPath.Text = filena;
}
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("操作失败:" + ex);
}
}
//上传按钮
private void btn_submitAppend_Click(object sender, EventArgs e)
{
if (ultraGrid2.ActiveRow == null)
{
MessageUtil.ShowTips("未选择送货单行号");
return;
}
UltraGridRow uge = ultraGrid2.ActiveRow;
string strDeliverySubLineSqe = uge.Cells["DELIVERYSUBLINESQE"].Value.ToString();//送货通知单行号
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("送货单号为空");
return;
}
//判断是否可以上传
//if (testStatus(strtaskId, 0) == false)
//{
// return;
//}
String filena = txt_certPath.Text.ToString().Trim();
if (String.IsNullOrEmpty(filena) || String.IsNullOrEmpty(fileName))
{
MessageUtil.ShowTips("请选择待上传文件");
return;
}
OrderAppend sat = new OrderAppend();
sat.OrderId = strDeliverySubLineSqe;
String filePathNew = "Pms/ZBS/" + strDeliverySubLineSqe + "/";
sat.CertPath = filena;
sat.CertPathOld = filePathNew + filena;
sat.CreateUserid = UserInfo.GetUserID();
sat.CreateName = UserInfo.GetUserName();
sat.CreateTime = DateTime.Now;
sat.Validflag = "1";
sat.CertDesc = txt_CERTDESC.Text.Trim();
if (GetCraftFileCraftNoCnt(filena, strDeliverySubLineSqe) > 0)
{
MessageUtil.ShowTips("送货单行已存在该附件文件:" + filena);
return;
}
List list = new List();
FileBean bean = new FileBean();
bean = new FileBean();
bean.setFileName(filena);
bean.setPathName(filePathNew);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
//开始写数据库
CoreResult crt = this.execute("com.hnshituo.pur.order.service.OrderAppendService", "insert_append", new object[] { sat });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("上传失败:" + crt.Resultmsg);
}
else
{
MessageUtil.ShowTips("上传成功");
ClearTab5();
}
}
else
{
MessageBox.Show("上传失败");
}
//刷新界面并激活当前行
Relocate(sat);
}
private void Relocate(OrderAppend sat)
{
getOrderAppend(sat.OrderId, sat.CertPath);
}
private void getOrderAppend(string p1, string p2)
{
dataTable6.Clear();
OrderAppend append = new OrderAppend();
append.OrderId = p1;
append.Validflag = "1";
DataTable dt = this.execute("com.hnshituo.pur.order.service.OrderAppendService", "find", new object[] { append, 0, 0 });
GridHelper.CopyDataToDatatable(dt, dataTable6, true);
GridHelper.RefreshAndAutoSize(ultraGrid4);
if (!String.IsNullOrEmpty(p2))
{
ConfigureClassCommon.doActiveSelRow(ultraGrid4, "CERTPATH", p2);
}
}
///
/// 判断是否之前已提交相同的文件
///
///
///
private int GetCraftFileCraftNoCnt(string CERT_PATH, string orderId)
{
OrderAppend sat = new OrderAppend();
sat.CertPath = CERT_PATH;
sat.OrderId = orderId;
sat.Validflag = "1";
int dt = this.execute("com.hnshituo.pur.order.service.OrderAppendService", "count", new object[] { sat });
return dt;
}
///
/// 清空文件上传编辑区
///
private void ClearTab5()
{
txt_certPath.Clear();
txt_CERTDESC.Clear();
fileName = "";
}
///
/// 删除文件
///
///
///
private void btn_deleteAppend_Click(object sender, EventArgs e)
{
UltraGridRow uge = ultraGrid2.ActiveRow;
if (uge == null)
{
MessageUtil.ShowTips("请选择送货单行!");
return;
}
string strDeliverySubLineSqe = uge.Cells["DELIVERYSUBLINESQE"].Value.ToString();//送货通知单行号
if (String.IsNullOrEmpty(strDeliverySubLineSqe))
{
MessageUtil.ShowTips("该送货单行编号为空!");
return;
}
UltraGridRow rowAppend = ultraGrid4.ActiveRow;
if (rowAppend == null)
{
MessageUtil.ShowTips("请选择需删除的附件!");
return;
}
String strAppendID = rowAppend.Cells["ID"].Value.ToString().Trim();
String strcertPath = rowAppend.Cells["CERTPATH"].Value.ToString().Trim();
String strCertPathOld = rowAppend.Cells["CERTPATHOLD"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strAppendID))
{
MessageUtil.ShowTips("该送货单行附件编号为空!");
return;
}
if (String.IsNullOrEmpty(strCertPathOld))
{
MessageUtil.ShowTips("未获取到送货单行附件地址信息!");
return;
}
//验证送货单是否可以增删改
if (testOrderAppendStatus(strAppendID, 1) == false)
{
return;
}
OrderAppend append = new OrderAppend();
append.Id = strAppendID;
append.Validflag = "0";
append.DeleteName = UserInfo.GetUserName();
append.DeleteTime = DateTime.Now;
append.DeleteUserid = UserInfo.GetUserID();
if (MessageUtil.ShowYesNoAndQuestion("确定删除附件:" + strcertPath + "?") != DialogResult.Yes)
{
return;
}
CoreResult crt = this.execute("com.hnshituo.pur.order.service.OrderAppendService", "delete_append", new object[] { append });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("删除失败!" + crt.Resultmsg);
return;
}
else
{
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Delete(strCertPathOld);
if (isSuccess)
{
MessageUtil.ShowTips("删除成功");
}
else
{
MessageBox.Show("删除成功");
}
}
getOrderAppend(strDeliverySubLineSqe, "");
}
///
/// 验证合同条款输入数据的有效性
///
///
private bool testOrderAppendStatus(String strId, int p)// 验证合同附件
{
OrderAppend append = this.execute("com.hnshituo.pur.order.service.OrderAppendService", "findById", new object[] { strId });
if (append == null)
{
MessageUtil.ShowTips("未发现附件:" + strId + "信息记录,可能已作废");
return false;
}
if (append.Validflag != "1")
{
MessageUtil.ShowTips("附件:" + strId + "信息记录可能已作废");
return false;
}
if (append.CreateUserid != UserInfo.GetUserID())
{
MessageUtil.ShowTips("非本人上传附件无权限进行增删改");
return false;
}
if (p == 1)
{
}
else
{
MessageUtil.ShowTips("未知参数:" + p + "");
return false;
}
return true;
}
#endregion
}
}