using System;
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;
using System.Xml.Linq;

namespace CowainHmi
{
    public partial class Dlg添加配方 : Form
    {
        private string pfName;
        private string nameAddr;
        private string plcVarName;
        public Dlg添加配方(string pfName, string nameAddr, string plcVarName)
        {
            InitializeComponent();
            this.txtName.Text = PCHMI.RT.GET_STRING(0, nameAddr, 15);
            this.pfName = pfName;
            this.nameAddr = nameAddr;
            this.plcVarName = plcVarName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            string name = this.txtName.Text;
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("配方名称不能为空！！", "提示");
                return;
            }
            PCHMI.RT.SEND_STRING(0, nameAddr, name);
            PCHMI.RT.SEND_SIEMENS_STRING(0, plcVarName, name);
            new PCHMI.配方().SAVE_TECH(pfName);          //保存指定配方文件名的配方
            this.Close();
        }
    }
}
