예제 #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //Check all textbox filled or not
            if (fncBlank() == true)
            {
                return;
            }


            try
            {
                #region Check Valid User in Database

                //if (fncSoftwareExDate()==true)
                //{
                // return;
                //}

                //Software Validation

                clsMain.strValidationDB = clsProc.GTRVaildationSQL();
                clsMain.strValidBTDB    = clsProc.GTRVaildationSQLBT();


                if (fncSoftwareExDateDB() == true)
                {
                    return;
                }

                System.Data.DataSet dsLogin = new System.Data.DataSet();
                clsForm.prcGetLoginDetails(ref dsLogin, txtUser.Text.ToString().Trim(), txtPassword.Text.ToString().Trim());

                if (dsLogin.Tables["Login"].Rows.Count == 0)
                {
                    //if invalid user
                    MessageBox.Show("Invalid user name or password", this.Text, MessageBoxButtons.OK);
                    txtUser.Focus();
                    return;
                }
                else
                {
                    //If valid user
                    DataTable dt = dsLogin.Tables["Login"];

                    //User Id & Name
                    clsMain.intUserId   = (Int32)dt.Rows[0]["LUserId"];
                    clsMain.strUser     = dt.Rows[0]["EmpNameCode"].ToString();
                    clsMain.strUserCode = dt.Rows[0]["EmpCode"].ToString();

                    //User SubGroupId & SubGroupName
                    clsMain.intSGroupId   = Int32.Parse(dt.Rows[0]["LSubGroupId"].ToString());
                    clsMain.strSGroupName = dt.Rows[0]["LSubGroupName"].ToString();

                    //User GroupId & GroupName
                    clsMain.intGroupId   = Int32.Parse(dt.Rows[0]["LGroupId"].ToString());
                    clsMain.strGroupName = dt.Rows[0]["LGroupName"].ToString();

                    //clsMain.intSalaryId = dt.Rows[0]["IsSalary"].ToString();
                    //clsMain.intAttProssId = dt.Rows[0]["IsAttPross"].ToString();

                    //Transaction Date
                    clsMain.strTranDate = dt.Rows[0]["LoginDate"].ToString();

                    //Computer Name
                    clsMain.strComputerName = clsProc.GTRGetComputerName();

                    //Computer IP Address
                    clsMain.strIPAddress = clsProc.GTRGetIPAddress();

                    //Computer Mac Address
                    clsMain.strMacAddress = "";//clsProc.GTRGetMacAddress();
                }
                #endregion Check Valid User in Database

                #region User log update
                clsM.prcLogin();
                #endregion

                #region Configuration
                clsMain.SetConfiguration();
                #endregion Configuration

                #region call & loading next window
                FM.prcConfigureForm();
                this.Close();
                #endregion call & loading next window
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }