BaoKai_202508-Wms-Jingwang..../WMS.Ctrl/NoteData.cs

127 lines
3.9 KiB
C#
Raw Permalink Normal View History

2025-08-24 09:35:55 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMS.Attirubte;
using System.Data;
using WMS.Model.Base;
using WMS.Common;
using WMS.Business;
using WMS.Business.Base;
namespace WMS.Ctrl
{
public enum DateType
{
= 0,
= 1,
= 2,
= 3,
= 4,
= 5,
= 6,
= 7,
= 8,
= 9,
= 10,
= 11,
}
public partial class NoteData : ComboBox
{
public NoteData()
{
// InitializeComponent();
this.DisplayMember = "CONTENT";
this.ValueMember = "CONTENT";
this.Leave += new System.EventHandler(this.NoteData_Leave);
}
DateType NoteType = DateType.;
string type = string.Empty;
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
//[Browsable(true)]
[Description("备注类型")]
[EditorBrowsable(EditorBrowsableState.Always)]
[Localizable(true)]
[Browsable(true)]
public DateType NoteTypes
{
get { return NoteType; }
set
{
NoteType = value;
type = NoteType.ToString();
LoadData();
}
}
public void LoadData()
{
// this.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
// Properties.Items.Clear();
string err = "";
BaseRemarkDictionaryModel model = new BaseRemarkDictionaryModel();
model.REMARK_TYPE = type;
try
{
List<BaseRemarkDictionaryModel> modelList = IBussFactory<BussBaseRemarkDictionary>.Instance().GetRemarkDictionaryList(model);
if (modelList != null)
{
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(Newtonsoft.Json.JsonConvert.SerializeObject(modelList));
this.DataSource = dt;
}
}
catch (Exception ex)
{
this.DataSource = null;
// LogWriteText.WriteLog("控件错误:"+ex.Message.ToString());
}
}
private void NoteData_Leave(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.Text))
{
string err = "";
BaseRemarkDictionaryModel model = new BaseRemarkDictionaryModel() { CONTENT = this.Text, REMARK_TYPE = NoteType.ToString() };
List<BaseRemarkDictionaryModel> modelList = IBussFactory<BussBaseRemarkDictionary>.Instance().GetRemarkDictionaryList(model);
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(Newtonsoft.Json.JsonConvert.SerializeObject(modelList));
if (dt.Rows.Count == 0)
{
model.ID = Guid.NewGuid().ToString();
err = "";
modelList = IBussFactory<BussBaseRemarkDictionary>.Instance().GetRemarkDictionaryList(model);
if (modelList == null)
{
SystemCommon.ShowErrorMessageBox("添加备注信息失败!");
}
else
{
LoadData();
this.SelectedValue = model.CONTENT;
// this.RefreshEditValue();
}
}
}
}
}
}