private void btnEnter_Click(object sender, EventArgs e) { bool CheckUser = false; if (txtUserName.Text == "") { MessageBox.Show("Please Enter User Name..", "Data Missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUserName.Focus(); return; } if (txtpassword.Text == "") { MessageBox.Show("Please Enter New Password..", "Data Missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtpassword.Focus(); return; } DBClass.SetConnectionString(); if (txtSecretPwd.Text == "2713") { DBClass.AddUser(txtUserName.Text, txtpassword.Text); } dt = DBClass.GetTableRecords("User_Master"); ds = new DataSet(); ds.Tables.Add(dt); if (ds.Tables[0].Rows.Count > 0) { DBClass.UserId = DBClass.GetUserIdByUsernameAndPassword(txtUserName.Text, txtpassword.Text); DBClass.UserName = txtUserName.Text; DBClass.UserType = DBClass.GetColValueByQuery("Select User_Type from User_Master where User_Id=" + DBClass.UserId); if (DBClass.UserId > 0) { CheckUser = true; } } if (CheckUser) { Username = txtUserName.Text; this.Hide(); Base obj = new Base(); obj.ShowDialog(); } else { MessageBox.Show("Invalid Username or Password", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtUserName.Text = ""; txtpassword.Text = ""; txtUserName.Focus(); //txtpassword.Focus(); return; } }