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;

namespace Aram_CRM_Project.UIL
{
    public partial class frmCheck : Form
    {
        public frmCheck()
        {
            InitializeComponent();
        }

        private void frmCheck_Load(object sender, EventArgs e)
        {
            string[] SystemDate = Aram_CRM_Project.BLL.Entity.StaticVariable.SystemDate.Split('/');
            nupDay.Value = decimal.Parse(SystemDate[2]);
            nupMonth.Value = decimal.Parse(SystemDate[1]);
            nupYear.Value = decimal.Parse(SystemDate[0]);
        }

        private void txtPrice_KeyDown(object sender, KeyEventArgs e)
        {
            if (!(e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) && !(e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) && !(e.KeyCode == Keys.Oemcomma) && !(e.KeyCode == Keys.Delete) && !(e.KeyCode == Keys.Back) && !(e.KeyCode == Keys.Down) && !(e.KeyCode == Keys.Up) && !(e.KeyCode == Keys.Left) && !(e.KeyCode == Keys.Right))
            {
                e.SuppressKeyPress = true;
            }
        }

        private void txtPrice_TextChanged(object sender, EventArgs e)
        {
            Aram_CRM_Project.BLL.Utility utility = new Aram_CRM_Project.BLL.Utility();
            txtPrice.Text = utility.ThousandSeparator(txtPrice.Text.Trim());
            txtPrice.SelectionStart = txtPrice.Text.Length;
        }

        private void btnEnter_Click(object sender, EventArgs e)
        {
            bool ErrorFlag = false;
            if (txtCheckNum.Text.Trim() == "")
            {
                errCheck.SetIconAlignment(this.txtCheckNum, ErrorIconAlignment.MiddleLeft);
                errCheck.SetError(this.txtCheckNum, Properties.Resources.ResourceManager.GetString("ErrEmptyCheckNum"));
                ErrorFlag = true;
            }
            if (txtBank.Text.Trim() == "")
            {
                errCheck.SetIconAlignment(this.txtBank, ErrorIconAlignment.MiddleLeft);
                errCheck.SetError(this.txtBank, Properties.Resources.ResourceManager.GetString("ErrEmptyBank"));
                ErrorFlag = true;
            }
            if (txtAccountNum.Text.Trim() == "")
            {
                errCheck.SetIconAlignment(this.txtAccountNum, ErrorIconAlignment.MiddleLeft);
                errCheck.SetError(this.txtAccountNum, Properties.Resources.ResourceManager.GetString("ErrEmptyAccountNum"));
                ErrorFlag = true;
            }
            if (txtPrice.Text.Trim() == "")
            {
                errCheck.SetIconAlignment(this.txtPrice, ErrorIconAlignment.MiddleLeft);
                errCheck.SetError(this.txtPrice, Properties.Resources.ResourceManager.GetString("ErrEmptyPrice"));
                ErrorFlag = true;
            }
            if (ErrorFlag)
            {
                return;
            }

            lblEvent.Text = "Enter";
            this.Close();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        
    }
}
