using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using WMS.Business;
using WMS.Business.Report;
using WMS.Business.Stock;
using WMS.Common;
using WMS.Ctrl;
using WMS.Frm.Base;
using WMS.Model.Stock;
namespace WMS.FrmCK
{
public partial class FrmStockAdj : FormBase
{
public FrmStockAdj()
{
InitializeComponent();
}
private void FrmStockAdj_Load(object sender, EventArgs e)
{
BindMiStockData();
}
///
/// 库存List
///
List miStockList = new List();
///
/// 绑定库存数据
///
///
public void BindMiStockData()
{
new Thread(delegate ()
{
string errText = string.Empty;
try
{
this.Invoke(new MethodInvoker(delegate
{
LoadForm load = new LoadForm();
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50);
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在处理数据,请等待....");
miStockList = IBussFactory.Instance().GetMiStockForLookUp();
if (miStockList != null)
{
bgsStock.DataSource = miStockList;
}
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
}));
}
catch (Exception)
{
SystemCommon.ShowInfoMessageBox("error");
}
}).Start();
}
private void ctrlButtons3_Click(object sender, EventArgs e)
{
if (SystemCommon.ShowMessageBoxResult("确定删除库存:" + this.txtLocation.Text.ToString() + "信息吗?") == DialogResult.OK)
{
DeleteStockdata();
}
}
public void DeleteStockdata()
{
string errText = string.Empty;
if (this.txtLocation.Text == "")
{
SystemCommon.ShowInfoMessageBox("请选择要删除的数据!");
}
try
{
IBussFactory.Instance().DeleteMIStock(txtCTL.Text, txtLocation.Text, txtGoodsId.Text, ref errText);
if (errText.Length == 0)
{
SystemCommon.ShowInfoMessageBox("手工删除库存成功!");
//DataProvider.Instance.AutoRkData.InsertOperateLog(GetLocalIp(), "托盘号:" + txtCTL.Text, "3", "手动删除库存");
}
else { SystemCommon.ShowInfoMessageBox("错误!" + errText); }
BindMiStockData();
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
}
private void ctrlButtons2_Click(object sender, EventArgs e)
{
if (SystemCommon.ShowMessageBoxResult("确定调整库存:" + this.txtLocation.Text.ToString() + "信息吗?") == DialogResult.OK)
{
if (this.txtLocation.Text == "")
{
SystemCommon.ShowInfoMessageBox("请选择要删除的数据!");
return;
}
if (txtCCNum.Text.ToString() == "0")
{
DeleteStockdata();
}
if (Convert.ToDecimal(txtCCNum.Text) < 0)
{
SystemCommon.ShowInfoMessageBox("请输入正确的库存数量!");
return;
}
if (IBussFactory.Instance().UpdateMis(txtCCNum.Text, txtLocation.Text, txtStorageid.Text, txtGoodsId.Text))
{
SystemCommon.ShowInfoMessageBox("调整库存成功!");
//DataProvider.Instance.AutoRkData.InsertOperateLog(GetLocalIp(), "托盘号:" + txtCTL.Text, "3", "手动调整库存");
}
}
}
private void ctrlButtons4_Click(object sender, EventArgs e)
{
if (SystemCommon.ShowMessageBoxResult("确定解冻库存:" + this.txtLocation.Text.ToString() + "信息吗?") == DialogResult.OK)
{
if (this.txtLocation.Text == "")
{
SystemCommon.ShowInfoMessageBox("请选择要删除的数据!");
return;
}
if (this.t_sts.Text == "正常")
{
SystemCommon.ShowInfoMessageBox("请选择正确的数据!");
return;
}
if (IBussFactory.Instance().UpdateMis(txtLocation.Text, txtStorageid.Text))
{
SystemCommon.ShowInfoMessageBox("解冻库存成功!");
}
}
}
private void ctrlButtons1_Click(object sender, EventArgs e)
{
BindMiStockData();
}
string storage_id = "";
private void GVMiStock_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
if (GVMiStock.RowCount == 0)
{
return;
}
storage_id = GVMiStock.GetFocusedRowCellValue("STORAGE_ID").ToString();
this.txtCTL.Text = GVMiStock.GetFocusedRowCellValue("CTL").ToString();
this.txtLocation.Text = GVMiStock.GetFocusedRowCellValue("LOCATION_ID").ToString();
this.txtGoodsId.Text = GVMiStock.GetFocusedRowCellValue("GOODS_ID").ToString();
txtGoodsName.Text = GVMiStock.GetFocusedRowCellValue("GOODS_NAME").ToString();
txtCCNum.Text = GVMiStock.GetFocusedRowCellValue("SHELVES_NUM").ToString();
this.txtGDH.Text = GVMiStock.GetFocusedRowCellValue("DOCCTNUMBER").ToString();
t_sts.Text = GVMiStock.GetFocusedRowCellValue("STS").ToString();
txtStorageid.Text = GVMiStock.GetFocusedRowCellValue("STORAGE_ID").ToString();
if (t_sts.Text == "1")
{
t_sts.Text = "占用";
}
else
{
t_sts.Text = "正常";
}
}
}
}