using DllEapEntity; using DllPubInfo; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace DllXqManager { public partial class TLcdBase : Form { private TLcd CurrEntity = null; public delegate void closeForm(); public delegate void AddRow(TLcd id); public event closeForm eventcloseform = null; public event AddRow eventaddrow = null; public TLcdBase(TLcd id) { InitializeComponent(); SetCurrID(id); } public void SetCurrID(TLcd id) { InitForm(id); } private void InitForm(TLcd id) { CurrEntity = id; if (CurrEntity == null) { CurrEntity = new TLcd(); } //用实体的值去赋值界面控件显示的值 string errorinfo = ""; int result = DllPubInfo.PubInfo.InitFormControl(panel1, CurrEntity, null, ref errorinfo); if (result < 0) MessageBox.Show(errorinfo); } private void button1_Click(object sender, EventArgs e) { InitForm(null); } private TLcd CallIUBase(TLcd entity) { try { string errorinfo = ""; int result = PubInfo.UpdateRowFormControl(panel1, entity, ref errorinfo); if (result < 0) { MessageBox.Show("更新数据发生错误:" + errorinfo); return null; } Hashtable tempds = new Hashtable(); string str = JsonConvert.SerializeObject(entity); tempds.Add(nameof(TLcd), str); Hashtable reds = PubInfo.CallFunction("DllStatusShowBll.StatusShowBll", "IUTLcd", tempds); if (reds == null) return null; TLcd reentity = JsonConvert.DeserializeObject(reds[nameof(TLcd)].ToString()); return reentity; } catch (Exception e) { MessageBox.Show("操作发生错误,错误信息为:" + e.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } } private void button2_Click(object sender, EventArgs e) { //if(edit代码.Text.Trim()=="") //{ // MessageBox.Show("代码不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // edit代码.Focus(); // return; //} if (editFName.Text.Trim() == "") { MessageBox.Show("名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); editFName.Focus(); return; } TLcd result = CallIUBase(CurrEntity); if(result!=null) { MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); InitForm(result); eventaddrow?.Invoke(result); } } private void mmabase_FormClosing(object sender, FormClosingEventArgs e) { eventcloseform?.Invoke(); } public void Selmma(DataRow row) { //if(row==null) //{ // edit机型代码.Text = ""; // return; //} //edit机型代码.Text = row["代码"].ToString(); } private void btEmail_Click(object sender, EventArgs e) { //mmaquery temp = new mmaquery(); //temp.eventselrow += Selmma; //temp.ShowDialog(); } private void button3_Click(object sender, EventArgs e) { //if (CurrDs == null) //{ // InitForm(0); // return; //} //CurrID = 0; //CurrDs.Tables[0].Rows[0]["id"] = 0; CurrEntity = new TLcd(); editFCode.Text = ""; } } }