123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
-
- 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<MacStatus>(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<MacStatus>(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)
- {
- }
- }
- }
|