/*******************************************************************************
* Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_SAP_HEGII_0104.cs
* 2.功能描述:成品WMS同步日志
* 编辑履历:
* 作者 日期 版本 修改内容
* 付斌 2022/09/02 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.SAPDataModule
{
///
/// 成品SAP日志
///
public partial class F_SAP_HEGII_0104 : DKDockPanelBase
{
#region 成员变量
private static F_SAP_HEGII_0104 _instance = null;
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_SAP_HEGII_0104 Instance
{
get
{
if (_instance == null)
{
_instance = new F_SAP_HEGII_0104();
}
return _instance;
}
}
#endregion
#region 构造函数
///
/// 成品SAP日志
///
public F_SAP_HEGII_0104()
{
InitializeComponent();
tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
}
#endregion
#region 控件事件
///
/// 关闭
///
///
///
private void F_SAP_HEGII_0104_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 画面加载
///
///
///
private void F_SAP_HEGII_0104_Load(object sender, System.EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
dgvBarcode.AutoGenerateColumns = false;
dtpDatebegin.Value = DateTime.Now.Date;
dtpDateend.Value = DateTime.Now.Date;
DataTable dtLogType = new DataTable();
dtLogType.Columns.Add("LogType", typeof(string));
dtLogType.Columns.Add("LogTypeName", typeof(string));
DataRow newRow = dtLogType.NewRow();
dtLogType.Rows.Add(newRow);
newRow = dtLogType.NewRow();
newRow["LogType"] = "1";
newRow["LogTypeName"] = "交接";
dtLogType.Rows.Add(newRow);
newRow = dtLogType.NewRow();
newRow["LogType"] = "2";
newRow["LogTypeName"] = "撤销";
dtLogType.Rows.Add(newRow);
this.cmbLogType.DisplayMember = "LogTypeName";
this.cmbLogType.ValueMember = "LogType";
this.cmbLogType.DataSource = dtLogType;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(ToString(),
MethodBase.GetCurrentMethod().Name, Text, ex);
}
}
///
/// 查询
///
///
///
private void tsbtnSearch_Click(object sender, EventArgs e)
{
try
{
tsrToolStrip1.Focus();
dgvBarcode.DataSource = null;
if (dtpDatebegin.Value == null || dtpDateend.Value == null)
{
return;
}
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "Hegii";
cre.Name = "GetWMSDataLog";
cre.Properties["datebegin"] = dtpDatebegin.Value.Value;
cre.Properties["dateend"] = dtpDateend.Value.Value.AddDays(1);
cre.Properties["LogType"] = cmbLogType.SelectedValue;
cre.Properties["ReturnDesc"] = txtReturnDesc.Text;
ServiceResultEntity sre = DoAsync(() =>
{
return SAPDataModuleProxy.Service.DoRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
// 查询成功
dgvBarcode.DataSource = sre.Data.Tables[0];
dgvBarcode.IsSetInputColumnsColor = true;
if (dgvBarcode.RowCount == 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(ToString(),
MethodBase.GetCurrentMethod().Name, Text, ex);
}
}
///
/// 同步操作
///
///
///
private void tsbtnSynLog_Click(object sender, EventArgs e)
{
try
{
tsrToolStrip1.Focus();
DataTable dtBarcode = dgvBarcode.DataSource as DataTable;
if (dtBarcode == null)
{
return;
}
DataTable dtSelBarcode = dtBarcode.Copy();
dtSelBarcode.DefaultView.RowFilter = "Sel = 1";
dtSelBarcode = dtSelBarcode.DefaultView.ToTable();
if (dtSelBarcode.Rows.Count == 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "未选择任何数据");
return;
}
DataRow[] rows = dtSelBarcode.Select("RETURNDESC = '同步成功'");
if (rows.Length > 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "同步成功不允许再同步");
return;
}
string logtype;
rows = dtSelBarcode.Select("LOGTYPE = '1'");
if (rows.Length == dtSelBarcode.Rows.Count)
{
logtype = "1";
}
else if (rows.Length == 0)
{
logtype = "2";
}
else
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "交接和撤销不能一起同步");
return;
}
foreach (DataRow row in dtSelBarcode.Rows)
{
rows = dtSelBarcode.Select("CODEI = '" + row["CODEI"] + "'");
if (rows.Length > 1)
{
DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, row["CODEI"] + ":出现两次以上");
return;
}
}
DialogResult dr = MessageBox.Show("是否对所选数据进行同步?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr != System.Windows.Forms.DialogResult.Yes)
{
return;
}
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "Hegii";
cre.Name = "SyncWMSDataLog";
cre.Properties["LogType"] = logtype;
cre.Data = new DataSet();
cre.Data.Tables.Add(dtSelBarcode);
ServiceResultEntity sre = DoAsync(() =>
{
return SAPDataModuleProxy.Service.DoRequest(cre);
});
if (sre.OtherStatus > 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
tsbtnSearch_Click(null, null);
}
else
{
MessageBox.Show(this, sre.Message);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(ToString(),
MethodBase.GetCurrentMethod().Name, Text, ex);
}
}
///
/// 清除条件
///
///
///
private void tsbtnClearCondition_Click(object sender, EventArgs e)
{
dtpDatebegin.Value = DateTime.Now.Date;
dtpDateend.Value = DateTime.Now.Date;
this.cmbLogType.SelectedIndex = 0;
txtReturnDesc.Text = string.Empty;
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
dgvBarcode.AutoResizeColumns();
}
///
/// 关闭画面
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
Close();
}
#endregion
}
}