using com.hnshituo.pur.vo;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
using Infragistics.Win.UltraWinGrid;
using Pur.Entity;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Pur.require_plan;
using Core.Mes.Client.Comm.Server;
using Pur.PublicTools;
using Pur.Entity.configureEntity;
using Pur.configure;
namespace Pur.ck
{
public partial class frmCkOutBillRemovePrint : FrmPmsBase
{
public frmCkOutBillRemovePrint()
{
InitializeComponent();
}
private void frmCkOutBillManaYB_Load(object sender, EventArgs e)
{
txt_isPrint.SelectedIndex = 1;
txt_CreateTimeStart.Value = DateTime.Now.AddMonths(-1);
txt_CreateTimeEnd.Value = DateTime.Now.AddDays(1);
getdropDownList();
is_JIT.Checked = true;
is_single.Checked = true;
ck_adjust.Checked = false;
txt_reqDepart1.Enabled = false;
txt_Dept1.Enabled = false;
ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true;
GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "CHK" });
GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "doQuery":
getOutbillData("");
break;
case "Close":
this.Close();
break;
case "UltraGridToExcel"://导出入口单
UltraGridToExcel();
break;
case "doPrint"://导出入口单
doPrint("0");
break;
case "doPrint_cf"://重复打印入口单
doPrint("1");
break;
case "cancelPrint"://导出入口单
cancelPrint();
break;
}
}
///
/// 取消打印
///
private void cancelPrint()
{
List al = new List();//取消打印出库单清单
StringBuilder bu=new StringBuilder();
ultraGrid1.UpdateData();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
CkOutBill pcibEntity = new CkOutBill();
pcibEntity.OutStockNo = row.GetCellValue("outStockno").ToString().Trim();
String strPrintCode1 = ultraGrid1.ActiveRow.GetCellValue("PrintRemoveCode").ToString().Trim();
if (String.IsNullOrEmpty(strPrintCode1))
{
MessageUtil.ShowTips("出库单:" + pcibEntity.OutStockNo + " 未打印");
row.Activate();
return;
}
pcibEntity.CreateName = UserInfo.GetUserName();
pcibEntity.CreateUserid = UserInfo.GetUserID();
pcibEntity.CreateTime = DateTime.Now;
//pcibEntity.PrintCode = strPrintNo;
al.Add(pcibEntity);
bu.Append(pcibEntity.OutStockNo+",");
}
}
if (al.Count <= 0)
{
MessageUtil.ShowTips("请选择需取消打印的出库单行");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确定取消打印出库单:" + bu.ToString() + "? 若为汇总打印,将同步取消关联出库单打印记录。") != DialogResult.Yes)
{
return;
}
CoreResult rt1 = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "cancelPrintRemove", new object[] { al });
if (rt1.Resultcode != 0)
{
MessageUtil.ShowTips("取消标记打印失败:" + rt1.Resultmsg);
}
else
{
MessageUtil.ShowTips("操作成功");
getOutbillData(al[al.Count - 1].OutStockNo);
}
}
private void doPrint(String strTips)
{
List al = new List();//打印出库单清单
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 isAll_print = "0";//是否汇总打印
if (!is_single.Checked)
{
//汇总打印
if (!ck_single_m.Checked)
{
String strDeptUse = "";
String strDept = txt_Dept1.Value == null ? "" : txt_Dept1.Value.ToString();
String strReqDept = txt_reqDepartCode.Text.ToString();
if (is_JIT.Checked)
{
if (String.IsNullOrEmpty(strDept))
{
MessageUtil.ShowTips("若选择按照成本中心打印,请先指定成本中心");
return;
}
strDeptUse = strDept;
}
else
{
if (String.IsNullOrEmpty(strReqDept))
{
MessageUtil.ShowTips("若选择按照领用单位打印,请先指定领用单位");
return;
}
strDeptUse = strReqDept;
}
//string strPrintNo = getPrintCode();
string stroutStockno = "";
ultraGrid1.UpdateData();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
String strOutStockNo = row.GetCellValue("outStockno").ToString().Trim();
stroutStockno += "'" + strOutStockNo + "',";
CkOutBill pcibEntity = new CkOutBill();
pcibEntity.OutStockNo = strOutStockNo;
if (String.IsNullOrEmpty(strOutStockNo))
{
MessageUtil.ShowTips("若单张打印的出库单号不能为空");
return;
}
CkOutBill outbill = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "findById", new object[] { strOutStockNo });
if (outbill == null)
{
MessageUtil.ShowTips("未发现出库单:" + strOutStockNo + "信息记录");
row.Activate();
return;
}
if (!String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "0")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 已打印,或请取消打印");
row.Activate();
return;
}
if (String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "1")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 还未打印,或请先打印");
row.Activate();
return;
}
pcibEntity.CreateName = UserInfo.GetUserName();
pcibEntity.CreateUserid = UserInfo.GetUserID();
pcibEntity.CreateTime = DateTime.Now;
al.Add(pcibEntity);
}
}
if (al.Count <= 0)
{
MessageUtil.ShowTips("请选择打印出库单行");
return;
}
stroutStockno = stroutStockno.Remove(0, 1);
stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_OutBill.cpt&op=view" + "&dept=" + strDeptUse + "&outStockNo=" + stroutStockno + "&TYPE=1" + "&ID=" + 1232025;
isAll_print = "1";
}
//单张连打
else
{
string stroutStockno = "";
ultraGrid1.UpdateData();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
{
String strOutStockNo = row.GetCellValue("outStockno").ToString().Trim();
stroutStockno += "'" + strOutStockNo + "',";
CkOutBill pcibEntity = new CkOutBill();
pcibEntity.OutStockNo = strOutStockNo;
pcibEntity.CreateName = UserInfo.GetUserName();
pcibEntity.CreateUserid = UserInfo.GetUserID();
pcibEntity.CreateTime = DateTime.Now;
if (String.IsNullOrEmpty(strOutStockNo))
{
MessageUtil.ShowTips("若单张打印的出库单号不能为空");
return;
}
CkOutBill outbill = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "findById", new object[] { strOutStockNo });
if (outbill == null)
{
MessageUtil.ShowTips("未发现出库单:" + strOutStockNo + "信息记录");
row.Activate();
return;
}
if (!String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "0")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 已打印,或请取消打印");
row.Activate();
return;
}
if (String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "1")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 还未打印,或请先打印");
row.Activate();
return;
}
//pcibEntity.PrintCode = strPrintNo;
al.Add(pcibEntity);
}
}
if (al.Count <= 0)
{
MessageUtil.ShowTips("请选择打印出库单行");
return;
}
stroutStockno = stroutStockno.Remove(0, 1);
stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_OutBill_single_ly_m.cpt&op=view" + "&outStockNo=" + stroutStockno + "&TYPE=1" + "&ID=" + 1232025;
}
}
else
{
if (ultraGrid1.ActiveRow == null)
{
MessageUtil.ShowTips("若单张打印,请选择需打印大出库单");
return;
}
String strOutStockNo = ultraGrid1.ActiveRow.GetCellValue("outStockno").ToString().Trim();
if (String.IsNullOrEmpty(strOutStockNo))
{
MessageUtil.ShowTips("若单张打印的出库单号不能为空");
return;
}
CkOutBill outbill = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "findById", new object[] { strOutStockNo });
if (outbill == null)
{
MessageUtil.ShowTips("未发现出库单:" + strOutStockNo + "信息记录");
return;
}
if (!String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "0")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 已打印,或请取消打印");
return;
}
if (String.IsNullOrEmpty(outbill.PrintRemoveCode) && strTips == "1")
{
MessageUtil.ShowTips("出库单:" + strOutStockNo + " 还未打印,或请先打印");
return;
}
if (is_JIT.Checked)
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_OutBill_single.cpt&op=view" + "&outStockNo=" + strOutStockNo + "&TYPE=1";
}
else
{
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_OutBill_single_ly.cpt&op=view" + "&outStockNo=" + strOutStockNo + "&TYPE=1" + "&ID=" + 1232025;
}
CkOutBill pcibEntity = new CkOutBill();
pcibEntity.OutStockNo = strOutStockNo;
pcibEntity.CreateName = UserInfo.GetUserName();
pcibEntity.CreateUserid = UserInfo.GetUserID();
pcibEntity.CreateTime = DateTime.Now;
al.Add(pcibEntity);
}
//strUrl = "http://localhost:8075/webroot/decision/view/report?viewlet=rpt_OutBill_test.cpt&op=view" + "&dept=" + strDept + "&itemClass=" + strItemClass + "&create_time_start=" + strStart + "&create_time_end=" + strEnd + "&inv_physic=" + strInvPhysic;
if (strTips == "0")
{
CoreResult rt = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "doPrintRemove", new object[] { al, isAll_print });
if (rt.Resultcode != 0)
{
MessageUtil.ShowTips("生成打印编号失败:" + rt.Resultmsg);
return;
}
}
comm.printReport(this.ob, strUrl, "出库单打印");
if (strTips == "0")
{
if (!MessageUtil.ShowYesNoAndQuestion("是否已打印出库单?").Equals(DialogResult.Yes))
{
CoreResult rt1 = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "cancelPrintRemove", new object[] { al });
if (rt1.Resultcode != 0)
{
MessageUtil.ShowTips("取消标记打印失败:" + rt1.Resultmsg);
}
}
getOutbillData(al[al.Count - 1].OutStockNo);
}
}
private void getOutbillData(String strOutBill)
{
try
{
dataSet1.Clear();
CkOutBill el = new CkOutBill();
String strDept = txt_Dept.Value == null ? "" : txt_Dept.Value.ToString();
el.UseOrgId = strDept;
String strReqDept = txt_reqDepart.Value == null ? "" : txt_reqDepart.Value.ToString();
el.UseOrgName = strReqDept;
if (txt_CreateTimeStart.Text != null)
{
el.CreateTime = Convert.ToDateTime(txt_CreateTimeStart.Value);
}
if (txt_CreateTimeEnd.Text != null)
{
el.UpdateTime = Convert.ToDateTime(txt_CreateTimeEnd.Value);
}
//if (txt_InvPhysic.SelectedIndex != -1)
//{
// el.DeliverAddress = txt_InvPhysic.Value.ToString();
//}
if (txt_ItemClass.SelectedIndex != -1)
{
el.ItemAttrId = txt_ItemClass.Value.ToString();
}
if (txt_isPrint.SelectedIndex != -1)
{
el.DeleteUserid = txt_isPrint.Value.ToString().Trim();
}
el.PrintRemoveCode = txt_printCode.Text.Trim();
el.OutStockNo = txt_outStockno.Text.Trim();
el.ItemCode = txt_itemCode.Text.Trim();
el.ItemName = txt_itemName.Text.Trim();
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "get_supp_remove", new object[] { el });
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (!String.IsNullOrEmpty(ugr.Cells["PrintRemoveCode"].Value.ToString().Trim()))
{
ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0);
}
else
{
ugr.CellAppearance.ForeColor = Color.Black;
}
}
GridHelper.RefreshAndAutoSize(ultraGrid1);
if (!String.IsNullOrEmpty(strOutBill))
{
publicPms.doActiveSelRow(ultraGrid1, "outStockno", strOutBill);
}
}
catch (Exception ex)
{
MessageUtil.ShowTips("查询失败:"+ex);
}
}
///
/// 加载dropdownlist
///
private void getdropDownList()
{
//加载成本中心
DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1230" }, this.ob);
if (dt1.Rows.Count > 0)
{
dt1.DefaultView.Sort = "BASENAME";
dt1 = dt1.DefaultView.ToTable();
}
publicPms.FilComboboxAdd(txt_Dept, dt1, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", "");
publicPms.FilComboboxAdd(txt_Dept1, dt1, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
//加载领用单位
CkOutBill el = new CkOutBill();
if (txt_CreateTimeStart.Text != null)
{
el.CreateTime = Convert.ToDateTime(txt_CreateTimeStart.Value);
}
if (txt_CreateTimeEnd.Text != null)
{
el.UpdateTime = Convert.ToDateTime(txt_CreateTimeEnd.Value);
}
DataTable dt11 = this.execute("com.hnshituo.pur.ck.service.CkOutBillService", "get_depart", new object[] { el });
if (dt11.Rows.Count > 0)
{
dt11.DefaultView.Sort = "useOrgName";
dt11 = dt11.DefaultView.ToTable();
}
publicPms.FilComboboxAdd(txt_reqDepart, dt11, "useOrgId", "useOrgName", "", true, "/", "");
//publicPms.FilComboboxAdd(txt_reqDepart1, dt11, "useOrgId", "useOrgName", "", false, "/", "");
getMatClassData();
//PhysicSeatEntity Phouse = new PhysicSeatEntity();
//Phouse.Validflag = "1";
//Phouse.DeleteUserid = "2";
//DataTable dt3 = this.execute("com.hnshituo.pur.configure.service.ActualSeatService", "find", new object[] { Phouse,0,0});
//publicPms.FilComboboxAdd(txt_InvPhysic, dt3, "INVPHYSIC", "INVPHYSICNAME", "", true, "/", "");
}
private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)
{
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow uge = ultraGrid1.ActiveRow;
if (uge == null)
return;
CkOutBill yy = new CkOutBill();
yy.ItemCode = uge.Cells["itemCode"].Value.ToString();
DataTable dt1 = this.execute("com.hnshituo.pur.ck.service.CkOutbillPositionService", " get_supp1", new object[] { uge.Cells["OutStockNo"].Value.ToString() });
GridHelper.CopyDataToDatatable(ref dt1, ref dataTable2, true);
GridHelper.RefreshAndAutoSize(ultraGrid2);
}
///
/// 导出Excel
///
private void UltraGridToExcel()
{
try
{
//获取导出的采购计划行表
ArrayList alUltraGrid = new ArrayList();
alUltraGrid.Add(ultraGrid1);
ArrayList alSheeft = new ArrayList();
alSheeft.Add("出库单");
if (ultraGrid1.Rows.Count > 0)
{
GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "出库单");//导出excel
}
MessageUtil.ShowTips("导出成功");
}
catch (Exception e)
{
MessageUtil.ShowTips("导出失败" + e.Message);
}
}
private void txt_Dept_SelectionChanged(object sender, EventArgs e)
{
getMatClassData();
txt_Dept1.Value = txt_Dept.Value;
}
///
/// 获取物料中类
///
private void getMatClassData()
{
//加载物料中类
PurmatclassEntity mat = new PurmatclassEntity();
mat.DeleteName = "1";
mat.DeleteUserid = "2";
if (is_JIT.Checked)
{
String strDept = txt_Dept.Value == null ? "" : txt_Dept.Value.ToString();
mat.UpdateName = strDept;
}
if (is_JIT1.Checked)
{
String strReqDept = txt_reqDepart.Value == null ? "" : txt_reqDepart.Value.ToString();
mat.UpdateUserid = strReqDept;
}
DataTable dt2 = this.execute("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { mat });
publicPms.FilComboboxAdd(txt_ItemClass, dt2, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", "");
}
private void is_JIT_CheckedChanged(object sender, EventArgs e)
{
if (ck_adjust.Checked)
{
txt_Dept1.Enabled = is_JIT.Checked;
}
}
private void is_JIT1_CheckedChanged(object sender, EventArgs e)
{
if (ck_adjust.Checked)
{
txt_reqDepart1.Enabled = is_JIT1.Checked;
}
}
private void is_single_CheckedChanged(object sender, EventArgs e)
{
//is_JIT.Enabled = !is_single.Checked;
//is_JIT1.Enabled = !is_single.Checked;
foreach (UltraGridRow row in ultraGrid1.Rows)
{
row.Cells["CHK"].Value = false;
}
if (is_single.Checked)
{
ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true;
}
else
{
ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false;
}
}
private void txt_reqDepart_SelectionChanged(object sender, EventArgs e)
{
txt_reqDepart1.Clear();
txt_reqDepartCode.Text = "";
txt_reqDepart1.Text = txt_reqDepart.Text;
txt_reqDepartCode.Text = txt_reqDepart.Value.ToString();
}
private void ck_adjust_CheckedChanged(object sender, EventArgs e)
{
txt_Dept1.Enabled = ck_adjust.Checked;
txt_reqDepart1.Enabled = ck_adjust.Checked;
}
private void txt_reqDepart1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
frmdepartment frm = new frmdepartment(this.ob);
//frm.StartPosition = FormStartPosition.Manual;
//frm.Location = publicPms.getShowLocation(frm);
frm.ShowDialog();
String strdeptId = frm.BuyerUnitCode;
String strDeptName = frm.Fulltext;
if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName))
{
txt_reqDepart1.Text = strDeptName;
txt_reqDepartCode.Text = strdeptId;
}
}
}
}