using DllEapEntity; using DllPubInfo; using Newtonsoft.Json; using RabbitMQ.Client; 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 MacStatusBase : Form { private MacStatus CurrEntity = null; public delegate void closeForm(); public delegate void AddRow(MacStatus id); public event closeForm eventcloseform = null; public event AddRow eventaddrow = null; private string StatusMqName = ""; public MacStatusBase(MacStatus id) { InitializeComponent(); SetCurrID(id); } public void SetCurrID(MacStatus id) { InitForm(id); } private void InitForm(MacStatus id) { CurrEntity = id; if (CurrEntity == null) { CurrEntity = new MacStatus(); } //用实体的值去赋值界面控件显示的值 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 MacStatus CallIUBase(MacStatus entity) { try { string errorinfo = ""; int result = PubInfo.UpdateRowFormControl(panel1, entity, ref errorinfo); if (result < 0) { MessageBox.Show("更新数据发生错误:" + errorinfo); return null; } entity.STime = DateTime.Now; Hashtable tempds = new Hashtable(); string str = JsonConvert.SerializeObject(entity); tempds.Add(nameof(MacStatus), str); Hashtable reds = PubInfo.CallFunction("DllStatusShowBll.StatusShowBll", "IMacStatus", tempds); if (reds == null) return null; MacStatus reentity = JsonConvert.DeserializeObject(reds[nameof(MacStatus)].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 (editFCode.Text.Trim() == "") { MessageBox.Show("名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); editFCode.Focus(); return; } MacStatus 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 MacStatus(); editMacCode.Text = ""; } private void btEmail_Click_1(object sender, EventArgs e) { StatusColor temp = new StatusColor(); temp.eventSelStandardStatus += Temp_eventSelRow; temp.ShowDialog(); } private void Temp_eventSelRow(StandardStatus rows) { editFCode.Text = rows.FCode; editFCode.Tag = rows.ID; editStatusFName.Text = rows.FName; } private void MacStatusBase_Load(object sender, EventArgs e) { } } }