525 lines
16 KiB
C#
525 lines
16 KiB
C#
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.Stock;
|
||
using WMS.Common;
|
||
|
||
using WMS.Ctrl;
|
||
using WMS.Model.Base;
|
||
using WMS.Frm;
|
||
using WMS.FrmBaseData;
|
||
using WMS.Business.Stock;
|
||
using WMS.Business;
|
||
|
||
namespace WMS.FrmStock
|
||
{
|
||
public partial class FrmCountingDet : FormBase
|
||
{
|
||
/// <summary>
|
||
/// 盘点任务MODEL
|
||
/// </summary>
|
||
CountingModel countingModel = new CountingModel();
|
||
|
||
/// <summary>
|
||
/// 盘点任务MODEL集合
|
||
/// </summary>
|
||
List<CountingModel> countList = new List<CountingModel>();
|
||
|
||
/// <summary>
|
||
/// 盘点任务MODEL
|
||
/// </summary>
|
||
CountingInfoModel countingInfoModel = new CountingInfoModel();
|
||
|
||
/// <summary>
|
||
/// 盘点任务MODEL集合
|
||
/// </summary>
|
||
List<CountingInfoModel> infoList = new List<CountingInfoModel>();
|
||
|
||
/// <summary>
|
||
/// 盘点单号
|
||
/// </summary>
|
||
public string pdsheet = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 业务类型
|
||
/// </summary>
|
||
int workflag = 3;//0 增加 1 修改 2 删除 ;
|
||
|
||
public FrmCountingDet()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 页面加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public void FrmCountingDet_Load(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
FrmSelectModle = new CountingModel();
|
||
DateTime dt = DateTime.Now;
|
||
if (string.IsNullOrEmpty(pdsheet))
|
||
{
|
||
BSCountingTab.DataSource = new CountingModel() { PLAN_DATE_STAR = dt.AddDays(1 - dt.Day), PLAN_DATE_END = dt.AddDays(1 - dt.Day).AddMonths(1).AddDays(-1) };
|
||
PageInfo.PageEnabled = false;
|
||
bindCountGrid();
|
||
}
|
||
else
|
||
{
|
||
|
||
CountingModel strmodel = new CountingModel()
|
||
{
|
||
COUNT_ID = pdsheet
|
||
};
|
||
|
||
|
||
countList = IBussFactory<BussCounting>.Instance().GetCountingList(strmodel);
|
||
|
||
if (countList != null)
|
||
{
|
||
GCCounting.DataSource = countList;
|
||
GVCounting.RefreshData();
|
||
bindCountInfoGrid(new CountingInfoModel() { COUNT_ID = pdsheet });
|
||
if (countList.Count > 0)
|
||
{
|
||
DateCount.EditValue = countList[0].COUNT_DATE;
|
||
noteData1.SelectedValue = countList[0].REMARK;
|
||
DicCountMan.TextBoxFlag = countList[0].COUNT_MAN;
|
||
DicCountMan.TextBoxValue = countList[0].COUNT_MAN_NAME;
|
||
}
|
||
xtraTabInfo.SelectedTabPage = PageCount;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
frmButtonItem["Save"].Enabled = false;
|
||
}catch(Exception ex)
|
||
{ }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通用查询
|
||
/// </summary>
|
||
/// <param name="table"></param>
|
||
public override void LoadListData(DataTable table)
|
||
{
|
||
countList = ConvertHelper<CountingModel>.ConvertToList(table);
|
||
GCCounting.DataSource = countList;
|
||
GVCounting.RefreshData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定盘点任务
|
||
/// </summary>
|
||
private void bindCountGrid()
|
||
{
|
||
BSCountingTab.EndEdit();
|
||
CountingModel smodel = BSCountingTab.DataSource as CountingModel;
|
||
smodel.COUNT_STATUS = "1";
|
||
|
||
try
|
||
{
|
||
// = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CountingInfoModel>>(strlist);
|
||
countList = IBussFactory<BussCounting>.Instance().GetCountingList(smodel);
|
||
|
||
if(countList!=null)
|
||
{
|
||
GCCounting.DataSource = countList;
|
||
GVCounting.RefreshData();
|
||
|
||
}
|
||
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定明细
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
private void bindCountInfoGrid(CountingInfoModel model)
|
||
{
|
||
try
|
||
{
|
||
|
||
infoList = IBussFactory<BussCountingInfo>.Instance().GetList(model);
|
||
|
||
if (infoList != null)
|
||
{
|
||
GCCountInfo.DataSource = infoList.OrderBy(r => r.STO_SEAT);
|
||
GVCountInfo.RefreshData();
|
||
}
|
||
}
|
||
catch(Exception e)
|
||
{
|
||
SystemCommon.ShowErrorMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 盘点单双击
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GCCounting_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
if (GVCounting.FocusedRowHandle < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
countingModel = GVCounting.GetFocusedRow() as CountingModel;
|
||
countingInfoModel.COUNT_ID = countingModel.COUNT_ID;
|
||
bindCountInfoGrid(countingInfoModel);
|
||
|
||
PageInfo.PageEnabled = true;
|
||
xtraTabInfo.SelectedTabPage = PageInfo;
|
||
DateCount.EditValue = DateTime.Now;
|
||
DicCountMan.TextBoxFlag = userData.USER_ID;
|
||
DicCountMan.TextBoxValue = userData.NAME;
|
||
if (!string.IsNullOrEmpty(countingModel.COUNT_MAN))
|
||
{
|
||
DicCountMan.TextBoxFlag = countingModel.COUNT_MAN;
|
||
}
|
||
else
|
||
{
|
||
DicCountMan.TextBoxFlag = userData.USER_ID;
|
||
}
|
||
if (countingModel.COUNT_DATE.ToString("yyyyMMdd") != "00010101")
|
||
{
|
||
DateCount.EditValue = countingModel.COUNT_DATE;
|
||
}
|
||
else
|
||
{
|
||
DateCount.EditValue = DateTime.Now;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 盘点任务显示转换
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVCounting_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Value == null || e.Value == DBNull.Value)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (e.Column.FieldName == "COUNT_TYPE")
|
||
{
|
||
switch (e.Value.ToString().Trim())
|
||
{
|
||
case "0":
|
||
e.DisplayText = "全盘";
|
||
break;
|
||
case "1":
|
||
e.DisplayText = "动盘";
|
||
break;
|
||
case "2":
|
||
e.DisplayText = "自定义";
|
||
break;
|
||
default:
|
||
e.DisplayText = "其它";
|
||
break;
|
||
}
|
||
}
|
||
else if (e.Column.FieldName == "COUNT_STATUS")
|
||
{
|
||
switch (e.Value.ToString().Trim())
|
||
{
|
||
case "0":
|
||
e.DisplayText = "未确认";
|
||
break;
|
||
case "1":
|
||
e.DisplayText = "已确认";
|
||
break;
|
||
case "2":
|
||
e.DisplayText = "已盘点";
|
||
break;
|
||
case "3":
|
||
e.DisplayText = "已复核";
|
||
break;
|
||
default:
|
||
e.DisplayText = "其它";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
#region 以下是继承的按钮事件
|
||
/// <summary>
|
||
/// 新增按钮
|
||
/// </summary>
|
||
public void Add()
|
||
{
|
||
workflag = 0;
|
||
frmButtonItem["Save"].Enabled = true;
|
||
frmButtonItem["Edit"].Enabled = false;
|
||
GCCounting_DoubleClick(null, null);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
public void Save()
|
||
{
|
||
FrmOperator(workflag);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除按钮
|
||
/// </summary>
|
||
public void Del()
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改按钮
|
||
/// </summary>
|
||
public void Edit()
|
||
{
|
||
if (countingModel.COUNT_STATUS != "2")
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("该盘点单不能修改!");
|
||
return;
|
||
}
|
||
workflag = 1;
|
||
frmButtonItem["Save"].Enabled = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刷新按钮
|
||
/// </summary>
|
||
public void RefreshDataButton()
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 确定按钮
|
||
/// </summary>
|
||
public void Confirm()
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询按钮
|
||
/// </summary>
|
||
public void Search()
|
||
{
|
||
FrmSelect frm = new FrmSelect(FrmSelectModle);
|
||
if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||
{
|
||
this.LoadListData(frm.SelectData);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出按钮
|
||
/// </summary>
|
||
public void ExportDataButton()
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打印按钮
|
||
/// </summary>
|
||
public void PrintDataButton()
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
protected new void NoteDataButton(FormBase fBase)
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 审核
|
||
/// </summary>
|
||
public void AuditDataButton()
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 反审核
|
||
/// </summary>
|
||
public void ReturnAuditDataButton()
|
||
{
|
||
|
||
}
|
||
|
||
#endregion
|
||
#region 操作(增、改、删)
|
||
/// <summary>
|
||
/// 操作(增、改、删)
|
||
/// </summary>
|
||
/// <param name="flag">0 新增 1修改 2删除 3停用 4启用/param>
|
||
private void FrmOperator(int flag)
|
||
{
|
||
try
|
||
{
|
||
GVCountInfo.CloseEditor();
|
||
GVCountInfo.UpdateCurrentRow();
|
||
string err = "";
|
||
countingModel.COUNT_MAN = DicCountMan.TextBoxFlag;
|
||
countingModel.COUNT_DATE = Convert.ToDateTime(DateCount.EditValue);
|
||
if (!string.IsNullOrEmpty(countingModel.REMARK))
|
||
{
|
||
countingModel.REMARK += ";" + noteData1.Text;
|
||
}
|
||
countingModel.COUNT_STATUS = "2";
|
||
if (flag == 0)
|
||
{
|
||
if (infoList.Count == 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("请先完善盘点信息!");
|
||
return;
|
||
}
|
||
bool back = true;
|
||
foreach (CountingInfoModel cim in infoList)
|
||
{
|
||
if (cim.STATUS != "0")
|
||
{
|
||
back = false;
|
||
}
|
||
}
|
||
if (back)
|
||
{
|
||
countingModel.COUNT_BACK = "0";
|
||
}
|
||
else
|
||
{
|
||
countingModel.COUNT_BACK = "1";
|
||
}
|
||
|
||
|
||
err = IBussFactory<BussCounting>.Instance().UpdateAndInfo(countingModel, infoList);
|
||
}
|
||
else if (flag == 1)
|
||
{
|
||
if (infoList.Count == 0)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("请先完善盘点信息!");
|
||
return;
|
||
}
|
||
bool back = true;
|
||
foreach (CountingInfoModel cim in infoList)
|
||
{
|
||
if (cim.STATUS != "0")
|
||
{
|
||
back = false;
|
||
}
|
||
}
|
||
if (back)
|
||
{
|
||
countingModel.COUNT_BACK = "0";
|
||
}
|
||
else
|
||
{
|
||
countingModel.COUNT_BACK = "1";
|
||
}
|
||
|
||
|
||
err = IBussFactory<BussCounting>.Instance().UpdateAndInfo(countingModel, infoList);
|
||
}
|
||
if (!string.IsNullOrEmpty(err))
|
||
{
|
||
SystemCommon.ShowErrorMessageBox(err);
|
||
}
|
||
else
|
||
{
|
||
|
||
SystemCommon.ShowInfoMessageBox("操作成功!");
|
||
frmButtonItem["Save"].Enabled = false;
|
||
}
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("您的操作出错:" + Environment.NewLine + e.Message);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// GRID修改完成时
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GVCountInfo_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
||
{
|
||
if (e.Column.Name == "colSTO_NUM")
|
||
{
|
||
decimal num = 0;
|
||
try
|
||
{
|
||
num = Convert.ToDecimal(e.Value);
|
||
}
|
||
catch
|
||
{
|
||
SystemCommon.ShowInfoMessageBox("请输入有效数量!");
|
||
return;
|
||
}
|
||
CountingInfoModel model = GVCountInfo.GetFocusedRow() as CountingInfoModel;
|
||
if (num == model.BOOK_NUM)
|
||
{
|
||
model.STATUS = "0";
|
||
}
|
||
else if (num > model.BOOK_NUM)
|
||
{
|
||
model.STATUS = "1";
|
||
}
|
||
else
|
||
{
|
||
model.STATUS = "2";
|
||
}
|
||
|
||
model.DIFF_NUM = (num - model.BOOK_NUM);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 超链接点击
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e)
|
||
{
|
||
CountingInfoModel model = GVCountInfo.GetFocusedRow() as CountingInfoModel;
|
||
if (model != null && !string.IsNullOrEmpty(model.GOODS_ID))
|
||
{
|
||
FrmGoodsInfoDet.IFlag = 2;
|
||
FrmGoodsInfoDet.StrGoodsID = model.GOODS_ID;
|
||
LoadForm load = new LoadForm();
|
||
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(load, load.GetType(), false, true, false, 0);
|
||
DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("正在读取商品信息....");
|
||
FrmGoodsInfoDet.GetInstance().Show();
|
||
}
|
||
}
|
||
}
|
||
}
|