468 lines
16 KiB
C#
468 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.SystemManage;
|
|
using WMS.Common;
|
|
using WMS.Model.Base;
|
|
using WMS.Business;
|
|
using WMS.Business.Base;
|
|
using WMS.Business.SystemManage;
|
|
|
|
namespace WMS.FrmSystems
|
|
{
|
|
public partial class FrmSysParams : FormBase
|
|
{
|
|
#region 全局变量声明
|
|
string strText = string.Empty;
|
|
string strSpin = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 单据规则Model
|
|
/// </summary>
|
|
DocumentTableModel docModel = new DocumentTableModel();
|
|
|
|
/// <summary>
|
|
/// 单据规则List
|
|
/// </summary>
|
|
List<DocumentTableModel> docList = new List<DocumentTableModel>();
|
|
|
|
|
|
/// <summary>
|
|
/// 系统参数 实体
|
|
/// </summary>
|
|
SystemParamsModel paramModel = new SystemParamsModel();
|
|
|
|
/// <summary>
|
|
/// 系统参数 集合
|
|
/// </summary>
|
|
List<SystemParamsModel> paramList = new List<SystemParamsModel>();
|
|
|
|
#endregion
|
|
|
|
#region 构造函数
|
|
/// <summary>
|
|
/// 无参构造
|
|
/// </summary>
|
|
public FrmSysParams()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#endregion
|
|
|
|
#region 窗体加载
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void FrmSysParams_Load(object sender, EventArgs e)
|
|
{
|
|
docModel = new DocumentTableModel();
|
|
docList = new List<DocumentTableModel>();
|
|
BindlkpData();
|
|
// this.radiodate.EditValue = "0";
|
|
BindParamData();
|
|
LockControl(true);
|
|
//splitContainerControl1.Panel1.Enabled = false;
|
|
}
|
|
#endregion
|
|
|
|
List<DictionaryTabModel> lis = new List<DictionaryTabModel>();
|
|
#region 单据类型
|
|
/// <summary>
|
|
/// 绑定下拉 单据类型(出库,入库,盘点等)
|
|
/// </summary>
|
|
public void BindlkpData()
|
|
{
|
|
lis = IBussFactory<BussDictionaryTab>.Instance().GetDictionaryTab("document_type");
|
|
this.lkpDocumentType.Properties.DataSource = lis;
|
|
this.lkpDocumentType.Properties.ValueMember = "VC_CHAR_VALUE";
|
|
this.lkpDocumentType.Properties.DisplayMember = "VC_DICTIONARY_NAME";
|
|
|
|
this.lkpDocumentType.ItemIndex = 0;
|
|
}
|
|
string valSeq = string.Empty;
|
|
string valName = string.Empty;
|
|
/// <summary>
|
|
/// 下拉单据类型
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void lkpDocumentType_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.lkpDocumentType.EditValue.ToString()))
|
|
{
|
|
string val =this.lkpDocumentType.EditValue.ToString();
|
|
if (lis != null)
|
|
{
|
|
DictionaryTabModel tbModel = lis.Find(r => r.VC_CHAR_VALUE == val);
|
|
valSeq = tbModel.VC_DESCRIPTION;
|
|
valName = tbModel.VC_DICTIONARY_NAME;
|
|
this.txtStarText.Text = tbModel.VC_PINYIN_CODE;
|
|
}
|
|
radiodate_SelectedIndexChanged(null, null);
|
|
|
|
txtStarText.Refresh();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 流水日期变动
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void radiodate_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.radiodate.SelectedIndex == 0)
|
|
{
|
|
this.lblDocument.Text = this.txtStarText.Text + DateTime.Now.ToString("yyyyMMdd");
|
|
strText = lblDocument.Text;
|
|
docModel.DOCUMENT_DATE = "yyyyMMdd";
|
|
}
|
|
else if (this.radiodate.SelectedIndex == 1)
|
|
{
|
|
this.lblDocument.Text = this.txtStarText.Text + DateTime.Now.ToString("yyyyMM");
|
|
strText = lblDocument.Text;
|
|
docModel.DOCUMENT_DATE = "yyyyMM";
|
|
|
|
}
|
|
else
|
|
{
|
|
lblDocument.Text = this.txtStarText.Text+"001";
|
|
docModel.DOCUMENT_DATE = string.Empty;
|
|
}
|
|
spinEdit1_EditValueChanged(null, null);
|
|
}
|
|
/// <summary>
|
|
/// 前缀
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void txtStarText_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
radiodate_SelectedIndexChanged(null, null);
|
|
this.lblDocument.Refresh();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 流水变化
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void spinEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
//lblDocument.Text = strText;
|
|
int i = (Convert.ToInt32(spinEdit1.EditValue));
|
|
lblDocument.Text = strText + (Math.Pow(10, (i - 1)) + 1).ToString();
|
|
strSpin = lblDocument.Text;
|
|
// docModel.DOCUMENT_MIN = (Math.Pow(10, (i - 1)) + 1).ToString();
|
|
lblDocument.Refresh();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 后缀
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void txtEndText_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
//lblDocument.Text = strText;
|
|
lblDocument.Text = strSpin;
|
|
if (!string.IsNullOrEmpty(this.txtEndText.Text))
|
|
{
|
|
this.lblDocument.Text = strSpin + this.txtEndText.Text;
|
|
}
|
|
|
|
else
|
|
{
|
|
this.lblDocument.Text = strSpin;
|
|
|
|
}
|
|
this.lblDocument.Refresh();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 系统参数
|
|
/// <summary>
|
|
/// 配置
|
|
/// </summary>
|
|
public override void Add()
|
|
{
|
|
//splitContainerControl1.Panel1.Enabled = true;
|
|
LockControl(false);
|
|
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = true; }
|
|
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = true; }
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 确认按钮
|
|
/// </summary>
|
|
public void Confirm()
|
|
{
|
|
|
|
if (!Validate())
|
|
{
|
|
return;
|
|
}
|
|
string strErr = string.Empty;
|
|
this.labelControl1.Focus();
|
|
BindValueByControl();
|
|
try
|
|
{
|
|
strErr = IBussFactory<BussSystemParams>.Instance().AddSysParamsData(paramList);
|
|
if (string.IsNullOrEmpty(strErr))
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = false; }
|
|
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = false; }
|
|
//splitContainerControl1.Panel1.Enabled = false;
|
|
LockControl(true);
|
|
}
|
|
else
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("网络连接错误,请检查当前网络环境是否可用!");
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新
|
|
/// </summary>
|
|
public override void Refresh()
|
|
{
|
|
BindlkpData();
|
|
this.radiodate.EditValue = "0";
|
|
BindParamData();
|
|
//splitContainerControl1.Panel1.Enabled = false;
|
|
LockControl(true);
|
|
if (frmButtonItem.ContainsKey("Confirm")) { frmButtonItem["Confirm"].Enabled = false; }
|
|
if (frmButtonItem.ContainsKey("Clear")) { frmButtonItem["Clear"].Enabled = false; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空
|
|
/// </summary>
|
|
public override void Clear()
|
|
{
|
|
if (DialogResult.OK!= SystemCommon.ShowMessageBoxResult("是否要清空当前页面所做配置?"))
|
|
{
|
|
return;
|
|
}
|
|
foreach (Control item in splitContainerControl1.Panel1.Controls)
|
|
{
|
|
if (item.GetType().ToString().ToLower().Contains("label"))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
if (item is DevExpress.XtraEditors.RadioGroup)
|
|
{
|
|
(item as DevExpress.XtraEditors.RadioGroup).EditValue = string.Empty;
|
|
}
|
|
else if (item is DevExpress.XtraEditors.SpinEdit)
|
|
{
|
|
(item as DevExpress.XtraEditors.SpinEdit).EditValue = (item as DevExpress.XtraEditors.SpinEdit).Properties.MinValue;
|
|
}
|
|
item.Refresh();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 窗体初加载时 给控件 赋值
|
|
/// </summary>
|
|
public void BindParamData()
|
|
{
|
|
paramModel = new SystemParamsModel();
|
|
paramList = IBussFactory<BussSystemParams>.Instance().GetSysParamsList(paramModel);
|
|
foreach (SystemParamsModel mo in paramList)
|
|
{
|
|
foreach (Control item in splitContainerControl1.Panel1.Controls)
|
|
{
|
|
//排除label
|
|
if (item.GetType().ToString().ToLower().Contains("label"))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
//RadioGroup 赋值
|
|
if (item is DevExpress.XtraEditors.RadioGroup)
|
|
{
|
|
if (mo.PARAMTYPE == item.Name)
|
|
{
|
|
(item as DevExpress.XtraEditors.RadioGroup).EditValue = mo.PARAMVALUE;
|
|
}
|
|
}
|
|
//SpinEdit 赋值
|
|
else if (item is DevExpress.XtraEditors.SpinEdit)
|
|
{
|
|
if (mo.PARAMTYPE == item.Name)
|
|
{
|
|
(item as DevExpress.XtraEditors.SpinEdit).EditValue = mo.PARAMVALUE;
|
|
}
|
|
}
|
|
item.Refresh();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定界面控件值(收集数据)
|
|
/// </summary>
|
|
public void BindValueByControl()
|
|
{
|
|
paramList = new List<SystemParamsModel>();
|
|
foreach (Control item in splitContainerControl1.Panel1.Controls)
|
|
{
|
|
//label控件排除
|
|
if (item.GetType().ToString().ToLower().Contains("label"))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
//RadioGroup控件处理
|
|
if (item is DevExpress.XtraEditors.RadioGroup)
|
|
{
|
|
paramModel = new SystemParamsModel();
|
|
paramModel.PARAMVALUE = (item as DevExpress.XtraEditors.RadioGroup).Text.ToString();
|
|
paramModel.PARAMDATE = DateTime.Now;
|
|
paramModel.PARAMTYPE = item.Name;
|
|
if (item.Tag != null)
|
|
{
|
|
paramModel.PARAMCOMMENTS = item.Tag.ToString();
|
|
}
|
|
paramModel.SYSUSER = userData.USER_ID;
|
|
if (!string.IsNullOrEmpty(paramModel.PARAMVALUE))
|
|
{
|
|
paramList.Add(paramModel);
|
|
}
|
|
}
|
|
//SpinEdit控件处理
|
|
if (item is DevExpress.XtraEditors.SpinEdit)
|
|
{
|
|
paramModel = new SystemParamsModel();
|
|
paramModel.PARAMVALUE = (item as DevExpress.XtraEditors.SpinEdit).EditValue.ToString();
|
|
paramModel.PARAMDATE = DateTime.Now;
|
|
paramModel.PARAMTYPE = item.Name;
|
|
if (item.Tag != null)
|
|
{
|
|
paramModel.PARAMCOMMENTS = item.Tag.ToString();
|
|
}
|
|
if (item.Name.ToString().ToLower().Contains("spinweight"))
|
|
{
|
|
paramModel.PARAMMENU = "FrmPackWeighing";
|
|
}
|
|
paramModel.SYSUSER = userData.USER_ID;
|
|
if (!string.IsNullOrEmpty(paramModel.PARAMVALUE))
|
|
{
|
|
paramList.Add(paramModel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 非法验证
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool Validate()
|
|
{
|
|
if (Convert.ToInt32(this.spinGoodsMin.EditValue) > Convert.ToInt32(this.spinGoodsMax.EditValue))
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("您输入的库存下限不合法!" + Environment.NewLine + "请重新输入!");
|
|
this.spinGoodsMin.Focus();
|
|
return false;
|
|
}
|
|
|
|
if (Convert.ToInt32(this.spinWearingValue.EditValue) > Convert.ToInt32(this.spinGoodsMin.EditValue))
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("您输入的库存预警值不合法!" + Environment.NewLine + "请重新输入!");
|
|
this.spinWearingValue.Focus();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 控件是否可以交互
|
|
/// </summary>
|
|
public void LockControl(bool isLock)
|
|
{
|
|
foreach (Control item in splitContainerControl1.Panel1.Controls)
|
|
{
|
|
item.Enabled = !isLock;
|
|
}
|
|
foreach (Control item in splitContainerControl1.Panel2.Controls)
|
|
{
|
|
item.Enabled = !isLock;
|
|
}
|
|
splitContainerControl1.Panel1.Refresh();
|
|
splitContainerControl1.Panel2.Refresh();
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 保存按钮,单条操作-- 一条
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.txtStarText.Text))
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("起始编号不能为空!");
|
|
this.txtStarText.Focus();
|
|
return;
|
|
|
|
}
|
|
string errText = string.Empty;
|
|
docModel.DOCUMENT_START = this.txtStarText.Text;
|
|
docModel.DOCUMENT_COUNT = Convert.ToInt32(this.spinEdit1.EditValue);
|
|
docModel.DOCUMENT_TYPE_VALUE =valSeq;
|
|
docModel.DOCUMENT_END = txtEndText.Text.Trim();
|
|
|
|
docModel.DOCUMENT_TYPE = valName;
|
|
// string strModel = Newtonsoft.Json.JsonConvert.SerializeObject(docModel);
|
|
errText = IBussFactory<BussDocumentTable>.Instance().AddDocumentData(docModel);
|
|
if (string.IsNullOrEmpty(errText))
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|
}
|
|
else
|
|
{
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|