示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có thật sự muốn xoá nhân viên này", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         Lnhanvien nv = new Lnhanvien();
         nv.set_manhanvien(txtmanv.Text);
         if (nv.xoabo() == true)
         {
             MessageBox.Show("Bạn đã xoá bỏ thành công");
             listView1.Items[i].Remove();
             DataRow dr = ds.Tables[0].Rows.Find(txtmanv.Text);
             ds.Tables[0].Rows.Remove(dr);
             for (int j = i; j < ds.Tables[0].Rows.Count - 1; j++)
             {
                 s[j] = s[j + 1];
             }
             if (i > 0)
             {
                 i = i - 1;
             }
             load_textbox(i);
         }
         else
         {
             MessageBox.Show("Quá trình xoá bỏ gặp thất bại bạn hãy kiểm tra lại");
         }
     }
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "OK")
            {
                button1.Text           = "Tạo mới";
                txtdiachi.Enabled      = false;
                txthoten.Enabled       = false;
                txttendangnhap.Enabled = false;
                comboBox1.Enabled      = false;
                Lnhanvien nv = new Lnhanvien();
                nv.set_manhanvien(txtmanv.Text);
                nv.set_matkhau("");
                nv.set_diachi(txtdiachi.Text);
                nv.set_hoten(txthoten.Text);
                nv.set_quyenhan(comboBox1.Text);
                nv.set_tendangnhap(txttendangnhap.Text);
                i = ds.Tables[0].Rows.Count;
                if (nv.taomoi())
                {
                    s[i] = txtmanv.Text;
                    //======cập nhật thông tin cho Dataset===========
                    DataRow dr;
                    dr    = ds.Tables[0].NewRow();
                    dr[0] = txtmanv.Text;
                    dr[1] = txthoten.Text;
                    dr[2] = txtdiachi.Text;
                    dr[3] = txttendangnhap.Text;
                    dr[4] = "";
                    dr[5] = comboBox1.Text;
                    ds.Tables[0].Rows.Add(dr);
                    //-------------------------------

                    //======Cập nhật thông tin cho Listview==========
                    listView1.Items.Add(txthoten.Text, 1);
                    listView1.Items[i].SubItems.Add(txtdiachi.Text);
                    listView1.Items[i].SubItems.Add(txttendangnhap.Text);
                    listView1.Items[i].SubItems.Add(comboBox1.Text);
                    //---------------------------------
                    MessageBox.Show("Quá trình tạo mới đã thành công");
                }
                else
                {
                    MessageBox.Show("Quá trình tạo mới bị lỗi bạn hãy thử lại");
                }
            }
            else
            {
                button1.Text           = "OK";
                txtdiachi.Enabled      = true;
                txthoten.Enabled       = true;
                txttendangnhap.Enabled = true;
                comboBox1.Enabled      = true;
                txtdiachi.Text         = "";
                txthoten.Text          = "";
                txttendangnhap.Text    = "";
                txtmanv.Text           = taoma(s[ds.Tables[0].Rows.Count - 1]);
            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str = treeView1.SelectedNode.Tag.ToString();

            if (str != "Ro")
            {
                if (tam)
                {
                    listView1.Enabled = true;
                    tam          = false;
                    button1.Text = "OK";
                }
                else
                {
                    string st = "";
                    for (int i = 0; i < listView1.CheckedItems.Count; i++)
                    {
                        st = st + listView1.CheckedItems[i].Text;
                    }
                    MessageBox.Show(st);
                    if (st != "")
                    {
                        Lnhanvien nv = new Lnhanvien();
                        nv.set_manhanvien(str.Substring(1, str.Length - 1));
                        if (st.IndexOf("ADMIN") >= 0)
                        {
                            nv.nangquyen("ADMIN");
                        }
                        else
                        {
                            nv.nangquyen(st);
                        }
                        button1.Text      = "Phân quyền";
                        tam               = true;
                        listView1.Enabled = false;
                        MessageBox.Show("Đã thực hiện thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                    else
                    {
                        MessageBox.Show("Hãy kiểm tra lại giá trị quyền hạn", "Thông báo");
                    }
                }
            }
            else
            {
                MessageBox.Show("Bạn phải chọn nhân viên", "Thông báo");
            }
        }