Beispiel #1
0
 public WorkForm(Teacher teacher, FormLogin parentForm, StudentServiceClient proxy)
 {
     InitializeComponent();
     _teacher = teacher;
     _parrentForm = parentForm;
     _proxy = proxy;
 } 
Beispiel #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FormLogin form = new FormLogin();

            form.ShowDialog();
            if (StatusCode == 1)
            {
                Application.Run(new FormMain());
            }
        }
Beispiel #3
0
        public FormClient()
        {
            InitializeComponent();


            FormLogin login = new FormLogin();

            if (login.ShowDialog() != DialogResult.OK)
            {
                Dispose();
                Application.Exit();
            }
        }
Beispiel #4
0
        // Connect
        void Connect()
        {
            IP     = new IPEndPoint(IPAddress.Parse(IPaddress), 7421);
            Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            try
            {
                Client.Connect(IP);
            }
            catch
            {
                FormLogin fLogin = new FormLogin();
                MessageBox.Show("Không thể kết nối server !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Thread listen = new Thread(Receive);

            listen.IsBackground = true;
            listen.Start();
            Client.Send(Serialize(User + Temp + "Đã kết nối"));
        }
Beispiel #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool loginSuccessful = false;

            FormLogin login = new FormLogin();

            if (login.ShowDialog() == DialogResult.OK)
            {
                // Attempt login
            }


            if (true) // TODO Login successful
            {
                Application.Run(new FormMain());
            }
        }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FormLogin fLogin = new FormLogin();

            try
            {
                this.Show();
                // AttempLogin();
                fLogin.ShowDialog(this);
                fLogin.Dispose();
                User        = fLogin.textBox1.Text;
                label1.Text = User;
                IPaddress   = fLogin.textBox_IP.Text;
                Connect();
                // Client.Send(Serialize(User + Temp + "Connect"));
                labelIP.Visible = true;
                labelIP.Text    = Client.RemoteEndPoint.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Không thể kết nối Server. Vui lòng thực hiện lại đăng nhập !!!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.Dispose();
            }
        }
Beispiel #7
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            MainForm  mainForm  = new MainForm();
            FormLogin loginForm = new FormLogin();

            //Login authentificator
            SqlConnection con = new SqlConnection(Properties.Settings.Default.connString);

            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select count (*) from UsersInfo where loginName ='" + NameTextBox.Text + "' and password ='******'", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                mainForm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("USER DOES NOT EXIST", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            /*  MainForm mainForm = new MainForm();
             * FormLogin loginForm = new FormLogin();
             *
             * if (isPasswordOk() && isNameOk())
             * {
             *    using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.connString))
             *    {
             *        const String sql = "SELECT * FROM UsersInfo WHERE loginName = '@LoginName' AND 'password' = @Password";
             *
             *        using (SqlCommand sqlCommand = new SqlCommand(sql, connection))
             *        {
             *            sqlCommand.Parameters.Add(new SqlParameter("@LoginName", SqlDbType.VarChar, 50));
             *            sqlCommand.Parameters["@LoginName"].Value = NameTextBox.Text;
             *
             *            sqlCommand.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 50));
             *            sqlCommand.Parameters["@Password"].Value = PasswordTextbox.Text;
             *
             *            try
             *            {
             *                connection.Open();
             *
             *                SqlDataReader dataReader = sqlCommand.ExecuteReader();
             *                if ((dataReader.Read() == true))
             *                {
             *                    MessageBox.Show("Logged in");
             *                    mainForm.Show();
             *                    this.Hide();
             *                }
             *                else
             *                {
             *                    MessageBox.Show("USER DOES NOT EXIST", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *
             *                }
             *            }
             *
             *            catch
             *            {
             *                MessageBox.Show("Some SQL error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *            }
             *            finally
             *            {
             *                ClearForm();
             *                connection.Close();
             *            }
             *        }
             *    }
             * } */
        }