public MainForm()
 {
     InitializeComponent();
     partOps = new Hashtable();
     partOps.Add(t1part1, t1opr1);
     partOps.Add(t2part1, t2opr1);
     partOps.Add(t2part2, t2opr2);
     partOps.Add(t2part3, t2opr3);
     partOps.Add(t2part4, t2opr4);
     partOps.Add(t3part1, t3opr1);
     partOps.Add(t4part1, t4opr1);
     partOps.Add(t4part2, t4opr2);
     partOps.Add(t4part3, t4opr3);
     partOps.Add(t4part4, t4opr4);
     partOps.Add(t5part1, t5opr1);
     partOps.Add(t6part1, t6opr1);
     partOps.Add(t6part2, t6opr2);
     partOps.Add(t7part1, t7opr1);
     partOps.Add(t7part2, t7opr2);
     _manifest = new Dictionary<string, ControlContainer>();
     this.StartPosition = FormStartPosition.CenterScreen;
     Init_Login();
     com = new ControlManifest();
     ManifestControls();
     cmd = new Commands(com);
     tcp = new TcpActions();
     tcp.ClientCountChanged += new TcpActions.ClientCountChangedEventHandler(tcp_ClientCountChanged);
     string port = Properties.Settings.Default.port.ToString();
     sockStatLbl.Text = "Listening on port " + port;
     MultiProgTblInit();
 }
        public void getFrmMultProgTbl(int flg)
        {
            string cmd = string.Empty;
            string err = string.Empty;
            int j = 1;
            int errCnt = 0;
            Hashtable h = new Hashtable();
            h.Add("prog", "Program");
            h.Add("part", "Part Name");
            h.Add("opr", "Operation");
            h.Add("gp", "Good Parts");
            h.Add("bp", "Bad Parts");
            var t = new List<Control>();
            var k = new List<Control>();
            Control[] m;
            Control[] n;
            if (flg == 1)
            {
                string showCmd = string.Empty;
                Control tb = new Control();
                tb = null;
                for (int i = 0; i < 4; i++)
                {
                    if (td.t2progBox[i].Text == "" && td.t2partBox[i].Text == "" && td.t2operBox[i].Text == "")
                    {
                        t.Add(td.t2progBox[i]);
                        t.Add(td.t2partBox[i]);
                        t.Add(td.t2operBox[i]);
                        errCnt++;
                        if (errCnt == 4)
                        {
                            err += "Enter atleast one row of data";
                        }
                    }
                    else if (td.t2progBox[i].Text != "" && td.t2partBox[i].Text != "" && td.t2operBox[i].Text != "")
                    {
                        cmd += "prgm" + j + "=" + td.t2progBox[i].Text + ";ptype" + j + "=" + td.t2partBox[i].Text + ";otype" + j + "=" + td.t2operBox[i].Text + ";";
                        t.Add(td.t2progBox[i]);
                        t.Add(td.t2partBox[i]);
                        t.Add(td.t2operBox[i]);
                        k.Add(td.t2gpbox[i]);
                        k.Add(td.t2bpbox[i]);
                        showCmd += "Program " + j + " - " + td.t2progBox[i].Text + "\nPart " + j + " - " + td.t2partBox[i].Text + "\nOperation " + j + " - " + td.t2operBox[i].Text + "\n\n";
                    }
                    else if (td.t2progBox[i].Text != "" || td.t2partBox[i].Text != "" || td.t2operBox[i].Text != "")
                    {
                        if (td.t2progBox[i].Text == "") { if (tb == null) { tb = td.t2progBox[i]; } err += "Please enter " + h[td.t2progBox[i].Name.ToString().Substring(2, 4)] + " " + (i + 1) + Environment.NewLine; }
                        if (td.t2partBox[i].Text == "") { if (tb == null) { tb = td.t2partBox[i]; } err += "Please enter " + h[td.t2partBox[i].Name.ToString().Substring(2, 4)] + " " + (i + 1) + Environment.NewLine; }
                        if (td.t2operBox[i].Text == "") { if (tb == null) { tb = td.t2operBox[i]; } err += "Please enter " + h[td.t2operBox[i].Name.ToString().Substring(2, 3)] + " " + (i + 1) + Environment.NewLine; }

                    }
                    j++;
                }
                if (err == string.Empty && cmd != string.Empty)
                {
                    if (MessageBox.Show(showCmd, "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        m = t.ToArray();
                        n = k.ToArray();
                        //td.ClearBoxes(m);
                        td.MakeReadOnly(m);
                        td.MakeNotReadOnly(n);
                        string fullCmd = getCurrTime() + "|" + "program-config" + "|" + cmd + "\n";
                        switchBtn(1, td.t2btn);
                        disableAllMenu();
                        tcp.sndData(fullCmd);
                        tcp.HoldBuffer(fullCmd,2);
                    }
                }
                else
                {
                    this.ActiveControl = tb;
                    MessageBox.Show(err, "Error");
                }

            }
            else if (flg == 2)
            {
                TextBox tb = new TextBox();
                tb = null;
                string showCmd = string.Empty;
                for (int i = 0; i < 4; i++)
                {
                    if (td.t2gpbox[i].Enabled == true)
                    {
                        if (td.t2gpbox[i].Text == "") { if (tb == null) { tb = td.t2gpbox[i]; } err += "Please enter " + h[td.t2gpbox[i].Name.ToString().Substring(2, 2)] + " " + (i + 1) + Environment.NewLine; }
                        if (td.t2bpbox[i].Text == "") { if (tb == null) { tb = td.t2bpbox[i]; } err += "Please enter " + h[td.t2bpbox[i].Name.ToString().Substring(2, 2)] + " " + (i + 1) + Environment.NewLine; }
                        if (td.t2gpbox[i].Text != "" && td.t2bpbox[i].Text != "")
                        {
                            showCmd += "Good Parts " + j + " - " + td.t2gpbox[i].Text + "\nBad Parts " + j + " - " + td.t2bpbox[i].Text + "\n\n";
                            cmd += "good" + j + "=" + td.t2gpbox[i].Text + ";bad" + j + "=" + td.t2bpbox[i].Text + ";";
                        }
                    }
                    j++;
                }
                if (err == string.Empty && cmd != string.Empty)
                {
                    if (td.CheckNumeric(td.t2gpbox) && td.CheckNumeric(td.t2bpbox))
                    {
                        if (MessageBox.Show(showCmd, "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            string fullCmd = getCurrTime() + "|" + "part-count-multiple" + "|" + cmd + "\n";
                            switchBtn(2, td.t2btn);
                            tcp.sndData(fullCmd);
                            tcp.HoldBuffer(string.Empty, 2);
                            HandleAfterSend(td.t2stp, td.t2snd, 2, td.t2btn);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Enter only numbers for Part Count", "Error");
                    }
                }
                else
                {
                    this.ActiveControl = tb;
                    MessageBox.Show(err, "Error");
                }
            }
        }
 private void doLogin()
 {
     Validations val = new Validations();
     string error;
     if((error = val.ValidateLogin(curEmpIdTxt.Text)) == String.Empty)
     {
         logInPnl.Visible = false;
         logoutBtn.Visible = true;
         empIdIndLbl.Text = "Current Employee :";
         empIdLbl.Visible = true;
         empIdLbl.Text = curEmpIdTxt.Text;
         nrmlPicBox.Visible = false;
         if (isSetup.Checked) { appCat = "S"; empIdLbl.Text += " (Setup)"; setPixBox.Visible = true; } else { appCat = "P"; opPicBox.Visible = true; }
         settingBtn.Enabled = false;
         //logBtn.Enabled = false;
         loadDefaults();
         greetLbl.Visible = true;
         string cmd = getCurrTime() + "|EMP|" + curEmpIdTxt.Text + "\n";
         if (isSetup.Checked) { cmd += getCurrTime() + "|EMP-TYPE|setup\n"; } else { cmd += getCurrTime() + "|EMP-TYPE|production\n"; }
         tcp.HoldBuffer(cmd, 0);
         tcp.sndData(cmd);
         MainfestionComboBoxes();
         macNameLbl.Text = Properties.Settings.Default.machinename;
     }
     else
     {
         Error(error);
     }
 }