예제 #1
0
        private void main_but_OK_Click(object sender, EventArgs e)
        {
            User current_usr = new User();
            SqlCommand command = new SqlCommand();
            command.Connection = con;
            command.CommandType = CommandType.Text;
            command.CommandText = "Select * from NHANVIEN where (username=@user) and (pass=@pass)";
            command.Parameters.Add("@user", SqlDbType.NVarChar, 50).Value = main_box_uname.Text;
            command.Parameters.Add("@pass", SqlDbType.NVarChar, 50).Value = main_box_pword.Text;
            da.SelectCommand = command;
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {

                QuanLy ql = new QuanLy();
                delPassData del = new delPassData(ql.funData);
                del(this.main_box_uname);
                ql.Show();
                Hide();
            }
            else
            {
                MessageBox.Show("Đăng nhập thất bại. Sai mật khẩu hoặc tên tài khoản");
            }
        }
 private void btchuyenbac_Click(object sender, EventArgs e)
 {
     if(txttths.Text == "")
     {
         MessageBox.Show("Vui lòng chọn nhân viên muốn chuyển bậc!");
     }
     else
     {
     ThemChuyenBac frmthem = new ThemChuyenBac();
     delPassData del = new delPassData(frmthem.Laydulieu);
     del(this.txtttma);
     frmthem.Show();
     }
 }
예제 #3
0
 private void logInBut_Click(object sender, EventArgs e)
 {
     SqlCommand command = new SqlCommand();
     command.Connection = con;
     command.CommandType = CommandType.Text;
     command.CommandText = "Select username,passworduser from NGUOIDUNG where (username=@user) and (passworduser=@pass)";
     command.Parameters.Add("@user", SqlDbType.NVarChar, 50).Value = uNameBox.Text;
     command.Parameters.Add("@pass", SqlDbType.NVarChar, 50).Value = pWordBox.Text;
     da.SelectCommand = command;
     da.Fill(dt);
     if (dt.Rows.Count > 0)
     {
         QuanLy ql = new QuanLy();
         delPassData del = new delPassData(ql.funData);
         del(this.txtTaikhoan);
         ql.Show();
         Hide();
     }
     else
     {
         MessageBox.Show("Đăng nhập thất bại. Sai mật khẩu hoặc tên tài khoản");
     }
 }
예제 #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (IP == null)
                {
                    IP = Dns.GetHostByName(Dns.GetHostName()).AddressList[0];
                }
                if (textBox1.Text == "" || textBox2.Text == "")
                {

                    MessageBox.Show("Username or Password incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                if (textBox5.Text == "" && checkBox2.Checked == false)
                {

                    MessageBox.Show("NumPort download incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                if ((textBox3.Text == "" || textBox4.Text == "") && checkBox1.Checked == false)
                {

                    MessageBox.Show("IP Address incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                //Input data IP and Port :
                String szPortDownload = textBox5.Text;
                if (checkBox2.Checked == true)
                {
                    szPortDownload = "9090";
                }
                else
                {
                    if (System.Convert.ToInt32(textBox5.Text, 10) < 65000)
                        szPortDownload = textBox5.Text;
                    else
                    {
                        MessageBox.Show("Port of Client between 0 and 65430");
                        return;
                    }
                }
                String szIPSelected = textBox3.Text;
                String szPort = textBox4.Text;
                if (checkBox1.Checked == true)
                {
                    szIPSelected = IP.ToString() ;
                    szPort = "8080";
                }
                int alPort = System.Convert.ToInt16(szPort, 10);

                //Create Socket :
                IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(szIPSelected), Convert.ToInt32(szPort));
                S_Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                //Connect :
                S_Client.Connect(ipep);

                //Send information from Client :
                string MyLogin = "******" + textBox1.Text.Trim() + "@" + textBox2.Text + "@" + szPortDownload+"@"+IP.ToString()+"@null";
                byte[] byMyLogin = System.Text.Encoding.ASCII.GetBytes(MyLogin);
                this.S_Client.Send(byMyLogin);

                //doi ket qua tu server :
                S_Client.ReceiveTimeout = 5000;
                byte[] login = new byte[64];
                int i_login = this.S_Client.Receive(login);
                char[] chars_login = new char[i_login];
                System.Text.Decoder d_login = System.Text.Encoding.UTF8.GetDecoder();
                int charLen = d_login.GetChars(login, 0, i_login, chars_login, 0);
                System.String S_login = new System.String(chars_login);

                if (S_login == "Login")
                {
                    button1.Enabled = false;
                    this.Hide();

                    //Close va deface giao dien tai day :
                    Download myDownload = new Download(S_Client, textBox1.Text);
                    delPassData del = new delPassData(myDownload.funData);
                    del(this.textBox5);
                    myDownload.Text = textBox1.Text;
                    myDownload.IP = IP;
                    myDownload.ShowDialog();

                    this.Close();
                }
                else
                    MessageBox.Show("Error Login! Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
예제 #5
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (IP == null)
                {
                    IP = Dns.GetHostByName(Dns.GetHostName()).AddressList[0];
                }
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("Username or Password incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                if (textBox5.Text == "" && checkBox2.Checked == false)
                {
                    MessageBox.Show("NumPort download incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                if ((textBox3.Text == "" || textBox4.Text == "") && checkBox1.Checked == false)
                {
                    MessageBox.Show("IP Address incorrect !", "MessageBox Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                    return;
                }
                //Input data IP and Port :
                String szPortDownload = textBox5.Text;
                if (checkBox2.Checked == true)
                {
                    szPortDownload = "9090";
                }
                else
                {
                    if (System.Convert.ToInt32(textBox5.Text, 10) < 65000)
                    {
                        szPortDownload = textBox5.Text;
                    }
                    else
                    {
                        MessageBox.Show("Port of Client between 0 and 65430");
                        return;
                    }
                }
                String szIPSelected = textBox3.Text;
                String szPort       = textBox4.Text;
                if (checkBox1.Checked == true)
                {
                    szIPSelected = IP.ToString();
                    szPort       = "8080";
                }
                int alPort = System.Convert.ToInt16(szPort, 10);

                //Create Socket :
                IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(szIPSelected), Convert.ToInt32(szPort));
                S_Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                //Connect :
                S_Client.Connect(ipep);

                //Send information from Client :
                string MyLogin   = "******" + textBox1.Text.Trim() + "@" + textBox2.Text + "@" + szPortDownload + "@" + IP.ToString() + "@null";
                byte[] byMyLogin = System.Text.Encoding.ASCII.GetBytes(MyLogin);
                this.S_Client.Send(byMyLogin);

                //doi ket qua tu server :
                S_Client.ReceiveTimeout = 5000;
                byte[] login                = new byte[64];
                int    i_login              = this.S_Client.Receive(login);
                char[] chars_login          = new char[i_login];
                System.Text.Decoder d_login = System.Text.Encoding.UTF8.GetDecoder();
                int           charLen       = d_login.GetChars(login, 0, i_login, chars_login, 0);
                System.String S_login       = new System.String(chars_login);

                if (S_login == "Login")
                {
                    button1.Enabled = false;
                    this.Hide();

                    //Close va deface giao dien tai day :
                    Download    myDownload = new Download(S_Client, textBox1.Text);
                    delPassData del        = new delPassData(myDownload.funData);
                    del(this.textBox5);
                    myDownload.Text = textBox1.Text;
                    myDownload.IP   = IP;
                    myDownload.ShowDialog();

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error Login! Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
        private void btSua_Click(object sender, EventArgs e)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();
            if (txttths.Text == "")
            {
                MessageBox.Show("Vui lòng chọn nhân viên muốn sửa!");
            }
            else
            {

            var u = from b in csdl.LichSuChuyenBacs where b.MaNV == txtttma.Text select b;
            int idmax = u.Max(b => b.id);
            string gttim = idmax.ToString();
            int VT = dataGridView1.CurrentCell.RowIndex;
            if (dataGridView1.Rows[VT].Cells[0].Value.ToString() != gttim)
            {
                MessageBox.Show("Đây không phải hệ số mới cập nhật của nhân viên!!");
            }
            else

                {
                    int CT = dataGridView1.CurrentCell.RowIndex;
                    int idtim = int.Parse(dataGridView1.Rows[CT].Cells[0].Value.ToString());
                    SuaLichSuChuyenBac frmsua = new SuaLichSuChuyenBac();
                    delPassData del = new delPassData(frmsua.Laydulieu);
                    laymasua lms = new laymasua(frmsua.Layma);
                    del(this.txtttma);
                    lms(this.txtid);
                    frmsua.Show();
                 }
            }
        }