Exemplo n.º 1
0
        private void Login()
        {
            string tmpHolder = "SELECT Username, Password FROM tblSysUsers WHERE Username = '******' AND Password ='******'";

            if (globalData.AlreadyExist(tmpHolder) == true)
            {
                string tmpHolderAuth = "SELECT * FROM tblServerAuth WHERE MacAddress='" + GlobalData.GetMACAddress() + "'";
                if (globalData.AlreadyExist(tmpHolderAuth) == true)
                {
                    DateTime tmpSDate = Convert.ToDateTime(globalData.GetValue(tmpHolderAuth, "StartDate"));
                    DateTime tmpEDate = Convert.ToDateTime(globalData.GetValue(tmpHolderAuth, "EndDate"));

                    var    Different = tmpEDate - DateTime.Now;
                    double tmpDays   = Different.TotalDays;
                    if (tmpDays == 0 || tmpDays < 0)
                    {
                        MessageBox.Show("Your Software License is Upto Date, Please Purchase License ", "Authendication Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        getUserInfo();
                        getCompanyInfo();
                        GlobalData.GCompName  = globalData.GetValue("SELECT * FROM tblCompany WHERE CustID=" + GlobalData.GCompID + "", "NameOF");
                        GlobalData.GUserGroup = globalData.GetValue("SELECT * FROM tblUserGroup WHERE CustID=" + gUserGroupID + "", "NameOF");

                        string stockRommID = globalData.GetValue("SELECT * FROM tblSetCompStockRoom WHERE CompID = " + GlobalData.GCompID + "", "StockRoomID");
                        if (string.IsNullOrEmpty(stockRommID))
                        {
                            GlobalData.GStockRoomID = 0;
                        }
                        else
                        {
                            GlobalData.GStockRoomID = Convert.ToInt32(stockRommID);
                        }

                        this.Hide();

                        frmIPMain f = new frmIPMain();
                        f.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Sorry.. This PC don't have license ", "Authendication Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                LoginAttempts += 1;
                MessageBox.Show("Sorry.. Username/ Password is incorrect", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (LoginAttempts == 3)
                {
                    Environment.Exit(0);
                }
                return;
            }
        }