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 Cindy_Restaurant.Classes;
namespace Cindy_Restaurant.Folder_Updates
{
    public partial class frmUpElectronicCurrency : Form
    {
        public frmUpElectronicCurrency()
        {
            InitializeComponent();
        }
        clsUpdate updateClass = new clsUpdate();
        public TextBox txtID = new TextBox();
        void valElectronicCurrency(Control ctrl)
        {
            if (txtElecName.Text.Trim().Length > 0)
            {

                clsInsert.err.SetError(txtElecName, string.Empty);

            }
            else
            {
                clsInsert.err.SetIconAlignment(txtElecName, ErrorIconAlignment.MiddleLeft);
                clsInsert.err.SetError(txtElecName, "Field Can't be empty");
                return;

            }
        }

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

        private void txtElecName_TextChanged(object sender, EventArgs e)
        {
            valElectronicCurrency((Control)sender);
        }

        private void txtElecName_Leave(object sender, EventArgs e)
        {
            valElectronicCurrency((Control)sender);
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            valElectronicCurrency(txtElecName);

            if (clsSelect.err.GetError(txtElecName).Length != 0)
            {
                clsInsert.err.SetIconAlignment(txtElecName, ErrorIconAlignment.MiddleLeft);
                clsInsert.err.SetError(txtElecName, "Field Can't be empty");
                return;

            }
            updateClass.updateElectronicCurrency(txtElecName.Text, Convert.ToInt32(txtID.Text));
        }
    }
}
