BaoKai_202508_Wms_Jingwang_.../WMS.FrmStock/FrmStockAdjust.cs
2025-08-24 21:52:42 +08:00

2314 lines
84 KiB
C#
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 WMS.Frm.Base;
using WMS.Model.Base;
using WMS.Common;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraEditors.Repository;
using WMS.Model.Stock;
using WMS.Model.RK;
using WMS.FrmBaseData;
using WMS.Ctrl;
using System.Collections;
using System.Threading;
using WMS.Business;
using WMS.Business.Stock;
using WMS.Business.Base;
namespace WMS.FrmStock
{
public partial class FrmStockAdjust : FormBase
{
#region
//库存调整单实体
public AdjustListModel adListmodel = new AdjustListModel();
//库存调整单实体集合
public List<AdjustListModel> list = new List<AdjustListModel>();
//库存调整单明细实体
public AdjustListInfoModel adListInfomodel = new AdjustListInfoModel();
//库存调整单明细实体集合
public List<AdjustListInfoModel> list_info = new List<AdjustListInfoModel>();
//gridview焦点行
public int rowFocus = 0;
////选择的盘点单
//private CountingModel countModel = new CountingModel();
/// <summary>
/// 盘点单据
/// </summary>
public string pdsheet = string.Empty;
private bool importing = false;
//操作标志 0 新增1 修改
int flg = 0;
#endregion
public FrmStockAdjust()
{
InitializeComponent();
}
public void FrmStockAdjust_Load(object sender, EventArgs e)
{
ctrDicCountid.IsSqlWhere = true;
ctrDicCountid.selSql = "select a.COUNT_ID,b.NAME COUNT_MAN_NAME,a.COUNT_DATE FROM T_STOCK_COUNTING a LEFT JOIN T_BASE_USERINFO b ON a.COUNT_MAN =b.USER_ID where a.COUNT_STATUS = '4' and a.COUNT_BACK = '1'";
FrmSelectModle = new AdjustListModel();
//选择当前用户有权限的仓库
//ctr_MIStock.IsSqlWhere = true;
//ctr_MIStock.SqlStr = " where STORAGE_ID in(select STORAGE_ID from T_BASE_STORAGE_ROLE where ROLE_ID = '" + userData.ROLE_ID + "')";
////选择当前用户有权限仓库的盘点单
//ctrDicCountid.IsSqlWhere = true;
//ctrDicCountid.SqlStr = " where STO_ID in(select STORAGE_ID from T_BASE_STORAGE_ROLE where ROLE_ID = '" + userData.ROLE_ID + "')";
////与当前登陆人同部门的用户
//ctr_CreatPeople.IsSqlWhere = true;
//ctr_CreatPeople.SqlStr = " where COM_ID = '" + userData.COM_ID + "'";
ctr_CreatPeople.TextBoxFlag = userData.USER_ID;
ctr_CreatPeople.TextBoxValue = userData.NAME;
BindAdList();
}
#region
/// <summary>
/// 通用查询
/// </summary>
/// <param name="table"></param>
public override void LoadListData(DataTable table)
{
list = ConvertHelper<AdjustListModel>.ConvertToList(table);
bs_StAdjustList.DataSource = list;
gr_adjustInfo.DataSource = list;
gridView2.RefreshData();
}
#endregion
#region
#region
/// <summary>
/// 绑定通知单数据
/// </summary>
public void BindAdList()
{
LoadForm load = new LoadForm();
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 10);
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("数据加载中...");
ChargeEnable();
BindLepReason();
//xtraTabControl1.TabPages[1].PageEnabled = false;
new Thread(delegate()
{
List<AdjustListModel> list = new List<AdjustListModel>();
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = true;
}
try
{
this.Invoke(new MethodInvoker(delegate()
{
//string sql ="";
list = IBussFactory<BussAdjustList>.Instance().GetAdjustList(adListmodel);
if(list!=null)
{
bs_StAdjustList.DataSource = list;
}
gr_StAdjustList_Click(null, null);
if (list.Count == 0)
{
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = false;
}
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
return;
}
else
{
if (list.Count > 0)
{
adListmodel = list[0];
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = true;
}
}
BindAdListInfo();
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
}));
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("连接出现错误!");
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
return;
}
}).Start();
}
#endregion
#region
/// <summary>
/// 绑定库存调整单明细
/// </summary>
/// <param name="listModel"></param>
public void BindAdListInfo()
{
if (adListmodel != null)
{
AdjustListInfoModel info = new AdjustListInfoModel();
info.LIST_ID = adListmodel.List_id;
List<AdjustListInfoModel> list = IBussFactory<BussAdjustListInfo>.Instance().GetAdjustList(info);
if (list != null)
{
bs_StAdjustList_Info.DataSource = list;
// gr_adjustInfo.DataSource = list;
list_info = list;
bg_Adjust.DataSource = adListmodel;
gridView2.RefreshData();
}
}
}
#endregion
#region
/// <summary>
/// 0 盘点生成 1 手动新增 2 其它原因 默认盘点生成
/// </summary>
public void BindLepReason()
{
DataTable dt_lep = new DataTable();
dt_lep.Columns.Add("编号", typeof(string));
dt_lep.Columns.Add("原因", typeof(string));
dt_lep.Rows.Add("0", "盘点生成");
dt_lep.Rows.Add("1", "手动新增");
dt_lep.Rows.Add("2", "其它原因");
dt_lep.Rows.Add("3", "期初调整");
dt_lep.AcceptChanges();
lep_Reason.Properties.DataSource = dt_lep;
lep_Reason.Properties.DisplayMember = "原因";
lep_Reason.Properties.ValueMember = "编号";
lep_Reason.SelectedText = "盘点生成";
}
#endregion
#endregion
#region
#region
/// <summary>
/// 处理库存调整单状态 状态 0 未确认 已确认 2 已审核 3 作废
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gv_StAdjustList_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Value == null)
{
return;
}
if (e.Column.FieldName == "Status")
{
if (!string.IsNullOrEmpty(e.Value.ToString()))
{
switch (e.Value.ToString())
{
case "0":
e.DisplayText = "未确认";
break;
case "1":
e.DisplayText = "已确认";
break;
case "2":
e.DisplayText = "已审核";
break;
case "3":
e.DisplayText = "作废";
break;
default:
break;
}
}
}
if (e.Column.FieldName == "List_reason")
{
if (!string.IsNullOrEmpty(e.Value.ToString()))
{
switch (e.Value.ToString())
{
case "0":
e.DisplayText = "盘点生成";
break;
case "1":
e.DisplayText = "手动增加";
break;
case "2":
e.DisplayText = "其它原因";
break;
default:
break;
}
}
}
if ((e.Column.FieldName == "List_date") && (e.Value.ToString() == "0001/1/1 0:00:00"))
{
e.DisplayText = "";
}
if ((e.Column.FieldName == "List_checkdate") && (e.Value.ToString() == "0001/1/1 0:00:00"))
{
e.DisplayText = "";
}
if ((e.Column.FieldName == "List_confirmdate") && (e.Value.ToString() == "0001/1/1 0:00:00"))
{
e.DisplayText = "";
}
}
#endregion
#region
/// <summary>
/// 获得当前选中实体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView2_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
//if (gridView1.DataSource == null)
//{
// return;
//}
//if (frmButtonItem.ContainsKey("Select"))
//{
// frmButtonItem["Select"].Enabled = false;
//}
//adListInfomodel = gridView2.GetRow(gridView2.FocusedRowHandle) as AdjustListInfoModel;
}
#endregion
#region
/// <summary>
/// 调整单获得选中实体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
if (gridView1.DataSource == null)
{
return;
}
if (gridView1.FocusedRowHandle < 0)
{
return;
}
adListmodel = gridView1.GetRow(gridView1.FocusedRowHandle) as AdjustListModel;
if (adListmodel.Status == "0")
{
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = true;
}
}
else if (adListmodel.Status == "1")
{
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = false;
}
}
else
{
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Edit"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Del"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Confirm"].Enabled = false;
}
}
}
#endregion
#region GridView单击事件
/// <summary>
/// 单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gr_StAdjustList_Click(object sender, EventArgs e)
{
if (gridView1.DataSource == null)
{
return;
}
if (gridView1.RowCount == 0)
{
return;
}
//adListmodel = gridView1.GetRow(gridView1.FocusedRowHandle) as AdjustListModel;
//if (adListmodel.Status != "2")
//{
// frmButtonItem["Check"].Enabled = true;
// frmButtonItem["Edit"].Enabled = true;
// frmButtonItem["Invalid"].Enabled = true;
// frmButtonItem["Del"].Enabled = true;
//}
//else
//{
// frmButtonItem["Check"].Enabled = false;
// frmButtonItem["Edit"].Enabled = false;
// frmButtonItem["Invalid"].Enabled = false;
// frmButtonItem["Del"].Enabled = false;
//}
}
#endregion
#region GridView双击
/// <summary>
/// 双击查看明细
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gr_StAdjustList_DoubleClick(object sender, EventArgs e)
{
if (gridView1.RowCount == 0)
{
return;
}
if (gridView1.DataSource == null)
{
return;
}
spEdit.Panel1.Enabled = false;
xtraTabControl1.TabPages[1].PageEnabled = true;
adListmodel = new AdjustListModel();
adListmodel = gridView1.GetRow(gridView1.FocusedRowHandle) as AdjustListModel;
colLIST_INFO_COUNT1.OptionsColumn.AllowEdit = false;
ctr_MIStock.TextBoxValue = adListmodel.Storage_name;
ctr_MIStock.TextBoxFlag = adListmodel.Storage_id;
ctr_CreatPeople.TextBoxValue = adListmodel.List_createperName;
ctr_CreatPeople.TextBoxFlag = adListmodel.List_createper;
de_CREATE_DATE.DateTime = adListmodel.List_createdate;
BindAdListInfo();
xtraTabControl1.SelectedTabPageIndex = 1;
}
#endregion
#region
/// <summary>
/// 控件可用状态
/// </summary>
public void ChargeEnable()
{
if (adListmodel != null && adListmodel.Status != "")
{
if (adListmodel.Status == "0")
{
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
} if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = true;
}
}
else if (adListmodel.Status == "1")
{
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
}
else
{
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
}
}
}
#endregion
#region
#region 
/// <summary>
/// 删除按钮
/// </summary>
public void Del()
{
if (xtraTabControl1.SelectedTabPageIndex == 1)
{
if (frmButtonItem.ContainsKey("Del"))
{
if (frmButtonItem["Del"].Enabled)
{
if (gridView2.RowCount > 0)
{
gridView2.DeleteSelectedRows();
}
}
}
}
else
{
string errText = "";
try
{
errText = IBussFactory<BussAdjustList>.Instance().DelList(adListmodel);
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
}
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("删除成功");
Refresh();
ChargeEnable();
}
}
}
#endregion
#region
/// <summary>
/// 新增按钮
/// </summary>
public override void Add()
{
LoadForm load = new LoadForm();
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 10);
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在处理...");
flg = 0;
xtraTabControl1.TabPages[1].PageEnabled = true;
spEdit.Panel1.Enabled = true;
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = true;
}
xtraTabControl1.SelectedTabPageIndex = 1;
ctr_MIStock.TextBoxValue = "";
ctr_MIStock.TextBoxFlag = "";
// 清空现有商品
// list_info = new List<AdjustListInfoModel>();
if (list_info != null)
{
if (list_info.Count > 0)
{
list_info.Clear();
bs_StAdjustList_Info.DataSource = list_info;
// gr_adjustInfo.DataSource = list_info;
gridView2.RefreshData();
}
adListmodel = new AdjustListModel();
bg_Adjust.DataSource = adListmodel;
ctr_MIStock.TextBoxValue = userData.STORAGE_NAME;
ctr_MIStock.TextBoxFlag = userData.STORAGE_ID;
adListmodel.Storage_id = userData.STORAGE_ID;
colLIST_INFO_COUNT1.OptionsColumn.AllowEdit = true;
txt_remark.Enabled = true;
txt_remark.Text = "";
lep_Reason.EditValue = "0";
ctr_CreatPeople.TextBoxFlag = userData.USER_ID;
ctr_CreatPeople.TextBoxValue = userData.NAME;
de_CREATE_DATE.DateTime = System.DateTime.Now;
}
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
}
#endregion
#region
/// <summary>
/// 选择商品
/// </summary>
public void Select()
{
if (ctr_MIStock.SelectTable.Rows.Count == 0 && ctr_MIStock.TextBoxValue == "")
{
SystemCommon.ShowInfoMessageBox("请选择仓库!");
ctr_MIStock.Focus();
return;
}
if (list_info == null)
{
return;
}
adListmodel.Storage_id = ctr_MIStock.TextBoxFlag;
//if (ctr_MIStock.TextBoxValue == "")
//{
// DataTable dt_select = ctr_MIStock.SelectTable;
// this.miatid = dt_select.Rows[0]["STORAGE_ID"].ToString();
//}
//else
//{
//miatid = ctr_MIStock.TextBoxFlag;
//}
// ctrlDicGoods.t_dictonary_ButtonClick(null, null);
mis_list = new List<MIStockModel>();
//list<MIStockModel> list =
FrmGoodsSelect f_g_select = new FrmGoodsSelect(adListmodel.Storage_id);
f_g_select.ShowDialog();
mis_list = f_g_select.miStockModelList;
if (mis_list.Count <= 0 && list_info.Count <= 0)
{
SystemCommon.ShowInfoMessageBox("请选择商品!");
return;
}
//库存集合转化为调整单明细
foreach (MIStockModel model in mis_list)
{
if (list_info.Find(r => r.LIST_INFO_GOODSID == model.GOODS_ID && r.Area_id == model.AREA_ID && r.LOC_ID == model.LOCATION_ID) != null)
{
continue;
}
adListInfomodel = new AdjustListInfoModel();
adListInfomodel.LIST_ID = adListmodel.List_id;
adListInfomodel.LIST_INFO_COUNT = 0;
adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
adListInfomodel.LOC_ID = model.LOCATION_ID;
adListInfomodel.Oldcount = model.SHELVES_NUM;
adListInfomodel.NEWCOUNT = model.SHELVES_NUM;
adListInfomodel.GOODS_NAME = model.GOODS_NAME;
adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
adListInfomodel.Area_id = model.AREA_ID;
adListInfomodel.Area_name = model.AREA_NAME;
adListInfomodel.Production_date = model.PRODUCTION_DATE;
adListInfomodel.Storage_id = model.STORAGE_ID;
adListInfomodel.Storage_name = model.STORAGE_NAME;
adListInfomodel.Goods_typeid = model.GOODS_TYPEID;
list_info.Add(adListInfomodel);
}
//移除商品和清空商品控件可用
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = true;
}
bs_StAdjustList_Info.DataSource = list_info;
gridView2.RefreshData();
}
#endregion
#region
/// <summary>
/// 移除商品
/// </summary>
public void Move()
{
if (gridView2.SelectedRowsCount > 0)
{
if (DialogResult.OK == SystemCommon.ShowMessageBoxResult("确定删除所选商品"))
{
AdjustListInfoModel model = new AdjustListInfoModel();
model = gridView2.GetFocusedRow() as AdjustListInfoModel;
list_info.Remove(model);
bs_StAdjustList_Info.DataSource = list_info;
gridView2.RefreshData();
}
}
else
{
SystemCommon.ShowInfoMessageBox("您未选择商品!");
}
}
#endregion
#region
/// <summary>
/// 清空商品
/// </summary>
public void Clear()
{
list_info = bs_StAdjustList_Info.DataSource as List<AdjustListInfoModel>;
if (list_info.Count > 0)
{
if (SystemCommon.ShowMessageBoxResult("确定删除") == DialogResult.OK)
{
list_info.Clear();
bs_StAdjustList_Info.DataSource = list_info;
gridView2.RefreshData();
}
}
else
{
SystemCommon.ShowInfoMessageBox("您未选择商品!");
}
}
#endregion
#region
/// <summary>
/// 单据提交
/// </summary>
public void Confirm()
{
if (adListmodel != null)
{
if (SystemCommon.ShowMessageBoxResultCancel("确定订单要提交") == System.Windows.Forms.DialogResult.No)
{
return;
}
//LoadForm load = new LoadForm();
//DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 10);
//DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在提交...");
adListmodel.Status = "1";
adListmodel.List_confirmper = userData.USER_ID;
adListmodel.List_confirmdate = System.DateTime.Now.Date;
string errText = "";
try
{
errText = IBussFactory<BussAdjustList>.Instance().ExecInsertUpdate(adListmodel, 1);
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("订单提交成功,需要订单审核!");
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = true ;
}
if (xtraTabControl1.SelectedTabPageIndex == 0)
{
adListmodel = new AdjustListModel();
BindAdList();
ChargeEnable();
}
else
{
spEdit.Enabled = false;
}
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
// DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
}
}
#endregion
#region
/// <summary>
/// 审核
/// </summary>
public void Check()
{
#region $$
//DateTime dt_now = System.DateTime.Now.Date;
////获得库存调整单明细
//string str = Newtonsoft.Json.JsonConvert.SerializeObject(adListmodel);
//List<AdjustListInfoModel> list = new List<AdjustListInfoModel>();
//try
//{
// string str_li = WebLockConfig.Instance.AdjustListInfo.GetAdjustList(str);
// list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AdjustListInfoModel>>(str_li);
//}
//catch (Exception ex)
//{
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
// return;
//}
////库存实体、库位实体、商品实体
//MIStockModel stoc = new MIStockModel();
//StorageAreaLocationModel stoc_loc = new StorageAreaLocationModel();
//JWGoodsInfoModel goods = new JWGoodsInfoModel();
//foreach (AdjustListInfoModel _ad_info in list)
//{
// if (_ad_info.LIST_INFO_COUNT == 0)
// {
// continue;
// }
// stoc = new MIStockModel();
// stoc.STORAGE_ID = _ad_info.Storage_id;
// stoc.AREA_ID = _ad_info.Area_id;
// stoc.LOCATION_ID = _ad_info.LOC_ID;
// stoc.GOODS_ID = _ad_info.LIST_INFO_GOODSID;
// stoc.SHELVES_NUM = _ad_info.NEWCOUNT;
// try
// {
// //操作库存
// string str_stoc = Newtonsoft.Json.JsonConvert.SerializeObject(stoc);
// string result = WebLockConfig.Instance.WebMIStock.UpdateMIStockAndTab(str_stoc);
// }
// catch (Exception ex)
// {
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
// return;
// }
// //插入库存日志、修改库位占用体积
// MIStockBackModel back_model = new MIStockBackModel();
// back_model.STOCK_ID = stoc.STOCK_ID;
// back_model.STORAGE_ID = _ad_info.Storage_id;
// back_model.AREA_ID = _ad_info.Area_id;
// back_model.LOCATION_ID = _ad_info.LOC_ID;
// back_model.GOODS_TYPEID = _ad_info.Goods_typeid;
// back_model.GOODS_ID = _ad_info.LIST_INFO_GOODSID;
// back_model.ORI_NUM = _ad_info.Oldcount;
// back_model.CHANGE_NUM = _ad_info.NEWCOUNT;//改变后数量
// back_model.GOODS_NUM = _ad_info.LIST_INFO_COUNT;
// back_model.OPERATOR_DATE = dt_now;
// back_model.OPERATOR_MAN = userData.USER_ID;
// back_model.PRODUCTION_DATE = _ad_info.Production_date;
// back_model.OPERATOR_TYPE = "2";//库存调整
// back_model.REMARK = "库存调整";
// try
// {
// back_model.ID = WebLockConfig.Instance.MIStockBack.execGetSerialNum();
// string str_bak = Newtonsoft.Json.JsonConvert.SerializeObject(back_model);
// string errText = WebLockConfig.Instance.MIStockBack.execMIStockBackAdd(str_bak);
// }
// catch (Exception ex)
// {
// SystemCommon.ShowInfoMessageBox("操作失败,网络连接错误!");
// return;
// }
// #region 修改库位占用体积
// //try
// //{
// // //修改库位占用体积
// // goods = new JWGoodsInfoModel();
// // string str_list_goods = WebLockConfig.Instance.Goods.GetGoodsList(_ad_info.LIST_INFO_GOODSID, "", "", "");
// // goods = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JWGoodsInfoModel>>(str_list_goods)[0];
// // decimal voluPer = goods.GVOLUME;
// // stoc_loc = new StorageAreaLocationModel();
// // stoc_loc.STORAGE_AREA_ID = _ad_info.Area_id;
// // stoc_loc.STORAGE_ID = _ad_info.Storage_id;
// // stoc_loc.LOCATION_ID = _ad_info.LOC_ID;
// // stoc_loc.HASVOLUME = voluPer * _ad_info.NEWCOUNT;
// // stoc_loc.OPERATEDATE = System.DateTime.Now.Date;
// // stoc_loc.OPERATORID = userData.USER_ID;
// // string str_stoc_loc = Newtonsoft.Json.JsonConvert.SerializeObject(stoc_loc);
// // int i = 1;
// // string j = string.Empty;
// // string str_err = WebLockConfig.Instance.StorageAreaLocation.InsOrUpdLocationInfo(str_stoc_loc, ref i, 0, 0, "", ref j);
// // i = 1;
// //}
// //catch (Exception ex)
// //{
// // SystemCommon.ShowInfoMessageBox("出现错误!");
// // return;
// //}
// #endregion
//}
//adListmodel.Status = "2";
//adListmodel.List_checkper = userData.USER_ID;
//adListmodel.List_checkdate = dt_now;
//string errText2 = "";
//try
//{
// string _str = Newtonsoft.Json.JsonConvert.SerializeObject(adListmodel);
// errText2 = WebLockConfig.Instance.AdjustList.ExecInsertUpdate(_str, 1);
//}
//catch (Exception ex)
//{
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
// return;
//}
//if (errText2 == "")
//{
// SystemCommon.ShowInfoMessageBox("操作成功!");
// adListmodel = new AdjustListModel();
// BindAdList();
// xtraTabControl1.SelectedTabPageIndex = 0;
// if (frmButtonItem.ContainsKey("Add"))
// {
// frmButtonItem["Add"].Enabled = true;
// }
// if (frmButtonItem.ContainsKey("Save"))
// {
// frmButtonItem["Save"].Enabled = false;
// }
// ChargeEnable();
//}
//else
//{
// SystemCommon.ShowInfoMessageBox("操作失败!");
//}
#endregion
if (adListmodel == null)
{
return;
}
if (DialogResult.OK == SystemCommon.ShowMessageBoxResult("确定审核单据编号为 " + adListmodel.List_id + " 的库存调整单"))
{
string userID = userData.USER_ID;
string errText = "";
try
{
errText = IBussFactory<BussAdjustList>.Instance().Check(adListmodel, userID);
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接出现错误!");
return;
}
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("操作成功!");
frmButtonItem["Check"].Enabled = false;
xtraTabControl1.SelectedTabPageIndex = 0;
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
}
}
#endregion
#region
/// <summary>
/// 刷新
/// </summary>
public override void Refresh()
{
//if (frmButtonItem.ContainsKey("Select"))
//{
// frmButtonItem["Select"].Enabled = false;
//}
//adListmodel = new AdjustListModel();
//BindAdList();
//ChargeEnable();
//xtraTabControl1.SelectedTabPageIndex = 0;
Cancel();
xtraTabControl1.SelectedTabPageIndex = 0;
}
#endregion
#region
/// <summary>
/// 编辑
/// </summary>
public override void Edit()
{
if (adListmodel.List_reason == "0" || adListmodel.List_reason == "3")
{//只有主动新增和其它原因可以编辑
return;
}
spEdit.Panel1.Enabled = true;
xtraTabControl1.TabPages[1].PageEnabled = true;
flg = 1;
rowFocus = gridView1.FocusedRowHandle;
colLIST_INFO_COUNT1.OptionsColumn.AllowEdit = true;
colLIST_INFO_COUNT1.OptionsColumn.AllowEdit = true;
txt_remark.Enabled = true;
colLIST_INFO_COUNT1.OptionsColumn.AllowEdit = true;
adListmodel = new AdjustListModel();
adListmodel = gridView1.GetRow(gridView1.FocusedRowHandle) as AdjustListModel;
ctr_MIStock.TextBoxValue = adListmodel.Storage_name;
ctr_MIStock.TextBoxFlag = adListmodel.Storage_id;
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Invalid"))
{
frmButtonItem["Invalid"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = true;
}
lep_Reason.Enabled = false;
BindAdListInfo();
xtraTabControl1.SelectedTabPageIndex = 1;
txt_remark.Text = adListmodel.Remark;
lep_Reason.EditValue = adListmodel.List_reason;
}
#endregion
#region
/// <summary>
/// 作废
/// </summary>
public void Invalid()
{
string errText = "";
adListmodel.Status = "3";
try
{
errText = IBussFactory<BussAdjustList>.Instance().ExecInsertUpdate(adListmodel, 1);
}
catch
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("操作成功!");
adListmodel = new AdjustListModel();
BindAdList();
}
else
SystemCommon.ShowInfoMessageBox("操作失败!");
}
#endregion
List<MIStockModel> li_mistock = new List<MIStockModel>();
List<MIStockBackModel> li_stockback = new List<MIStockBackModel>();
MIStockBackModel sto_back = new MIStockBackModel();
MIStockModel sto = new MIStockModel();
#region
/// <summary>
/// 保存
/// </summary>
public override void Save()
{
#region
if (lep_Reason.Text == "期初调整")
{
List<AdjustListInfoModel> li_adjInfo = bs_StAdjustList_Info.DataSource as List<AdjustListInfoModel>;
if (li_adjInfo.Count > 0)
{
li_mistock = new List<MIStockModel>();
DateTime dt_no = System.DateTime.Now;
string USERID = userData.USER_ID;
li_adjInfo.ForEach(r =>
{
#region
sto = new MIStockModel();
sto.AREA_ID = r.Area_id;
sto.AREA_NAME = r.Area_name;
sto.STORAGE_ID = r.Storage_id;
sto.STORAGE_NAME = r.Storage_name;
sto.SHELVES_NUM = r.LIST_INFO_COUNT;
sto.GOODS_ID = r.LIST_INFO_GOODSID;
sto.GOODS_TYPEID = r.Goods_typeid;
sto.LOCATION_ID = r.LOC_ID;
sto.WARE_DATE = dt_no;
li_mistock.Add(sto);
#endregion
#region
sto_back = new MIStockBackModel();
sto_back.REMARK = "期初调整";
sto_back.GOODS_NUM = r.LIST_INFO_COUNT;
sto_back.GOODS_ID = r.LIST_INFO_GOODSID;
sto_back.GOODS_TYPEID = r.Goods_typeid;
sto_back.LOCATION_ID = r.LOC_ID;
sto_back.STORAGE_ID = r.Storage_id;
sto_back.AREA_ID = r.Area_id;
sto_back.OPERATOR_DATE = dt_no;
sto_back.OPERATOR_MAN = USERID;
#endregion
li_stockback.Add(sto_back);
});
string errtext = "";
int i = 0;
string str = IBussFactory<BussMIStock>.Instance().AddMIStockList(li_mistock);
if (str == "[]" || string.IsNullOrEmpty(str))
{
SystemCommon.ShowInfoMessageBox("操作成功!");
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
return;
}
}
#endregion
if (flg == 0)
{
#region
txt_ListID.Focus();
gridView2.CloseEditor();
bs_StAdjustList_Info.EndEdit();
list_info = bs_StAdjustList_Info.DataSource as List<AdjustListInfoModel>;
if (list_info == null)
{
SystemCommon.ShowInfoMessageBox("请选择商品!");
return;
}
if (list_info.Count <= 0)
{
SystemCommon.ShowInfoMessageBox("请选择商品!");
return;
}
//查询调整明细里是否有调整数量为0的商品
int cou = list_info.FindAll(r => r.LIST_INFO_COUNT.ToString().StartsWith("0")).Count;
if (cou > 0)
{
string goodsName = list_info.FindAll(r => r.LIST_INFO_COUNT.ToString().StartsWith("0"))[0].GOODS_NAME;
SystemCommon.ShowInfoMessageBox("商品:" + goodsName + "调整数量为0请重新输入");
return;
}
//新增单据以及明细 添加主表
// adListmodel = new AdjustListModel();
adListmodel.Storage_id = ctr_MIStock.TextBoxFlag;
//adListmodel.Storage_name =
// adListmodel.List_id = txt_ListID.Text;
adListmodel.Status = "0";
adListmodel.List_reason = lep_Reason.ItemIndex.ToString();
// adListmodel.List_id = txt_ListID.Text;
adListmodel.List_createdate = System.DateTime.Now.Date;
adListmodel.List_createper = ctr_CreatPeople.TextBoxFlag;
adListmodel.Operatedate = System.DateTime.Now.Date;
adListmodel.Operatorid = userData.USER_ID;
adListmodel.Remark = txt_remark.Text;
adListmodel.Count_id = ctrDicCountid.TextBoxFlag;
//获取流水号
string errText = "";
string listId = string.Empty;
try
{
errText = IBussFactory<BussAdjustList>.Instance().InsertUpdate(adListmodel, list_info, 0,ref listId);
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
if (errText == "")
{
foreach (AdjustListInfoModel list in list_info)
{
list.LIST_ID = listId;
}
adListmodel.List_id = listId;
txt_ListID.Text = listId;
SystemCommon.ShowInfoMessageBox("操作成功!");
// xtraTabControl1.SelectedTabPageIndex = 0;
txt_remark.Enabled = true;
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Confirm"))
{
frmButtonItem["Confirm"].Enabled = true;
}
//移除商品和清空商品控件不可用
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Check"))
{
frmButtonItem["Check"].Enabled = false;
}
spEdit.Enabled = false;
//if (xtraTabControl1.TabIndex == 0)
//{
// adListmodel = new AdjustListModel();
// BindAdList();
// ChargeEnable();
//}
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
#endregion
}
else if (flg == 1)
{
#region
txt_ListID.Focus();
gridView2.CloseEditor();
bs_StAdjustList_Info.EndEdit();
list_info = bs_StAdjustList_Info.DataSource as List<AdjustListInfoModel>;
if (list_info.Count <= 0)
{
SystemCommon.ShowInfoMessageBox("请选择商品!");
return;
}
//查询调整明细里是否有调整数量为0的商品
int cou = list_info.FindAll(r => r.LIST_INFO_COUNT.ToString().StartsWith("0")).Count;
if (cou > 0)
{
string goodsName = list_info.FindAll(r => r.LIST_INFO_COUNT.ToString().StartsWith("0"))[0].GOODS_NAME;
SystemCommon.ShowInfoMessageBox("商品:" + goodsName + "调整数量为0请重新输入");
return;
}
txt_ListID.Focus();
gridView2.CloseEditor();
bs_StAdjustList_Info.EndEdit();
string errText = "";
adListmodel.Remark = txt_remark.Text;
adListmodel.List_reason = lep_Reason.EditValue.ToString();
adListmodel.Operatorid = userData.USER_ID;
adListmodel.Operatedate = System.DateTime.Now.Date;
adListmodel.Storage_id = ctr_MIStock.TextBoxFlag;
adListmodel.Storage_name = ctr_MIStock.TextBoxValue;
list_info = bs_StAdjustList_Info.DataSource as List<AdjustListInfoModel>;
string listId = string.Empty;
try
{
errText = IBussFactory<BussAdjustList>.Instance().InsertUpdate(adListmodel, list_info, 1, ref listId);
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("操作成功!");
txt_remark.Enabled = false;
lep_Reason.Enabled = false;
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = false;
}
//选择商品、移除商品和清空商品控件不可用
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = false;
}
// xtraTabControl1.SelectedTabPageIndex = 0;
Refresh();
ChargeEnable();
gridView1.FocusedRowHandle = rowFocus;
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
#endregion
}
}
#endregion
#region
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
if (frmButtonItem.ContainsKey("Cancel"))
{
frmButtonItem["Cancel"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = false;
}
txt_remark.Enabled = false;
adListmodel = new AdjustListModel();
BindAdList();
BindAdListInfo();
xtraTabControl1.SelectedTabPageIndex = 0;
}
#endregion
/// <summary>
/// 导入明细
/// </summary>
public void Import()
{
list_info = new List<AdjustListInfoModel>();
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Title = "导入调整明细资料";
fileDialog.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx";
DialogResult dialogResult = fileDialog.ShowDialog(this);
if (dialogResult == DialogResult.OK)
{
//LoadForm load = new LoadForm();
//DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 50);
//DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在加载数据,请稍等....");
Hashtable ht = new Hashtable();
ht.Add("LIST_INFO_GOODSID", "商品代码");
ht.Add("GOODS_NAME", "商品名称");
// ht.Add("LIST_ID", "库存调整单编号");
ht.Add("Storage_id", "仓库");
ht.Add("Storage_name", "仓库ISNAME");
ht.Add("Area_id", "库区");
ht.Add("Area_name", "库区ISNAME");
ht.Add("LOC_ID", "库位");
ht.Add("LIST_INFO_COUNT", "调整数量");
//ht.Add("NEWCOUNT", "调整后数量");
//ht.Add("Oldcount", "当前数量");
//ht.Add("OPERATORID", "操作人");
////ht.Add("OPERATEDATE", "操作时间");
//ht.Add("REMARK", "备注");
//ht.Add("VERSION", "版本号");
List<AdjustListInfoModel> tempList = NPOIHelper<AdjustListInfoModel>.Import(fileDialog, ht);
if (tempList == null || tempList.Count == 0) { return; }
foreach (var item in tempList)
{
item.NEWCOUNT = item.Oldcount + item.LIST_INFO_COUNT;
}
if (list_info.Count > 0)
{
list_info.AddRange(tempList);
}
else
{
list_info = tempList;
}
foreach (AdjustListInfoModel ss in list_info)
{
ss.LIST_ID = this.txt_ListID.Text;
}
bs_StAdjustList_Info.DataSource = list_info;
gr_adjustInfo.DataSource = list_info;
bs_StAdjustList_Info.ResetBindings(true);
gridView2.RefreshData();
gr_adjustInfo.Refresh();
lep_Reason.EditValue = "3";
}
}
/// <summary>
/// 保存导入
/// </summary>
public void SaveImport()
{
////将list存入数据库
//if (list != null && list.Count > 0)
//{
// string errText = string.Empty;
// string strList = Newtonsoft.Json.JsonConvert.SerializeObject(list);
// List<int> errorIndex = new List<int>();
// int hadNum = 0;
// int lengthNum = 0;
// string error = string.Empty;
// try
// {
// errorIndex = Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(WebLockConfig.Instance.Goods.AddGoodsInfoList(strList, ref errText, ref hadNum, ref lengthNum, ref error, fuGaiSave));
// }
// catch (Exception)
// {
// SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
// fuGaiSave = false;
// return;
// }
// fuGaiSave = false;
// if (errorIndex.Count == 0)
// {
// SystemCommon.ShowInfoMessageBox("所有记录已保存成功");
// Refresh();
// }
// else
// {
// List<JWGoodsInfoModel> goods = new List<JWGoodsInfoModel>();
// for (int i = errorIndex.Count - 1; i >= 0; i--)
// {
// goods.Add(list[i]);
// }
// list_info = goods;
// JWGoodsInfoModelBindingSource.DataSource = list;
// GvGoods.RefreshData();
// string fileName = @"D:\WMS\保存导入商品错误日志" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
// SystemCommon.WriteFile(fileName, error);///写文件
// /*错误提示*/
// string info = string.Empty;
// if (errorIndex.Count > (hadNum + lengthNum))
// {
// info += ((errorIndex.Count - hadNum - lengthNum) + "个商品导入时遇到未知错误,");
// }
// if (hadNum > 0)
// {
// info += (hadNum + "个商品编号已存在,");
// }
// if (lengthNum > 0)
// {
// info += (lengthNum + "条商品记录数据长度过长,");
// }
// info += "日志已写入" + fileName + ",未出错记录已写入数据库并从窗体中移除。";
// SystemCommon.ShowErrorMessageBox(info);
// }
//}
//else
//{
// SystemCommon.ShowErrorMessageBox("没有等待保存的导入数据,请刷新页面");
//}
}
#endregion
#endregion
#region
#region
/// <summary>
/// gridview输入调整数量计算
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gv_StAdjustList_Info_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (e.Column.Name == "colLIST_INFO_COUNT1")
{
if (gridView2.FocusedRowHandle < 0)
{
return;
}
adListInfomodel = gridView2.GetFocusedRow() as AdjustListInfoModel;
if (adListInfomodel == null || string.IsNullOrEmpty(adListInfomodel.LIST_INFO_GOODSID))
{
return;
}
decimal info_count = 0;
decimal oldcount = 0;
try
{
oldcount = Convert.ToDecimal(gridView2.GetFocusedRowCellValue("Oldcount"));
info_count = Convert.ToDecimal(gridView2.GetFocusedRowCellValue("LIST_INFO_COUNT"));
//if (Convert.ToInt32(info_count) == 0)
//{
// SystemCommon.ShowInfoMessageBox("数量不能为0");
// gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNEWCOUNT1, oldcount);
// return;
//}
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("请输入数字!");
return;
}
decimal newcount = oldcount + info_count;
if (newcount <= 0)
{
SystemCommon.ShowInfoMessageBox("调整后数量为负数!请重新输入调整数量!");
gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colLIST_INFO_COUNT1, 0);
return;
}
//if (!ChargeLoc(adListInfomodel))
//{
// gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colLIST_INFO_COUNT1, 0);
// SystemCommon.ShowInfoMessageBox("当前商品体积已经超过该库位体积!");
// return;
//}
adListInfomodel.NEWCOUNT = newcount;
ChargeLoc(adListInfomodel);//判断库位容积和商品体积
gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNEWCOUNT, newcount);
}
}
#endregion
#region
/// <summary>
/// 判断库位容积
/// </summary>
/// <param name="mode">库位能放得下返回 true, 库位放不下这么多商品 返回 false</param>
/// <returns></returns>
public void ChargeLoc(AdjustListInfoModel mode)
{
if (gridView2.GetFocusedRowCellValue(colLIST_INFO_COUNT1).ToString() == "0")
{
return;
}
bool bol = false;
//查询该明细商品的单位体积
decimal perVolu = 0;
decimal allVolu = 0;
decimal locVolu = 0;
//List< JWGoodsInfoModel> goods = IBussFactory<BussGoods>.Instance().GetGoodsList(mode.LIST_INFO_GOODSID, "", "", "");
// if (goods != null)
// {
// if(goods.Count>0)
// {
// perVolu = goods[0].GVOLUME;
// //计算调整后的占用体积
// allVolu = mode.NEWCOUNT * perVolu;
// }
// }
//查询该明细库位的容积
StorageAreaLocationModel loc = new StorageAreaLocationModel();
loc.LOCATION_ID = mode.LOC_ID;
loc.STORAGE_ID = mode.Storage_id;
List<LocAreaModel> locAreaList = new List<LocAreaModel>();
try
{
List<StorageAreaLocationModel> str_list = IBussFactory<BussStorageAreaLocation>.Instance().GetLocationInfoDS(loc, ref locAreaList);
if (str_list != null)
{
if (str_list.Count > 0)
{
loc = str_list[0];
locVolu = loc.VOLUME;
}
else
{
SystemCommon.ShowInfoMessageBox("查询库位出现错误!");
return;
}
}
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
//比较
if (allVolu > locVolu)
{
SystemCommon.ShowInfoMessageBox("当前商品体积已经超过该库位体积!");
gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNEWCOUNT1, mode.Oldcount);
gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colLIST_INFO_COUNT1, 0);
return;
}
}
#endregion
#region
///// <summary>
///// 查询出库位名称
///// </summary>
///// <param name="locID">库位编号</param>
///// <returns></returns>
//public string GetLocName(string locID)
//{
// string locName = "";
// StorageAreaLocationModel stLoc = new StorageAreaLocationModel();
// stLoc.LOCATION_ID = locID;
// string str_mod = Newtonsoft.Json.JsonConvert.SerializeObject(stLoc);
// string errText = "";
// try
// {
// string str_list = WebLockConfig.Instance.StorageAreaLocation.GetLocationInfoDS(str_mod, ref errText);
// stLoc = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StorageAreaLocationModel>>(str_list)[0];
// locName = stLoc.LOCATION_NAME;
// }
// catch (Exception ex)
// {
// return "";
// }
// return locName;
//}
#endregion
#region
/// <summary>
/// 查询商品名称
/// </summary>
/// <param name="goodsID">商品编号</param>
/// <returns>商品名称</returns>
public string GetGoodsName(string goodsID)
{
string goodsName = "";
try
{
List<JWGoodsInfoModel> god = IBussFactory<BussGoods>.Instance().GetGoodsList(goodsID, "", "", "");
if (god != null)
{
//goodsName = god[0].GOODS_NAME;
}
}
catch (Exception ex)
{
return "";
}
return goodsName;
}
#endregion
#region
/// <summary>
/// 商品选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlDicGoods_Button_Click_1(object sender, EventArgs e)
{
//if (ctrlDicGoods.SelectTable.Rows.Count == 0)
//{
// SystemCommon.ShowInfoMessageBox("请选择商品!");
// return;
//}
////商品集合
//List<JWGoodsInfoModel> list = ConvertHelper<JWGoodsInfoModel>.ConvertToList(ctrlDicGoods.SelectTable);
////库存实体
//MIStockModel mistoc_model = new MIStockModel();
////库存实体集合
//List<MIStockModel> _list = new List<MIStockModel>();
//List<MIStockModel> temp_list = new List<MIStockModel>();
//foreach (JWGoodsInfoModel model in list)
//{
// mistoc_model.GOODS_ID = model.GOODS_ID;
// string str_miStockmodel = Newtonsoft.Json.JsonConvert.SerializeObject(mistoc_model);
// try
// {
// string errText = "";
// string str_Stocklist = WebLockConfig.Instance.WebMIStock.GetMIStockListStr(str_miStockmodel, ref errText);
// temp_list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MIStockModel>>(str_Stocklist);
// foreach (MIStockModel stoc_mo in temp_list)
// {
// _list.Add(stoc_mo);
// }
// }
// catch (Exception ex)
// {
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
// return;
// }
//}
//if (_list.Count > 0)
//{
// foreach (MIStockModel model in _list)
// {
// //当前集合中已经有的商品就过滤掉
// if (list_info.Find(r => r.LIST_INFO_GOODSID == model.GOODS_ID && r.LOC_ID == model.LOCATION_ID && r.Area_id == model.AREA_ID) != null)
// {
// continue;
// }
// adListInfomodel = new AdjustListInfoModel();
// adListInfomodel.LIST_ID = txt_ListID.Text;
// adListInfomodel.LIST_INFO_COUNT = 0;
// adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
// adListInfomodel.LOC_ID = model.LOCATION_ID;
// adListInfomodel.Oldcount = model.SHELVES_NUM;
// adListInfomodel.NEWCOUNT = model.SHELVES_NUM;
// adListInfomodel.LIST_INFO_COUNT = 0;
// adListInfomodel.GOODS_NAME = GetGoodsName(model.GOODS_ID);
// //adListInfomodel.Loc_name = GetLocName(model.LOCATION_ID);
// if (!list_info.Contains(adListInfomodel))
// {
// list_info.Add(adListInfomodel);
// }
// }
// bs_StAdjustList_Info.DataSource = list_info;
// gridView2.RefreshData();
//}
}
#endregion
#region
/// <summary>
/// 盘点单选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrDicCountid_Button_Click(object sender, EventArgs e)
{
DataTable dt = ctrDicCountid.SelectTable;
if (dt.Rows.Count <= 0)
{
//if (ctrlDicGoods.SelectTable.Rows.Count == 0)
//{
SystemCommon.ShowInfoMessageBox("请选择盘点单!");
return;
//}
}
if (dt.Rows.Count > 0)
{
list_info = new List<AdjustListInfoModel>();
adListmodel.List_reason = "0";
adListmodel.Count_id = dt.Rows[0]["count_id"].ToString();
list_info.Clear();
//根据所选择盘点单查处差异表,转移到调整单明细
//盘点单集合
List<CountingModel> list_count = ConvertHelper<CountingModel>.ConvertToList(dt);
//盘点单明细集合
List<CountingInfoModel> _lsit_info = new List<CountingInfoModel>();
//盘点单明细实体
CountingInfoModel info_model = new CountingInfoModel();
DateTime dt_now = System.DateTime.Now.Date;
string str_storeage = "";
string str_stoname = "";
try
{
CountingModel countModel = new CountingModel();
countModel.COUNT_ID = list_count[0].COUNT_ID;
string str_list = "";
List<CountingModel> list_cou = IBussFactory<BussCounting>.Instance().GetCountingList(countModel);
if (list_cou != null)
{
if (list_cou.Count > 0)
{
str_storeage = list_cou[0].STO_ID;
str_stoname = list_cou[0].STO_NAME;
ctr_MIStock.TextBoxFlag = str_storeage;
ctrDicCountid.TextBoxFlag = countModel.COUNT_ID;
}
}
info_model.COUNT_ID = list_count[0].COUNT_ID;
_lsit_info = IBussFactory<BussCountingInfo>.Instance().GetList(info_model);
if(_lsit_info!=null)
{
foreach (CountingInfoModel mod in _lsit_info)
{
if (mod.DIFF_NUM == 0)
{
continue;
}
adListInfomodel = new AdjustListInfoModel();
adListInfomodel.Storage_id = str_storeage;
adListInfomodel.Storage_name = str_stoname;
adListInfomodel.Area_id = mod.STO_AREA;
adListInfomodel.Area_name = mod.STO_AREA_NAME;
adListInfomodel.LIST_ID = txt_ListID.Text;
adListInfomodel.LIST_INFO_COUNT = mod.DIFF_NUM;
adListInfomodel.LIST_INFO_GOODSID = mod.GOODS_ID;
adListInfomodel.LOC_ID = mod.STO_SEAT;
adListInfomodel.Oldcount = mod.BOOK_NUM;
adListInfomodel.NEWCOUNT = mod.DIFF_NUM + mod.BOOK_NUM;
adListInfomodel.GOODS_NAME = mod.GOODS_NAME;
//adListInfomodel.Loc_name = GetLocName(mod.STO_SEAT);
if (!list_info.Contains(adListInfomodel))
{
adListInfomodel.OPERATEDATE = dt_now;
adListInfomodel.OPERATORID = userData.USER_ID;
list_info.Add(adListInfomodel);
}
}
bs_StAdjustList_Info.DataSource = list_info;
gr_adjustInfo.DataSource = list_info;
}
}
catch (Exception ex)
{
SystemCommon.ShowInfoMessageBox("网络连接错误!");
return;
}
//把盘点单商品明细集合转移到库存调整单明细
}
}
#endregion
#region
/// <summary>
/// 库位选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlDicLoc_Button_Click_1(object sender, EventArgs e)
{
//DataTable dt = ctrlDicLoc.SelectTable;
//if (dt.Rows.Count == 0)
//{
// SystemCommon.ShowInfoMessageBox("请选择库位!");
// return;
//}
////库位集合、库存集合
//List<StorageAreaLocationModel> list = ConvertHelper<StorageAreaLocationModel>.ConvertToList(ctrlDicLoc.SelectTable);
//List<MIStockModel> _list = new List<MIStockModel>();
//List<MIStockModel> temp_list = new List<MIStockModel>();
//MIStockModel stoc_model = new MIStockModel();
//foreach (StorageAreaLocationModel sa_model in list)
//{
// //库位ID赋给库存集合根据库位ID查出库存集合
// stoc_model = new MIStockModel();
// stoc_model.LOCATION_ID = sa_model.LOCATION_ID;
// string str_Stockmodel = Newtonsoft.Json.JsonConvert.SerializeObject(stoc_model);
// string errText = "";
// try
// {
// string str_Stocklist = WebLockConfig.Instance.WebMIStock.GetMIStockListStr(str_Stockmodel, ref errText);
// temp_list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MIStockModel>>(str_Stocklist);
// }
// catch (Exception ex)
// {
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
// return;
// }
// if (temp_list.Count == 0)
// {
// return;
// }
// stoc_model = temp_list[0];
// _list.Add(stoc_model);
//}
////把库存集合转换成库存调整单明细集合
//if (_list.Count > 0)
//{
// foreach (MIStockModel model in _list)
// {
// adListInfomodel = new AdjustListInfoModel();
// adListInfomodel.LIST_ID = txt_ListID.Text;
// adListInfomodel.LIST_INFO_COUNT = 0;
// adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
// adListInfomodel.LOC_ID = model.LOCATION_ID;
// adListInfomodel.Oldcount = model.SHELVES_NUM;
// adListInfomodel.NEWCOUNT = model.SHELVES_NUM;
// adListInfomodel.GOODS_NAME = GetGoodsName(model.GOODS_ID);
// //adListInfomodel.Loc_name = GetLocName(model.LOCATION_ID);
// list_info.Add(adListInfomodel);
// }
// bs_StAdjustList_Info.DataSource = list_info;
// gridView2.RefreshData();
//}
//else
//{
// return;
//}
}
#endregion
#region
/// <summary>
/// 调整原因为盘点之外的原因是 盘点单放大镜不可用
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lep_Reason_EditValueChanged(object sender, EventArgs e)
{
if (lep_Reason.Text == "盘点生成")
{
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = false;
}
ctrDicCountid.Enabled = true;
}
else
{
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = true;
}
ctrDicCountid.Enabled = false;
}
}
#endregion
private void ctrlButtons1_Click(object sender, EventArgs e)
{
//l = new List<MIStockModel>();
////list<MIStockModel> list =
//FrmGoodsSelect f_g_select = new FrmGoodsSelect(miatid);
//f_g_select.ShowDialog();
//l = f_g_select.miStockModelList;
////库存集合转化为调整单明细
//foreach (MIStockModel model in l)
//{
// adListInfomodel = new AdjustListInfoModel();
// adListInfomodel.LIST_ID = txt_ListID.Text;
// adListInfomodel.LIST_INFO_COUNT = 0;
// adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
// adListInfomodel.LOC_ID = model.LOCATION_ID;
// adListInfomodel.Oldcount = model.SHELVES_NUM;
// adListInfomodel.NEWCOUNT = model.SHELVES_NUM;
// adListInfomodel.GOODS_NAME = model.GOODS_NAME;
// adListInfomodel.LIST_INFO_GOODSID = model.GOODS_ID;
// adListInfomodel.Area_id = model.AREA_ID;
// adListInfomodel.Area_name = model.AREA_NAME;
// adListInfomodel.Production_date = model.PRODUCTION_DATE;
// adListInfomodel.Storage_id = model.STORAGE_ID;
// adListInfomodel.Storage_name = model.STORAGE_NAME;
// adListInfomodel.Goods_typeid = model.GOODS_TYPEID;
// list_info.Add(adListInfomodel);
//}
//bs_StAdjustList_Info.DataSource = list_info;
//gridView2.RefreshData();
}
#endregion
/// <summary>
/// 字典所选择仓库
/// </summary>
private string miatid = "";
public string Miatid
{
get { return miatid; }
set { miatid = value; }
}
//库存集合
private List<MIStockModel> mis_list = new List<MIStockModel>();
#region
/// <summary>
/// 选择商品
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctr_MIStock_Button_Click(object sender, EventArgs e)
{
//if (ctr_MIStock.SelectTable.Rows.Count == 0)
//{
// SystemCommon.ShowInfoMessageBox("请选择仓库!");
// return;
//}
//else
//{
// ctrlButtons1.Enabled = true;
// DataTable dt_select = ctr_MIStock.SelectTable;
// this.miatid = dt_select.Rows[0]["STORAGE_ID"].ToString();
//}
}
#endregion
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
{
if (frmButtonItem.ContainsKey("Save"))
{
if (frmButtonItem["Save"].Enabled)
{
if (xtraTabControl1.SelectedTabPageIndex == 1)
{
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = true;
}
lep_Reason.Enabled = true;
ctrDicCountid.Enabled = true;
txt_remark.Enabled = true;
}
else
{
if (frmButtonItem.ContainsKey("Move"))
{
frmButtonItem["Move"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Clear"))
{
frmButtonItem["Clear"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Select"))
{
frmButtonItem["Select"].Enabled = false;
}
lep_Reason.Enabled = false;
ctrDicCountid.Enabled = false;
txt_remark.Enabled = false;
}
}
}
}
}
}