Beispiel #1
0
        private void btn_logIn_Click(object sender, EventArgs e)
        {
            DataTable     dt = new DataTable();
            MessagesClass ms = new MessagesClass();

            if (txt_UserName.Text == "")
            {
                MessageBox.Show("please enter UserName");
                return;
            }
            if (txt_Password.Text == "")
            {
                MessageBox.Show("please enter UserName");
                return;
            }

            dt = user.Search(txt_UserName.Text, txt_Password.Text);
            if (dt != null)
            {
                m.CurrentUserID = (int)dt.Rows[0]["id"];
                u.CurrentUserID = (int)dt.Rows[0]["id"];

                user.LogIn((int)dt.Rows[0]["id"]);///update online Status
                m.MdiParent = this.ParentForm;
                this.Hide();
                m.Show();
            }

            else
            {
                MessageBox.Show("UserName or Password is incorrect");
                return;
            }
        }
Beispiel #2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            MessageForm m  = new MessageForm();
            DataTable   dt = new DataTable();

            dt = user.Search(txt_username.Text);

            if (txt_name.Text == "")
            {
                MessageBox.Show("please enter name!");
                return;
            }
            if (txt_family.Text == "")
            {
                MessageBox.Show("please enter family!");
                return;
            }
            if (cmb_position.SelectedIndex == -1 && cmb_position.Text == "")
            {
                MessageBox.Show("please select position!");
                return;
            }
            if (txt_username.Text == "")
            {
                MessageBox.Show("please enter username!");
                return;
            }


            if (txt_password.Text == "")
            {
                MessageBox.Show("please enter password!");
                return;
            }
            if (txt_repeatpassword.Text == "")
            {
                MessageBox.Show("please enter repeatpassword!");
                return;
            }
            if (txt_password.Text != txt_repeatpassword.Text)
            {
                MessageBox.Show("please enter same password!");
                return;
            }
            if (dt != null)
            {
                MessageBox.Show("there is a user with  this username, so please change username");
                return;
            }
            else
            {
                user.Add(txt_name.Text, txt_family.Text, cmb_position.SelectedItem.ToString(), txt_username.Text, txt_password.Text);
                txt_name.Text              = "";
                txt_family.Text            = "";
                cmb_position.SelectedIndex = -1;
                txt_username.Text          = "";
                txt_password.Text          = "";
                txt_repeatpassword.Text    = "";
                btn_refresh_Click(btn_refresh, EventArgs.Empty);
                return;
            }
        }