using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UAS_LabelMachine.Entity;
using UAS_LabelMachine.PublicMethod;

namespace UAS_LabelMachine
{
    public partial class 附件内容打印 : Form
    {

        DataHelper dh = SystemInf.dh;

        string custcode;

        public 附件内容打印(string CustCode)
        {
            custcode = CustCode;
            InitializeComponent();
        }

        private void 附件内容打印_Load(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)dh.ExecuteSql("select *  from LabelAttachPARAMETER where lap_custcode='" + custcode + "' and lap_inman='" + User.UserCode + "'", "select");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Controls["lap_id" + (i + 1)].Text = dt.Rows[i]["lap_id"].ToString();
                Controls["lap_param" + (i + 1)].Text = dt.Rows[i]["lap_param"].ToString();
                Controls["lap_value" + (i + 1)].Text = dt.Rows[i]["lap_value"].ToString();
            }
        }

        private void Confirm_Click(object sender, EventArgs e)
        {
            string SQL = "";
            for (int i = 1; i < 6; i++)
            {
                if (Controls["lap_id" + i].Text == "")
                {
                    SQL = "insert into LabelAttachPARAMETER(lap_id,lap_custcode,lap_param,lap_value,lap_inman)values(LabelAttachPARAMETER_seq.nextval,'" + custcode + "','" + Controls["lap_param" + i].Text + "','" + Controls["lap_value" + i].Text + "','" + User.UserCode + "')";
                }
                else
                {
                    SQL = "update LabelAttachPARAMETER set lap_custcode='" + custcode + "',lap_param='" + Controls["lap_param" + i].Text + "',lap_value='" + Controls["lap_value" + i].Text + "' where lap_id='" + Controls["lap_id" + i].Text + "'";
                }
                dh.ExecuteSql(SQL, "insert");
            }
            LogManager.DoCommandLog(custcode, User.UserCode, "保存附加参数", "成功");
            MessageBox.Show("保存成功");
            Close();
        }
    }
}