using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;using Pur.Entity;
using Pur.Entity.ck;
using Pur.require_plan;
using Pur.Entity.configureEntity;
using Core.Mes.Client.Comm.Control;
using com.hnshituo.pur.vo;
using Pur.configure;
using Infragistics.Win;
using Pur.PublicTools;
using Infragistics.Win.UltraWinGrid;
using Pur.Pop_upWindow;
using Core.Mes.Client.Comm.Tool;
using System.Collections;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm;
namespace Pur.ck
{
public partial class FrmCkStorage : FrmPmsBase
{
public FrmCkStorage()
{
InitializeComponent();
txt_createTimeE.Value = System.DateTime.Now;
txt_createTimeS.Value = ((DateTime)txt_createTimeE.Value).AddMonths(-1);
//ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
}
//菜单按钮事件
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
if (ultraTabControl2.SelectedTab.Key == "0")
{
GetPUR_CK_STORAGE();
}
else
{
getPur_Ck_StorageSuorce();
}
break;
case "Add":
addCkInBill();
break;
case "cockInv":
cockInv();
break;
case "unCockInv":
unCockInv();
break;
case "MovingInvPhy":
MovingInvPhy();
break;
case "CanCelMovingInvPhy":
CanCelMovingInvPhy();
break;
case "Print":
doPrint("0");
break;
case "overPrint":
doPrint("1");
break;
case "CanCelPrint":
CanCelPrint();
break;
case "doexport":
doexport();
break;
case "doSaveMemo":
doSaveMemo();
break;
}
}
public void doexport()
{
if (ultraTabControl2.ActiveTab.Key == "0")
GridHelper.ulGridToExcel(ultraGrid1, ultraGrid1.Text);
else
GridHelper.ulGridToExcel(ultraGrid5, ultraGrid5.Text);
}
///
/// 查询
///
private void GetPUR_CK_STORAGE()
{
dataTable2.Rows.Clear();
dataTable3.Rows.Clear();
CkStorage CkSto = new CkStorage();
CkSto.InvId = txt_InvId.Text;
CkSto.ItemCode = txt_itemCode.Text;
CkSto.ItemName = txt_itemName.Text;
if (txt_invBin.Value != null)
{
CkSto.DeleteName = txt_invBin.Text;
}
//CkSto.InvLogic = txt_invLogic.Text;
if (txt_invPhysic.Value != null)
{
CkSto.DeleteUserid = txt_invPhysic.Text;
}
CkSto.SuppName = txt_suppName.Text;
CkSto.OrderId = txt_orderId.Text;
CkSto.InStockNo = txt_inStockNo.Text;
CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
CkSto.CreateName = txtItemClass.Text;
if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
{
CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
}
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
GridHelper.CopyDataToDatatable(dt, dataTable1, true);
GridHelper.RefreshAndAutoSize(ultraGrid1);
//publicPms.autoGridColumnWSize(ultraGrid1.DisplayLayout.Bands[0]);
getBindInvPhySic();
getBindInvPhySicPos();
txt_invPhysic.Text = CkSto.DeleteUserid;
txt_invBin.Text = CkSto.DeleteName;
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
//标记待检状态入库单
if (ugr.Cells["USESTATUS"].Value.ToString() == "不可用")
{
ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
ugr.Cells["STATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
}
else
{
ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Black;
ugr.Cells["STATUS"].Appearance.ForeColor = Color.Black;// System.Drawing.Color.FromArgb(255, 128, 0);
}
}
}
///
/// 获取移库记录
///
private void getPur_Ck_StorageSuorce()
{
//dataTable7.Rows.Clear();
//CkStorage CkSto = new CkStorage();
//CkSto.InvId = txt_InvId.Text;
//CkSto.ItemCode = txt_itemCode.Text;
//CkSto.ItemName = txt_itemName.Text;
//if (txt_invBin.Value != null)
//{
// CkSto.DeleteName = txt_invBin.Text;
//}
////CkSto.InvLogic = txt_invLogic.Text;
//if (txt_invPhysic.Value != null)
//{
// CkSto.DeleteUserid = txt_invPhysic.Text;
//}
//CkSto.SuppName = txt_suppName.Text;
//CkSto.OrderId = txt_orderId.Text;
//CkSto.InStockNo = txt_inStockNo.Text;
//CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
//if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
//{
// CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
// CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
//}
////查询源移库记录
//CkSto.Status = "11";
//DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
//GridHelper.CopyDataToDatatable(dt, dataTable4, true);
//GridHelper.RefreshAndAutoSize(ultraGrid2);
dataTable6.Rows.Clear();
CkStorage CkSto = new CkStorage();
CkSto.InvId = txt_InvId.Text;
CkSto.ItemCode = txt_itemCode.Text;
CkSto.ItemName = txt_itemName.Text;
if (txt_invBin.Value != null)
{
CkSto.DeleteName = txt_invBin.Text;
}
//CkSto.InvLogic = txt_invLogic.Text;
if (txt_invPhysic.Value != null)
{
CkSto.DeleteUserid = txt_invPhysic.Text;
}
CkSto.SuppName = txt_suppName.Text;
CkSto.OrderId = txt_orderId.Text;
CkSto.InStockNo = txt_inStockNo.Text;
CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
{
CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
}
CkSto.CreateName = txtItemClass.Text;
CkSto.PrintNo = utPrintNo.Text.Trim();
//查询源移库记录
//CkSto.Status = "11";
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageUseService", "getCk_YK", new object[] { CkSto });
GridHelper.CopyDataToDatatable(dt, dataTable6, true);
GridHelper.RefreshAndAutoSize(ultraGrid5);
}
///
/// 解冻库存
///
private void unCockInv()
{
UltraGridRow ugr = ultraGrid1.ActiveRow;
CkStorage ck = new CkStorage();
ck.InvId = ugr.Cells["InvId"].Value.ToString();
ck.UseStatus = "1";
if (MessageUtil.ShowYesNoAndQuestion("确定解冻库存【" + ck.InvId + "】?").Equals(DialogResult.No))
{
return;
}
CoreResult re1 = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
if (re1.Resultcode == -1)
{
MessageBox.Show("解冻失败:" + re1.Resultmsg, "");
return;
}
MessageBox.Show("解冻成功!");
GetPUR_CK_STORAGE();
getPur_Ck_StorageSuorce();
}
///
/// 冻结库存
///
private void cockInv()
{
UltraGridRow ugr = ultraGrid1.ActiveRow;
CkStorage ck = new CkStorage();
ck.InvId = ugr.Cells["InvId"].Value.ToString();
ck.UseStatus = "0";
if (MessageUtil.ShowYesNoAndQuestion("确定冻结库存【" + ck.InvId + "】?").Equals(DialogResult.No))
{
return;
}
CoreResult re1 = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
if (re1.Resultcode == -1)
{
MessageBox.Show("冻结失败:" + re1.Resultmsg, "");
return;
}
MessageBox.Show("冻结成功!");
GetPUR_CK_STORAGE();
getPur_Ck_StorageSuorce();
}
///
/// 新增入库操作
///
private void addCkInBill()
{
PopFrmCkInBill frm = new PopFrmCkInBill(this.ob);
frm.ShowDialog();
}
///
/// 物料弹窗
///
///
///
private void txt_itemCode_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
FrmPurPlanMat mat = new FrmPurPlanMat(this.ob);
mat.ShowDialog();
if (mat.getItemCode() != null)
{
txt_itemCode.Text = mat.getItemCode().ToString();
txt_itemName.Text = mat.getItemName().ToString();
}
}
///
/// 界面加载,库区下拉框加载
///
///
///
private void PurCkStorage_Load(object sender, EventArgs e)
{
//加载成本中心
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_Dept1, dt1, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
txt_createTimeS.Text = DateTime.Now.AddMonths(-1).ToString();
txt_invOrigQty.Value = 2;
//获取
PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();
DataTable dt_GropByItem = this.execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
comm.FilComboboxAdd(txtItemClass, dt_GropByItem, "basecode", "basename", "", true, "", "");
//LogicWareHouseEntity lhouse = new LogicWareHouseEntity();
//lhouse.Validflag = "1";
//DataTable dt = this.execute("com.hnshituo.pur.configure.service.LogicSeatService", "getLogicSeat", new object[] { lhouse, 0, 0 });
//if (dt.Rows.Count > 0)
//{
// txt_invLogic.DataSource = dt;
// this.txt_invLogic.DisplayMember = "invLogicName";
// this.txt_invLogic.ValueMember = "invLogic";
//}
//PhysicSeatEntity Phouse = new PhysicSeatEntity();
//Phouse.Validflag = "1";
//DataTable dt1 = this.execute("com.hnshituo.pur.configure.service.ActualSeatService", "getActualSeat", new object[] { Phouse, 0, 0 });
//if (dt1.Rows.Count > 0)
//{
// txt_invPhysic.DataSource = dt1;
// this.txt_invPhysic.DisplayMember = "invPhysicName";
// this.txt_invPhysic.ValueMember = "invPhysic";
//}
//ActualSeatPosEntity PosEntity = new ActualSeatPosEntity();
//PosEntity.Validflag = "1";
//DataTable dt3 = this.execute("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { PosEntity, 0, 0 });
//if (dt3.Rows.Count > 0)
//{
// txt_invBin.DataSource = dt3;
// this.txt_invBin.DisplayMember = "invPosName";
// this.txt_invBin.ValueMember = "invPos";
//}
ValueListItem[] item1 = new ValueListItem[] {
new ValueListItem("0", "待确认"),
new ValueListItem("1", "已确认"),
};
ValueList valueList1 = new ValueList();
valueList1.ValueListItems.AddRange(item1);
ultraGrid5.DisplayLayout.Bands[0].Columns["confirmStatus"].ValueList = valueList1;
ValueListItem[] item2 = new ValueListItem[] {
new ValueListItem("0", "未打印"),
new ValueListItem("1", "已打印"),};
ValueList valueList2 = new ValueList();
valueList2.ValueListItems.AddRange(item2);
ultraGrid5.DisplayLayout.Bands[0].Columns["printType"].ValueList = valueList2;
GridHelper.SetExcludeColumnsActive(ultraGrid5.DisplayLayout.Bands[0], "Check","MEMO");
GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "Check", "MoveQtyKC", "MoveQty");
ultraExpandableGroupBox2.Expanded = true;
//GetPUR_CK_STORAGE();
}
///
/// 供应商弹窗
///
///
///
private void txt_suppName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
Supp Sp = new Supp();
Sp.Validflag = "1";
//DataTable dt = this.execute("com.hnshituo.pur.configure.service.SuppService", "find", new object[] {Sp,0,0 });
frmSuppSel Sky = new frmSuppSel(this.ob);
Sky.ShowDialog();
if (Sky.strSUPP_CODE == null)
return;
txt_suppName.Text = Sky.strSUPP_NAME.ToString();
//Supp_Code = Sky.strSUPP_CODE.ToString();
}
///
/// 激活库存表
///
///
///
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
//GetPUR_CK_STORAGE_USE();
//GetPUR_CK_STORAGE_POS();
}
///
/// 保存备注
///
private void doSaveMemo()
{
List rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
if (rows.Count <= 0)
{
MessageUtil.ShowTips("请勾选需要填写的记录");
return;
}
if (!MessageUtil.ShowYesNoQuestion("确定保存当前记录?"))
return;
List list = new List();
foreach (UltraGridRow row in rows)
{
PurCkStorageUseEntity ckuse = new PurCkStorageUseEntity();
ckuse.Id = row.Cells["Id"].Value.ToString();
ckuse.Memo = row.Cells["MEMO"].Value.ToString();
list.Add(ckuse);
}
CoreResult re1 = this.execute("com.hnshituo.pur.ck.service.CkStorageUseService", "doSaveMemo", new object[] { list });
if (re1.Resultcode == -1)
{
MessageBox.Show("保存失败:" + re1.Resultmsg, "");
return;
}
MessageBox.Show("保存成功!");
GetPUR_CK_STORAGE_USE();
}
///
/// 查询库存使用表
///
private void GetPUR_CK_STORAGE_USE()
{
if (ultraGrid1.ActiveRow != null)
{
PurCkStorageUseEntity CkStorageUseEntity = new PurCkStorageUseEntity();
CkStorageUseEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
CkStorageUseEntity.Validflag = "1";
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageUseService", "find", new object[] { CkStorageUseEntity, 0, 0 });
//按创建时间降序
if (dt.Rows.Count > 1)
{
dt.DefaultView.Sort = "CREATETIME DESC";
dt = dt.DefaultView.ToTable();
}
GridHelper.CopyDataToDatatable(dt, dataTable3, true);
}
}
///
/// 查询库存库位
///
private void GetPUR_CK_STORAGE_POS()
{
if (ultraGrid1.ActiveRow != null)
{
PurCkStoragePosEntity CkStoragePosEntity = new PurCkStoragePosEntity();
CkStoragePosEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePos_ByInvId", new object[] { CkStoragePosEntity });
//按创建时间降序
if (dt.Rows.Count > 1)
{
dt.DefaultView.Sort = "CREATETIME DESC";
dt = dt.DefaultView.ToTable();
}
GridHelper.CopyDataToDatatable(dt, dataTable2, true);
}
//publicPms.autoGridColumnWSize(ultraGrid2.DisplayLayout.Bands[0]);
}
///
/// 查询库存中的库区分组
///
private void getBindInvPhySic()
{
CkStorage CkSto = new CkStorage();
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "GetCkStorage_GropByInvPhisc", new object[] { CkSto });
comm.setUltraComboEditorBind(txt_invPhysic, dt, "itemName", "itemCode");
}
///
/// 查询库存中的库位分组
///
private void getBindInvPhySicPos()
{
CkStorage CkSto = new CkStorage();
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "GetCkStorage_GropByInvPos", new object[] { CkSto });
dt = comm.getDtGroupBy_reDt(dt, "itemName");
comm.setUltraComboEditorBind(txt_invBin, dt, "itemName", "itemCode");
}
///
/// 勾选库存记录
///
///
///
private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
object o = e.Cell.Value;
ultraGrid1.UpdateData();
//UltraGridRow[] ugrs = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check" }, new string[] { e.Cell.Value.ToString()});
//判断库区是否全相同
//UltraGridRow[] ugrsPhysic = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check","invPhysic" }, new string[] { e.Cell.Value.ToString(),e.Cell.Row.Cells["invPhysic"].Value.ToString() });
//判断库位是否全相同
//UltraGridRow[] ugrsPhysicPos = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check", "invPos" }, new string[] { e.Cell.Value.ToString(), e.Cell.Row.Cells["invPos"].Value.ToString() });
if (e.Cell.Column.Key == "MoveQtyKC")
{
double bMoveQtyKC = 0;
double.TryParse(e.Cell.Row.Cells["MoveQtyKC"].Value.ToString(), out bMoveQtyKC);
double bINVQTYWEIGHT = 0;
double.TryParse(e.Cell.Row.Cells["INVQTYWEIGHT"].Value.ToString(), out bINVQTYWEIGHT);
double bITEMUOMCONEFFICIENT = 0;
double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
if (bMoveQtyKC > bINVQTYWEIGHT)
{
MessageUtil.ShowTips("移库数量不能>库存数量");
e.Cell.Value = o;
return;
}
else
{
if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
{
e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC * bITEMUOMCONEFFICIENT, 3);
}
else
{
e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC / bITEMUOMCONEFFICIENT, 3);
}
}
}
if (e.Cell.Column.Key == "MoveQty")
{
double bMoveQty = 0;
double.TryParse(e.Cell.Row.Cells["MoveQty"].Value.ToString(), out bMoveQty);
double bINVQTY = 0;
double.TryParse(e.Cell.Row.Cells["INVQTY"].Value.ToString(), out bINVQTY);
double bITEMUOMCONEFFICIENT = 0;
double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
if (bMoveQty > bINVQTY)
{
MessageUtil.ShowTips("移库数量不能>采购数量");
e.Cell.Value = o;
return;
}
else
{
if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
{
e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty / bITEMUOMCONEFFICIENT, 3);
}
else
{
e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty * bITEMUOMCONEFFICIENT, 3);
}
}
}
}
///
/// 选择库区
///
///
///
private void txt_PhysicNew_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
try
{
frmPopActualSeat pas = new frmPopActualSeat(this.ob, "0");
pas.ShowDialog();
txt_PhysicNew.Text = pas.DeliveryLocation;
txt_PhysicNewCode.Text = pas.DeliveryLocationCode;
//获取储位
ActualSeatPosEntity aspe = new ActualSeatPosEntity();
aspe.InvPhysic = pas.DeliveryLocationCode;
DataTable dt = this.execute("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { aspe, 0, 0 });
comm.setUltraComboEditorBind(txtPhysicPosNew, dt, "INVPOSNAME", "invpos");
}
catch (Exception ee)
{
MessageUtil.ShowTips(ee.Message);
}
}
///
/// 移库操作
///
///
///
private void btn_MovePhysic_Click(object sender, EventArgs e)
{
MovingInvPhy();
}
///
/// 移库
///
private void MovingInvPhy()
{
ultraGrid1.UpdateData();
if (ultraTabControl2.SelectedTab.Key != "0")
{
MessageUtil.ShowTips("请切换tab页面到“库存记录”,再进行移库");
return;
}
if (txt_PhysicNew.Text.Trim() == "")
{
MessageUtil.ShowTips("请选择新库区");
return;
}
if (txtPhysicPosNew.Text.Trim() == "")
{
MessageUtil.ShowTips("请选择新库位");
return;
}
if (txt_PhysicNewCode.Text.Trim() == "")
{
MessageUtil.ShowTips("未获取到新库区编码,请重试或联系管理员");
return;
}
if (txtPhysicPosNew.Value == null || txtPhysicPosNew.Value.ToString().Trim() == "")
{
MessageUtil.ShowTips("未获取到新库位编码,请重试或联系管理员");
return;
}
ArrayList al = new ArrayList();
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
if ((bool)ugr.Cells["Check"].Value)
{
double bMoveQty = 0;
//if (ugr.Cells["itemUom"].Value.ToString() == "基吨")
//{
// double.TryParse(ugr.Cells["MoveQtyKC"].Value.ToString(), out bMoveQty);
//}
//else
//{
// double.TryParse(ugr.Cells["MoveQty"].Value.ToString(), out bMoveQty);
//}
double.TryParse(ugr.Cells["MoveQtyKC"].Value.ToString(), out bMoveQty);
CkStorage ck = new CkStorage();
ck.InvId = ugr.Cells["InvId"].Value.ToString();
ck.InvQty = bMoveQty;//移库数量
if (bMoveQty <= 0)
{
MessageUtil.ShowTips("库存记录【" + ck.InvId + "】移库数量必须>0");
return;
}
//标记待检状态入库单
if (ugr.Cells["USESTATUS"].Value.ToString() == "不可用")
{
MessageUtil.ShowTips("库存记录【" + ck.InvId + "】使用状态为“不可用”,不能做移库操作");
return;
}
al.Add(ck);
}
}
if (al.Count < 1)
{
MessageUtil.ShowTips("请勾选需要移库的库存记录");
return;
}
PurCkStoragePosEntity csp = new PurCkStoragePosEntity();
csp.InvPhysic = txt_PhysicNewCode.Text;
csp.InvPos = txtPhysicPosNew.Value.ToString().Trim();
csp.CreateName = UserInfo.GetUserName();
csp.CreateUserid = UserInfo.GetUserID();
if (MessageUtil.ShowYesNoAndQuestion("确定移库?").Equals(DialogResult.No))
{
return;
}
CoreResult re1 = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "MoveInvPhysic", new object[] { al, csp });
if (re1.Resultcode == -1)
{
MessageBox.Show("操作失败:" + re1.Resultmsg, "");
return;
}
MessageBox.Show("移库成功!");
GetPUR_CK_STORAGE();
getPur_Ck_StorageSuorce();
}
///
/// 撤销移库
///
private void CanCelMovingInvPhy()
{
if (ultraTabControl2.SelectedTab.Key != "1")
{
MessageUtil.ShowTips("请切换tab页面到“移库记录”,再撤销移库");
return;
}
List rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
if (rows.Count<=0)
{
MessageUtil.ShowTips("请勾选需要撤销的记录");
return;
}
if (!MessageUtil.ShowYesNoQuestion("确定进行撤销移库操作"))
return;
List list = new List();
foreach (UltraGridRow row in rows)
{
CkStorage ck = new CkStorage();
ck.InvId = row.Cells["INVIDNEW"].Value.ToString();
ck.InvIdSource = row.Cells["invid"].Value.ToString();
ck.UpdateName = UserInfo.GetUserName();
ck.UpdateUserid = UserInfo.GetUserID();
list.Add(ck);
}
CoreResult re1 = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "CanCelMovingInvPhy", new object[] { list });
if (re1.Resultcode == -1)
{
MessageBox.Show("撤销失败:" + re1.Resultmsg, "");
return;
}
MessageBox.Show("撤销成功!");
GetPUR_CK_STORAGE();
getPur_Ck_StorageSuorce();
}
///
/// 选择新库位
///
///
///
private void txtPhysicPosNew_ValueChanged(object sender, EventArgs e)
{
//获取库位编码
}
private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
{
CkStorage CkSto = new CkStorage();
CkSto.InvIdSource = ultraGrid2.ActiveRow.Cells["InvId"].Value.ToString();
DataTable dt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
GridHelper.CopyDataToDatatable(dt, dataTable7, true);
GridHelper.RefreshAndAutoSize(ultraGrid4);
}
private void doPrint(String strTips)
{
if (ultraTabControl2.SelectedTab.Key != "1")
{
MessageUtil.ShowTips("请切换tab页面到“移库记录”,再进行打印操作");
return;
}
List rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
if (rows.Count <= 0)
{
MessageUtil.ShowTips("请勾选需要打印的记录");
return;
}
List al = new List();//打印出库单清单
String strUrlPort = "http://172.54.10.42:8080";//报表系统IP
String[] str = strUrlPort.Split(':');
String strUrl = str[0] + ":" + str[1];
String isAll_print = "0";//是否汇总打印
//汇总打印
if (!ck_single_m.Checked)
{
String strDeptUse = "";
String strDept = txt_Dept1.Value == null ? "" : txt_Dept1.Value.ToString();
if (is_JIT.Checked)
{
if (String.IsNullOrEmpty(strDept))
{
MessageUtil.ShowTips("若选择按照成本中心打印,请先指定成本中心");
return;
}
strDeptUse = strDept;
}
//string strPrintNo = getPrintCode();
string stroutStockno = "";
ultraGrid1.UpdateData();
foreach (UltraGridRow row in rows)
{
String invId = row.Cells["INVIDNEW"].Value.ToString();
stroutStockno += "'" + invId + "',";
CkStorage ck = new CkStorage();
ck.InvId = invId;
if (String.IsNullOrEmpty(invId))
{
MessageUtil.ShowTips("若单张打印的出库单号不能为空");
return;
}
CkStorage ckInfo = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
if (ckInfo == null)
{
MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
row.Activate();
return;
}
if (!String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "0")
{
MessageUtil.ShowTips("库存号:" + invId + " 已打印,或请取消打印");
row.Activate();
return;
}
if (String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "1")
{
MessageUtil.ShowTips("库存号:" + invId + " 还未打印,或请先打印");
row.Activate();
return;
}
ck.CreateName = UserInfo.GetUserName();
ck.CreateUserid = UserInfo.GetUserID();
ck.CreateTime = DateTime.Now;
//pcibEntity.PrintCode = strPrintNo;
al.Add(ck);
}
stroutStockno = stroutStockno.Remove(0, 1);
stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_InBill.cpt&op=view" + "&dept=" + strDeptUse + "&outStockNo=" + stroutStockno + "&ID=" + 1232025;
isAll_print = "1";
}
//单张连打
else
{
string stroutStockno = "";
ultraGrid1.UpdateData();
foreach (UltraGridRow row in rows)
{
String invId = row.Cells["INVIDNEW"].Value.ToString();
stroutStockno += "'" + invId + "',";
CkStorage ck = new CkStorage();
ck.InvId = invId;
ck.CreateName = UserInfo.GetUserName();
ck.CreateUserid = UserInfo.GetUserID();
ck.CreateTime = DateTime.Now;
if (String.IsNullOrEmpty(invId))
{
MessageUtil.ShowTips("若单张打印的出库单号不能为空");
return;
}
CkStorage ckInfo = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
if (ckInfo == null)
{
MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
row.Activate();
return;
}
if (!String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "0")
{
MessageUtil.ShowTips("库存号:" + invId + " 已打印,或请取消打印");
row.Activate();
return;
}
if (String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "1")
{
MessageUtil.ShowTips("库存号:" + invId + " 还未打印,或请先打印");
row.Activate();
return;
}
al.Add(ck);
}
stroutStockno = stroutStockno.Remove(0, 1);
stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_InBill_single_ly_m.cpt&op=view" + "&outStockNo=" + stroutStockno + "&ID=" + 1232025;
}
if (strTips == "0")
{
CoreResult rt = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "doPrint", 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.CkStorageService", "cancelPrint", new object[] { al });
if (rt1.Resultcode != 0)
{
MessageUtil.ShowTips("取消标记打印失败:" + rt1.Resultmsg);
}
}
}
}
private void CanCelPrint()
{
if (ultraTabControl2.SelectedTab.Key != "1")
{
MessageUtil.ShowTips("请切换tab页面到“移库记录”,再进行取消打印操作");
return;
}
List rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
if (rows.Count <= 0)
{
MessageUtil.ShowTips("请勾选需要取消打印的记录");
return;
}
List list = new List();
foreach (UltraGridRow row in rows)
{
String invId = row.Cells["INVIDNEW"].Value.ToString();
CkStorage ck = new CkStorage();
ck.InvId = invId;
ck.CreateName = UserInfo.GetUserName();
ck.CreateUserid = UserInfo.GetUserID();
ck.CreateTime = DateTime.Now;
CkStorage ckInfo = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
if (ckInfo == null)
{
MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
row.Activate();
return;
}
if (String.IsNullOrEmpty(ckInfo.PrintNo))
{
MessageUtil.ShowTips("库存号:" + invId + " 还未打印,不能取消");
row.Activate();
return;
}
list.Add(ck);
}
CoreResult rt1 = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "cancelPrint", new object[] { list });
if (rt1.Resultcode != 0)
{
MessageUtil.ShowTips("取消打印失败:" + rt1.Resultmsg);
}
}
private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
{
if ("0".Equals(ultraTabControl2.SelectedTab.Key))
{
utPrintNo.Visible = false;
ultraLabel18.Visible = false;
ultraPanel3.Visible = false;
}
else
{
utPrintNo.Visible = true;
ultraLabel18.Visible = true;
ultraPanel3.Visible = true;
}
}
}
}