| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947 |
- 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;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- 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<DataTable>("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;
- }
- /// <summary>
- /// 绑定查询条件的下拉列表
- /// </summary>
- 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<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropBySupp", new object[] { pcibEntity });
- DataTable dt_GropByItem = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { pcibEntity });
- //DataTable dt_GropByOrder = this.execute<DataTable>("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;
- // }
- //}
-
-
- }
- /// <summary>
- /// 界面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- /// <summary>
- /// 激活入库单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<DataTable>("com.hnshituo.pur.ck.service.CkInbillPositionService", "getBillPosition", new object[] { CkInbillPositionEntity });
- GridHelper.CopyDataToDatatable(dtCkInbillPositio, dataTable3, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
-
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 单张打印
- /// </summary>
- 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<PurCkInBillEntity>("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<CoreResult>("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<CoreResult>("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);
- }
- }
- }
- /// <summary>
- /// 取消打印
- /// </summary>
- private void cancelPrint()
- {
- //获取需要取消的打印的入库单编号
- ultraGrid4.UpdateData();
- IQueryable<UltraGridRow> 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<CoreResult>("com.hnshituo.pur.ck.service.CkInBillService", "cancelPrintNo", new object[] { list });
- if (core.Resultcode != 0)
- {
- MessageUtil.ShowTips("取消打印失败:" + core.Resultmsg);
- return;
- }
- else
- {
- MessageUtil.ShowTips("取消打印成功");
- GetCkInBill();
- }
- }
- /// <summary>
- /// 汇总打印入库单
- /// </summary>
- private void printCkInBill(String strTips)
- {
- //获取要打印的入库单编号
- ultraGrid4.UpdateData();
- string strIn_stock_no_s = "";
- IQueryable<UltraGridRow> 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<PurCkInBillEntity>("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<CoreResult>("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<CoreResult>("com.hnshituo.pur.ck.service.CkInBillService", "isPrint", new object[] { al });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("标记打印失败:" + rt.Resultmsg);
- }
- GetCkInBill();
- }
- }
- }
- /// <summary>
- /// 打印入库单汇总,方法弃用
- /// </summary>
- 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<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
- //comm.FilComboboxAdd(txt_ItemName, dt_GropByItem, "ItemCODE", "ItemNAME", "", true, "", "");
- }
- /// <summary>
- /// 选择物料时,加载库区
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByOrder", new object[] { CkInBillEntity });
- //DataTable dt_GropByItem = comm.getDtGroupBy_reDt(dataTable5, "basecode");
- ////DataTable dt_GropByItem = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
- //DataTable dt_GropByInvPhisc = this.execute<DataTable>("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<DataTable>("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();
- }
- /// <summary>
- /// 选择物料
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<DataTable>("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<DataTable>("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<DataTable>("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)
- {
-
- }
- /// <summary>
- /// 导入入库单到库存
- /// </summary>
- 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<PurCkInBillEntity>("com.hnshituo.pur.ck.service.CkInBillService", "findById", new object[] { dr["InStockNo"].ToString() });
- //CkStorageEntity = EntityHelper.CopyEntity<CkStorage>(ck);//复制发货通知单行号中相同的字段值
- ////CkStorageEntity = EntityHelper.CopyEntity<CkStorage>(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<DataTable>("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<CoreResult>("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();
- }
- /// <summary>
- /// 导入入库单到库存
- /// </summary>
- private void ExportCkToCkOut()
- {
- ArrayList al = comm.getDtGroupBy_reAl(dataTable5, "InStockNo");
- CoreResult crt = this.GetJsonService().execute<CoreResult>("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;
- }
- }
- }
- }
- }
- }
|