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 Core.Mes.Client.Comm;
using Pur.Entity.configureEntity;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using Pur.Entity.pur_orderEntiy;
using Pur.configure;
using Pur.Pop_upWindow;
using Pur.require_plan;
using Core.Mes.Client.Comm.Tool;
using com.hnshituo.pur.vo;
using Pur.Entity.ck;
using Infragistics.Win;
using Core.Mes.Client.Comm.Server;
using Pur.PublicTools;
namespace Pur.ck
{
public partial class FrmCkInBillManager : FrmPmsBase
{
bool b = false;//是否进行,是否点击查询按钮
DataTable _dt_GropByItem = null;
public FrmCkInBillManager()
{
InitializeComponent();
}
//菜单按钮事件
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
GetCkInBill();
break;
case "UltraGridToExcel"://导出入库单
UltraGridToExcel();
break;
case "printCkInBill"://打印预览
printCkInBillSinger("0");
break;
case "printCkInBill_cf"://重复打印预览
printCkInBillSinger("1");
break;
case "cancelPrint"://取消打印
cancelPrint();
break;
case "printCkInBillCollet"://打印汇总预览
printCkInBill("0");
break;
case "printCkInBillCollet_cf"://重复打印汇总预览
printCkInBill("1");
break;
}
}
///
/// 查询
///
private void GetCkInBill()
{
if (b)
{
dataTable3.Rows.Clear();
PurCkInBillEntity pcibEntity = getQueryCondition();
if (!create_time_label.Checked && String.IsNullOrEmpty(pcibEntity.SuppCode) && String.IsNullOrEmpty(pcibEntity.ItemCode) && String.IsNullOrEmpty(pcibEntity.OrderId)
&& String.IsNullOrEmpty(pcibEntity.InvPhysic) && String.IsNullOrEmpty(pcibEntity.RefeId) && String.IsNullOrEmpty(pcibEntity.ItemName))
{
MessageUtil.ShowTips("请添加查询条件或勾选创建时间,进行查询");
return;
}
if (!create_time_label.Checked)
{
pcibEntity.CreateTime = null;
pcibEntity.UpdateTime = null;
}
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill", new object[] { pcibEntity });
GridHelper.CopyDataToDatatable(dt, dataTable5, true);
GridHelper.RefreshAndAutoSize(ultraGrid4);
}
}
private DateTime setCreateTimeStart(Object value)
{
DateTime time = Convert.ToDateTime(value);
DateTime endtime = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
return endtime;
}
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;
}
private PurCkInBillEntity getQueryCondition()
{
PurCkInBillEntity pcibEntity = new PurCkInBillEntity();
if (txt_CreateTimeStart.Value != null)//创建开始时间
{
//pcibEntity.CreateTime = ((DateTime)txt_CreateTimeStart.Value);//.AddDays(-1);
pcibEntity.CreateTime = setCreateTimeStart(txt_CreateTimeStart.Value);
}
else
{
//pcibEntity.CreateTime = DateTime.MinValue;
}
if (txt_CreateTimeEnd.Value != null)//创建结束时间
{
//pcibEntity.UpdateTime = (DateTime)txt_CreateTimeEnd.Value;
pcibEntity.UpdateTime = setCreateTimeEnd(txt_CreateTimeEnd.Value);
//pcibEntity.UpdateTime = pcibEntity.UpdateTime.Value.AddDays(1);
}
else
{
//pcibEntity.UpdateTime = DateTime.MaxValue;
}
pcibEntity.SuppCode = txt_SuppName.Value == null ? null : txt_SuppName.Value.ToString();
pcibEntity.ItemCode = txt_ItemName.Value == null ? null : txt_ItemName.Value.ToString();
pcibEntity.OrderId = txt_OrderId.Value == null ? null : txt_OrderId.Value.ToString();
pcibEntity.InvPhysic = txt_InvPhysic.Value == null ? null : txt_InvPhysic.Value.ToString();
pcibEntity.RefeId = txt_DELIVERY_ID.Text.Trim();
//if (txt_ITEMCODE.Text!="全部")
//{
//if (txt_ITEMCODE.Value != null && txt_ITEMCODE.Value.ToString() == "")
//{
pcibEntity.ItemName = txt_ITEMCODE.Text;// == null ? null : txt_ITEMCODE.Value.ToString();;
//}
// }
return pcibEntity;
}
///
/// 绑定查询条件的下拉列表
///
private void getBindCmbInGrid()
{
PurCkInBillEntity pcibEntity = getQueryCondition();
pcibEntity.UpdateTime = null;
pcibEntity.CreateTime = null;
pcibEntity.ItemCode = null;
pcibEntity.SuppCode = null;
pcibEntity.OrderId = null;
pcibEntity.ItemName = null;
DataTable dt_GropBySupp = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropBySupp", new object[] { pcibEntity });
DataTable dt_GropByItem = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { pcibEntity });
//DataTable dt_GropByOrder = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByOrder", new object[] { pcibEntity });
string strSuppName = txt_SuppName.Value == null ? "" : txt_SuppName.Value.ToString();
string strItemName = txt_ItemName.Value == null ? "" : txt_ItemName.Value.ToString();
string strOrderId = txt_OrderId.Value == null ? "" : txt_OrderId.Value.ToString();
_dt_GropByItem = dt_GropByItem;
//ValueListItem vli= txt_SuppName.SelectedItem;
//ValueList vl = txt_SuppName.ValueList;
//comm.FilComboboxAdd(txt_SuppName, dt_GropBySupp,"SUPPCODE", "SUPPNAME", "", true, "", "");
//comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "ItemCODE", "ItemNAME", "", true, "", "");
comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "basecode", "basename", "", true, "全部", "");
//comm.FilComboboxAdd(txt_OrderId, dt_GropByOrder, "ORDERID", "ORDERID", "", true, "", "");
comm.FilComboboxAdd(txt_SuppName, dt_GropBySupp, "SUPPCODE", "SUPPNAME", "", true, "全部", "");
// comm.setUltraComboEditorBind(txt_SuppName, dt_GropBySupp, "SUPPNAME", "SUPPCODE","全部","");
//if (txt_ItemName.Items.Count==0)
//{
// comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "basecode", "basename", "", true, "", "");
// foreach (ValueListItem vli in txt_ItemName.Items)
// {
// if (vli.DataValue.ToString() == strItemName)
// {
// txt_ItemName.Value = strItemName;
// break;
// }
// }
//}
//if (txt_ItemName.Items.Count == 0)
//{
// comm.setUltraComboEditorBind(txt_OrderId, dt_GropByOrder, "ORDERID", "ORDERID", "", "");
// foreach (ValueListItem vli in txt_OrderId.Items)
// {
// if (vli.DataValue.ToString() == strOrderId)
// {
// txt_OrderId.Value = strOrderId;
// break;
// }
// }
//}
//foreach (ValueListItem vli in txt_SuppName.Items)
//{
// if (vli.DataValue.ToString() == strSuppName)
// {
// //txt_SuppName.Value = strSuppName;
// txt_SuppName.SelectedItem = vli;
// break;
// }
//}
}
///
/// 界面加载
///
///
///
private void FrmCkInBillManager_Load(object sender, EventArgs e)
{
txt_CreateTimeStart.Value = DateTime.Now.AddMonths(-1);
txt_CreateTimeEnd.Value = DateTime.Now.AddDays(1);
getBindCmbInGrid();
b = true;
}
///
/// 激活入库单行
///
///
///
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow uge = ultraGrid4.ActiveRow;
PurCkInbillPositionEntity CkInbillPositionEntity = new PurCkInbillPositionEntity();
CkInbillPositionEntity.InStockNo = uge.Cells["InStockNo"].Value.ToString();
DataTable dtCkInbillPositio = this.execute("com.hnshituo.pur.ck.service.CkInbillPositionService", "getBillPosition", new object[] { CkInbillPositionEntity });
GridHelper.CopyDataToDatatable(dtCkInbillPositio, dataTable3, true);
GridHelper.RefreshAndAutoSize(ultraGrid2);
}
///
/// 导出Excel
///
private void UltraGridToExcel()
{
try
{
//获取导出的采购计划行表
ArrayList alUltraGrid = new ArrayList();
alUltraGrid.Add(ultraGrid4);
ArrayList alSheeft = new ArrayList();
alSheeft.Add("入库单");
if (ultraGrid4.Rows.Count > 0)
{
GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "入库单.xls");//导出excel
}
else
{
MessageUtil.ShowTips("无可导出项");
return;
}
//MessageUtil.ShowTips("导出成功");
}
catch (Exception e)
{
MessageUtil.ShowTips("导出失败" + e.Message);
}
}
///
/// 单张打印
///
private void printCkInBillSinger(String strTips)
{
UltraGridRow ugr = ultraGrid4.ActiveRow;
if (ugr == null)
{
MessageUtil.ShowTips("未找到要打印的入库单");
return;
}
if(ugr.Cells["status"].Value.ToString()=="待检")
{
MessageUtil.ShowTips("状态为“待检”的入库单不能打印!");
return;
}
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 strUrlPort = "http://localhost:8075";//报表系统IP
String[] str = strUrlPort.Split(':');
String strUrl = str[0] + ":" + str[1];
string strIn_stock_no = ugr.Cells["Instockno"].Value.ToString().Trim();
string itemName = ugr.Cells["itemname"].Value.ToString().Trim();
if (String.IsNullOrEmpty(strIn_stock_no))
{
MessageUtil.ShowTips("入库单号为空");
return;
}
PurCkInBillEntity CkInbill = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "findById", new object[] { strIn_stock_no });
if (CkInbill == null)
{
MessageUtil.ShowTips("未发现入库单:" + strIn_stock_no + "信息记录");
return;
}
string strPrintNo = CkInbill.PrintCode;
if (!String.IsNullOrEmpty(strPrintNo) && strTips == "0")
{
MessageUtil.ShowTips("入库单:" + strIn_stock_no + "已打印,或请先取消打印或选择重复打印功能");
return;
}
//获取打印编号
if (strTips == "0")
{
PurPrintNoEntity ppn = new PurPrintNoEntity();
ppn.Remark = "入库单打印";
ppn.PrintType = "1";
ppn.CreateName = UserInfo.GetUserName();
ppn.CreateUserid = UserInfo.GetUserID();
CoreResult core = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "getPrintNo", new object[] { ppn });
if (core.Resultcode == 0)
{
strPrintNo = core.Resultmsg;
}
else
{
MessageUtil.ShowTips(core.Resultmsg);
}
}
if (itemName.ToString().Equals("国内废钢"))
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBillFg.cpt&op=view" + "&printNo=" + strPrintNo + "&in_stock_no='" + strIn_stock_no + "'&ID=" + 1232024;
}
else
{
//打印操作
if (TipsEnv == "2")//测试环境
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_test.cpt&op=view" + "&printNo=" + strPrintNo + "&in_stock_no=" + strIn_stock_no;
}
else
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill.cpt&op=view" + "&printNo=" + strPrintNo + "&in_stock_no=" + strIn_stock_no + "&ID=" + 1232024;
}
}
//strUrl = "http://localhost:8075/webroot/decision/view/report?viewlet=rpt_CkInBill.cpt&op=view" + "&in_stock_no="+ "&printNo=" + strPrintNo + strIn_stock_no;
comm.printReport(this.ob, strUrl, "入库单打印");
if (strTips== "0")
{
if (MessageUtil.ShowYesNoAndQuestion("是否已打印入库单?").Equals(DialogResult.Yes))
{
ArrayList al = new ArrayList();
PurCkInBillEntity pcibEntity = new PurCkInBillEntity();
pcibEntity.InStockNo = strIn_stock_no;
pcibEntity.PrintCode = strPrintNo;
al.Add(pcibEntity);
CoreResult rt = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "isPrint", new object[] { al });
if (rt.Resultcode != 0)
{
MessageUtil.ShowTips("标记打印失败:" + rt.Resultmsg);
}
ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0);
}
}
}
///
/// 取消打印
///
private void cancelPrint()
{
//获取需要取消的打印的入库单编号
ultraGrid4.UpdateData();
IQueryable checkRows = ultraGrid4.Rows.AsQueryable().Where("Check = 'True' ");
if (checkRows.Count() == 0)
{
MessageUtil.ShowTips("请勾选要取消打印的入库单");
return;
}
ArrayList list = new ArrayList();
StringBuilder bu = new StringBuilder();
foreach (UltraGridRow ugr in checkRows)
{
string Instockno = ugr.Cells["Instockno"].Value.ToString().Trim();
string printCode = ugr.Cells["printcode"].Value.ToString().Trim();
if (String.IsNullOrEmpty(Instockno))
{
MessageUtil.ShowTips("入库单号不能为空");
ugr.Activate();
}
if(!String.IsNullOrEmpty(printCode))
{
string userId = "";
DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQueryPrint", new Object[] { printCode }, this.ob);
if (dt.Rows.Count > 0)
{
userId = dt.Rows[0]["CREATE_USERID"].ToString();
}
if(!UserInfo.GetUserID().Equals(userId))
{
MessageUtil.ShowTips("不是该账号打印无法取消!");
return;
}
}
PurCkInBillEntity inbill=new PurCkInBillEntity();
inbill.InStockNo=Instockno;
inbill.CreateName=UserInfo.GetUserName();
inbill.CreateUserid=UserInfo.GetUserID();
list.Add(inbill);
bu.Append(Instockno + ",");
}
if (list.Count <= 0)
{
MessageUtil.ShowTips("请勾选要取消打印的入库单");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确定取消打印入库单:" + bu.ToString() + "? 若为汇总打印,将同步取消关联入库单打印记录。") != DialogResult.Yes)
{
return;
}
CoreResult core = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "cancelPrintNo", new object[] { list });
if (core.Resultcode != 0)
{
MessageUtil.ShowTips("取消打印失败:" + core.Resultmsg);
return;
}
else
{
MessageUtil.ShowTips("取消打印成功");
GetCkInBill();
}
}
///
/// 汇总打印入库单
///
private void printCkInBill(String strTips)
{
//获取要打印的入库单编号
ultraGrid4.UpdateData();
string strIn_stock_no_s = "";
IQueryable checkRows = ultraGrid4.Rows.AsQueryable().Where("Check = 'True' ");
if (checkRows.Count() <= 0)
{
MessageUtil.ShowTips("请勾选要打印的入库单");
return;
}else if(checkRows.Count()>140)
{
MessageUtil.ShowTips("勾选的合同不能超过140!");
return;
}
ArrayList list1=new ArrayList();
ArrayList al = new ArrayList();
string n = "";
string itemName = "";
foreach (UltraGridRow ugr in checkRows)
{
string Instockno = ugr.Cells["Instockno"].Value.ToString();
itemName = ugr.Cells["itemname"].Value.ToString();
if (String.IsNullOrEmpty(Instockno))
{
MessageUtil.ShowTips("入库单号为空");
return;
}
PurCkInBillEntity CkInbill = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "findById", new object[] { Instockno });
if (CkInbill == null)
{
MessageUtil.ShowTips("未发现入库单:" + Instockno + "信息记录");
return;
}
if (!String.IsNullOrEmpty(CkInbill.PrintCode) && strTips == "0")
{
MessageUtil.ShowTips("入库单:" + Instockno + "已打印,或请先取消打印");
ugr.Activate();
return;
}
if (String.IsNullOrEmpty(CkInbill.PrintCode) && strTips == "1")
{
MessageUtil.ShowTips("入库单:" + Instockno + "还未打印,或请先打印");
ugr.Activate();
return;
}
if (n != CkInbill.PrintCode)
{
list1.Add(CkInbill.PrintCode);
}
n = CkInbill.PrintCode;
strIn_stock_no_s += "'" + Instockno + "',";
if (ugr.Cells["status"].Value.ToString() == "待检")
{
MessageUtil.ShowTips("状态为“待检”的入库单不能打印!");
return;
}
PurCkInBillEntity pcibEntity = new PurCkInBillEntity();
pcibEntity.InStockNo = Instockno;
al.Add(pcibEntity);
}
strIn_stock_no_s = strIn_stock_no_s.Substring(0, strIn_stock_no_s.Length - 1);
//string strSuppCode = txt_SuppName.Value == null ? "" : txt_SuppName.Value.ToString();//供应商
//string strItemCode = txt_ItemName.Value == null ? "" : txt_ItemName.Value.ToString();//物料分类
//string strItemCodeCode = txt_ITEMCODE.Value == null ? "" : txt_ITEMCODE.Value.ToString();//物料名称
//string strInvPhysic = txt_InvPhysic.Value == null ? "" : txt_InvPhysic.Value.ToString();//库区
////string strSuppCode = txt_SuppName.Text;
////string strItemCode = txt_ItemName.Text;
//string strOrderId = txt_OrderId.Value == null ? "" : txt_OrderId.Value.ToString();
//string strStart = ((DateTime)txt_CreateTimeStart.Value).ToString("yyyy-MM-dd");
//string strEnd = ((DateTime)txt_CreateTimeEnd.Value).ToString("yyyy-MM-dd");
//if (string.IsNullOrEmpty(strSuppCode) || string.IsNullOrEmpty(strItemCode) || string.IsNullOrEmpty(strOrderId) || string.IsNullOrEmpty(strStart))
//{
// MessageUtil.ShowTips("供应商、物料名称、合同、创建时间必须从下拉列表中选择,否则不能打印");
// return;
//}
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];
//获取打印编号
string strPrintNo = "";
if (strTips == "0")
{
PurPrintNoEntity ppn = new PurPrintNoEntity();
ppn.Remark = "入库单打印";
ppn.PrintType = "1";
ppn.CreateName = UserInfo.GetUserName();
ppn.CreateUserid = UserInfo.GetUserID();
CoreResult core = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "getPrintNo", new object[] { ppn });
if (core.Resultcode == 0)
{
strPrintNo = core.Resultmsg;
}
else
{
MessageUtil.ShowTips(core.Resultmsg);
}
}
else
{
strPrintNo = publicPms.ArrayListToString(list1);
}
if (itemName.ToString().Equals("国内废钢"))
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBillFg.cpt&op=view" + "&printNo=" + strPrintNo + "&in_stock_no=" + strIn_stock_no_s + "&ID=" + 1232024;
//strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_PrintFg.cpt" + "&printNo=" + strPrintNo + "&in_stock_no_s=" + strIn_stock_no_s + "&ID=" + 1232024;
}
else
{
if (TipsEnv == "2")//测试环境
{
//strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_Print_test.cpt" + "&printNo=" + strPrintNo + "&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&create_time_start=" + strStart + "&create_time_end=" + strEnd + "&inv_physic=" + strInvPhysic + "&order_id=" + strOrderId + "&item_code_code=" + strItemCodeCode;
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_Print_test.cpt" + "&printNo=" + strPrintNo + "&in_stock_no_s=" + strIn_stock_no_s;
}
else
{
//strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_Print.cpt" + "&printNo=" + strPrintNo + "&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&create_time_start=" + strStart + "&create_time_end=" + strEnd + "&inv_physic=" + strInvPhysic + "&order_id=" + strOrderId + "&item_code_code=" + strItemCodeCode;
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBill_Print.cpt" + "&printNo=" + strPrintNo + "&in_stock_no_s=" + strIn_stock_no_s + "&ID=" + 1232024;
}
}
//strUrl = "http://localhost:8075/webroot/decision/view/report?viewlet=rpt_CkInBill_Print.cpt&op=view" + "&printNo=" + strPrintNo + "&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&create_time_start=" + strStart + "&create_time_end=" + strEnd + "&inv_physic=" + strInvPhysic + "&order_id=" + strOrderId;
//http://localhost:8075/webroot/decision/view/report?viewlet=rpt_CkInBill_Print.cpt&printNo=20160900019&supp_code=W05AXQSHGS&item_code=W04&create_time_start=2016-08-11&create_time_end=2016-09-12&inv_physic=&order_id=4640366&item_code_code=W00403044500010
comm.printReport(this.ob, strUrl,"入库单汇总打印");
if (strTips == "0")
{
if (MessageUtil.ShowYesNoAndQuestion("是否已打印入库单?").Equals(DialogResult.Yes))
{
foreach (PurCkInBillEntity pcibEntity1 in al)
{
pcibEntity1.PrintCode = strPrintNo;
}
CoreResult rt = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "isPrint", new object[] { al });
if (rt.Resultcode != 0)
{
MessageUtil.ShowTips("标记打印失败:" + rt.Resultmsg);
}
GetCkInBill();
}
}
}
///
/// 打印入库单汇总,方法弃用
///
private void printCkInBillCollet()
{
string strSuppCode = txt_SuppName.Value==null?"":txt_SuppName.Value.ToString();
string strItemCode = txt_ItemName.Value == null ? "" : txt_ItemName.Value.ToString();
//string strSuppCode = txt_SuppName.Text;
//string strItemCode = txt_ItemName.Text;
string strOrderId = txt_OrderId.Value==null?"":txt_OrderId.Value.ToString();
string strStart = ((DateTime)txt_CreateTimeStart.Value).ToString("yyyy-MM-dd");
string strEnd = ((DateTime)txt_CreateTimeEnd.Value).ToString("yyyy-MM-dd");
if (string.IsNullOrEmpty(strSuppCode) || string.IsNullOrEmpty(strItemCode) || string.IsNullOrEmpty(strOrderId) || string.IsNullOrEmpty(strStart) || string.IsNullOrEmpty(strEnd))
{
MessageUtil.ShowTips("供应商、合同号、物料名称、开始时间和结束时间必须从下拉列表中选择,否则不能汇总打印");
return;
}
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 (TipsEnv == "2")//测试环境
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBillCollect_test.cpt&op=view" + "&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&order_id=" + strOrderId + "&create_time_start=" + strStart + "&create_time_end=" + strEnd;
}
else
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_CkInBillCollect_test.cpt&op=view" + "&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&order_id=" + strOrderId + "&create_time_start=" + strStart + "&create_time_end=" + strEnd;
}
strUrl = "http://localhost:8075/webroot/decision/view/report?viewlet=rpt_CkInBillCollect.cpt&supp_code=" + strSuppCode + "&item_code=" + strItemCode + "&order_id=" + strOrderId + "&create_time_start=" + strStart + "&create_time_end=" + strEnd;
comm.printReport(this.ob, strUrl,"入库单汇总打印");
}
private void txt_OrderId_ValueChanged(object sender, EventArgs e)
{
//txt_ItemName.Text = null;
//PurCkInBillEntity CkInBillEntity = getQueryCondition();
//DataTable dt_GropByItem = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
//comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "ItemCODE", "ItemNAME", "", true, "", "");
}
///
/// 选择物料时,加载库区
///
///
///
private void txt_ItemName_ValueChanged(object sender, EventArgs e)
{
}
private void txt_SuppName_SelectionChanged(object sender, EventArgs e)
{
//b = true;
//GetCkInBill();
//if (b)
// { return; }
string strSuppName = txt_SuppName.Value == null ? "" : txt_SuppName.Value.ToString();
string strItemName = txt_ItemName.Value == null ? "" : txt_ItemName.Value.ToString();
string strOrderId = txt_OrderId.Value == null ? "" : txt_OrderId.Value.ToString();
txt_OrderId.Value = null;
txt_ItemName.Value = null;
txt_ITEMCODE.Value = null;
//txt_OrderId.Value = "";
//txt_ItemName.Value = "";
//txt_ITEMCODE.Value = "";
PurCkInBillEntity CkInBillEntity = getQueryCondition();
CkInBillEntity.UpdateTime = null;
CkInBillEntity.CreateTime = null;
CkInBillEntity.OrderId = null;
CkInBillEntity.ItemCode = null;
CkInBillEntity.ItemName = null;
//DataTable dt_GropByOrder = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByOrder", new object[] { CkInBillEntity });
//DataTable dt_GropByItem = comm.getDtGroupBy_reDt(dataTable5, "basecode");
////DataTable dt_GropByItem = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
//DataTable dt_GropByInvPhisc = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByInvPhisc", new object[] { CkInBillEntity });
//comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "basecode", "basename", "", true, "", "");
//comm.FilComboboxAdd(txt_OrderId, dt_GropByOrder, "ORDERID", "ORDERID", "", true, "", "");
//comm.FilComboboxAdd(txt_InvPhysic, dt_GropByInvPhisc, "invPhysic", "ItemNAME", "", true, "", "");
DataTable dt_GropByItem = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "basecode", "basename", "", true, "全部", "");
foreach (ValueListItem vli in txt_ItemName.Items)
{
if (vli.DataValue.ToString() == strItemName)
{
txt_ItemName.Value = strItemName;
break;
}
}
//GetCkInBill();
}
///
/// 选择物料
///
///
///
private void txt_ItemName_SelectionChanged(object sender, EventArgs e)
{
string strSuppName = txt_SuppName.Value == null ? "" : txt_SuppName.Value.ToString();
string strItemName = txt_ItemName.Value == null ? "" : txt_ItemName.Value.ToString();
string strOrderId = txt_OrderId.Value == null ? "" : txt_OrderId.Value.ToString();
string strItemCode = txt_ITEMCODE.Value == null ? "" : txt_ITEMCODE.Value.ToString();
txt_OrderId.Value = null;
txt_ITEMCODE.Value = null;
//txt_OrderId.Value = "";
//txt_ITEMCODE.Value = "";
PurCkInBillEntity CkInBillEntity = getQueryCondition();
CkInBillEntity.UpdateTime = null;
CkInBillEntity.CreateTime = null;
CkInBillEntity.OrderId = null;
CkInBillEntity.ItemName = null;
//CkInBillEntity.ItemCode = null;
//txt_InvPhysic.Value = null;
//DataTable dt_GropByInvPhisc = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByInvPhisc", new object[] { CkInBillEntity });
//comm.FilComboboxAdd(txt_InvPhysic, dt_GropByInvPhisc, "invPhysic", "ItemNAME", "", true, "", "");
// GetCkInBill();
//查询合同
DataTable dt_GropByOrder = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByOrder", new object[] { CkInBillEntity });
comm.setUltraComboEditorBind(txt_OrderId, dt_GropByOrder, "ORDERID", "ORDERID", "全部", "");
foreach (ValueListItem vli in txt_OrderId.Items)
{
if (vli.DataValue.ToString() == strOrderId)
{
txt_OrderId.Value = strOrderId;
break;
}
}
//GetCkInBill();
}
private void txt_InvPhysic_SelectionChanged(object sender, EventArgs e)
{
//GetCkInBill();
}
private void txt_OrderId_SelectionChanged(object sender, EventArgs e)
{
string strItemCode = txt_ITEMCODE.Value == null ? "" : txt_ITEMCODE.Value.ToString();
//查询物料
//txt_OrderId.Text = null;
txt_ITEMCODE.Value = null;
//txt_ITEMCODE.Value = "";
PurCkInBillEntity CkInBillEntity = getQueryCondition();
CkInBillEntity.UpdateTime = null;
CkInBillEntity.CreateTime = null;
CkInBillEntity.ItemName = null;
DataTable dt_GropByItemName = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItemName", new object[] { CkInBillEntity });
//comm.setUltraComboEditorBind(txt_ITEMCODE, dt_GropByItemName, "ItemName", "ItemCode", "全部", "");
comm.FilComboboxAdd(txt_ITEMCODE, dt_GropByItemName, "ItemCode", "ItemName", "", true, "", "");
foreach (ValueListItem vli in txt_ITEMCODE.Items)
{
if (vli.DataValue.ToString() == strItemCode)
{
txt_ITEMCODE.Value = strItemCode;
break;
}
}
GetCkInBill();
}
private void txt_ITEMCODE_SelectionChanged(object sender, EventArgs e)
{
}
///
/// 导入入库单到库存
///
private void ExportCkToStorage()
{
ArrayList al_CkStorageEntity = new ArrayList();//库存
ArrayList al_CkStoragePosEntity = new ArrayList();
//DataTable dt = null;
//foreach (DataRow dr in dataTable5.Rows)
//{
//CkStorage CkStorageEntity = new CkStorage();
//PurCkStoragePosEntity CkStoragePosEntity = new PurCkStoragePosEntity();//库存收发存表
////-----------------------------------------------------------------------------库存单表
//PurCkInBillEntity ck = new PurCkInBillEntity();
//ck = this.GetJsonService().execute("com.hnshituo.pur.ck.service.CkInBillService", "findById", new object[] { dr["InStockNo"].ToString() });
//CkStorageEntity = EntityHelper.CopyEntity(ck);//复制发货通知单行号中相同的字段值
////CkStorageEntity = EntityHelper.CopyEntity(CkInBillEntity);//复制合同行号中相同的字段值
////CkStorageEntity.RefType = "2";//1.送货单,2.收货单
//CkStorageEntity.InvId = ck.InStockNo.Replace("RK", "CK");
//CkStorageEntity.Validflag = "1";
//CkStorageEntity.InvQty = ck.InNum;//库存数量
//CkStorageEntity.InvOrigQty = ck.InNum;//期初库存数量
//al_CkStorageEntity.Add(CkStorageEntity);
////---------------------------------------------------------------------------------------------------------------------------------库存储位明细表
//PurCkInbillPositionEntity CkInbillPositionEntity = new PurCkInbillPositionEntity();//入库单储位明细表
//CkInbillPositionEntity.InStockNo = ck.InStockNo;
//DataTable dtp = this.GetJsonService().execute("com.hnshituo.pur.ck.service.CkInbillPositionService", "find", new object[] { CkInbillPositionEntity, 0, 0 });
//for (int i = 0; i < dtp.Rows.Count; i++)
//{
// CkStoragePosEntity.InvId = CkStorageEntity.InvId;//库存记录号记录发货通知单行号,方便在后台获取入库单号
// CkStoragePosEntity.InvPosId = CkStorageEntity.InvId + "00" + i;
// CkStoragePosEntity.Validflag = "1";
// double bINNUM = 0;
// double.TryParse(dtp.Rows[i]["INNUM"].ToString(), out bINNUM);
// CkStoragePosEntity.InvOrigQty = bINNUM;//期初入库量
// CkStoragePosEntity.InvQty = bINNUM;//库存数量
// CkStoragePosEntity.InvPhysic = CkStorageEntity.InvPhysic;
// CkStoragePosEntity.InvPos = dtp.Rows[i]["InvPos"].ToString();//ugr_5.Cells["INVPOS"].Value.ToString();//库位
// CkStoragePosEntity.PackageQty = dtp.Rows[i]["PackageQty"].ToString();//包装数量
// //CkStoragePosEntity.PackageUnit = dtp.Rows[i]["PackageUnit"].ToString();//包装单位
// al_CkStoragePosEntity.Add(CkStoragePosEntity);//添加库存单储位明细表
//}
//}
ArrayList al= comm.getDtGroupBy_reAl(dataTable5, "InStockNo");
CoreResult crt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.CkInBillService", "ExportCkToStorage", new object[] { al });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("导入失败 " + crt.Resultmsg);
return;
}
MessageUtil.ShowTips("导入成功");//,入库单号:" + crt.Resultmsg);
}
private void ultraButton1_Click(object sender, EventArgs e)
{
//ExportCkToStorage();
ExportCkToCkOut();
}
///
/// 导入入库单到库存
///
private void ExportCkToCkOut()
{
ArrayList al = comm.getDtGroupBy_reAl(dataTable5, "InStockNo");
CoreResult crt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.CkInBillService", "ExportCkToCkOut", new object[] { al });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("导入失败 " + crt.Resultmsg);
return;
}
MessageUtil.ShowTips("导入成功 " + crt.Resultmsg);//,入库单号:" + crt.Resultmsg);
}
private void ultraGroupBox1_Click(object sender, EventArgs e)
{
}
private void ultraGrid4_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
}
private void ultraButton2_Click(object sender, EventArgs e)
{
ExportCkToCkOut();
}
private void ultraGrid4_InitializeRow(object sender, InitializeRowEventArgs e)
{
UltraGridRow ugr = e.Row;
if (!String.IsNullOrEmpty(ugr.Cells["printcode"].Value.ToString().Trim()))
{
ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0);
}
else
{
ugr.CellAppearance.ForeColor = Color.Black;
}
//标记待检状态入库单
if (ugr.Cells["status"].Value.ToString() == "待检")
{
ugr.Cells["status"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
}
else
{
ugr.Cells["status"].Appearance.ForeColor = Color.Black;
}
}
private void ultraGrid4_CellChange(object sender, CellEventArgs e)
{
ultraGrid4.UpdateData();
String suppname = "";
String orderLineSqe = "";
String basename = "";
int i = 0;
if (e.Cell.Column.Key == "Check")
{
foreach (UltraGridRow row in ultraGrid4.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("Check")) == true)
{
String strSuppname = row.Cells["suppname"].Value.ToString();
String strOrderLineSqe = row.Cells["orderid"].Value.ToString();
String strBasename = row.Cells["basename"].Value.ToString();
if (i == 0)
{
suppname = strSuppname;
orderLineSqe = strOrderLineSqe;
basename = strBasename;
}
else
{
if (suppname != strSuppname)
{
MessageUtil.ShowTips("请选择同供应商下入库单进行操作!");
e.Cell.Row.Cells["Check"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("Check"));
return;
}
if (orderLineSqe != strOrderLineSqe)
{
MessageUtil.ShowTips("请选择同合同下入库单进行操作!");
e.Cell.Row.Cells["Check"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("Check"));
return;
}
if (basename != strBasename)
{
MessageUtil.ShowTips("请选择同物料类别下入库单进行操作!");
e.Cell.Row.Cells["Check"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("Check"));
return;
}
}
i = i + 1;
}
}
}
}
}
}