Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection ketnoi = Connect.taoketnoi();

            ketnoi.Open();
            string     st  = "select count(*) from Diem where id='" + textBox1.Text + "'";
            int        i   = 0;
            SqlCommand cmd = new SqlCommand(st, ketnoi);

            i = (int)cmd.ExecuteScalar();
            if (i == 0)
            {
                MessageBox.Show("ID không tồn tại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Text  = "";
                comboBox1.Text = "";
                comboBox2.Text = "";
                textBox4.Text  = "";
            }
            else
            {
                try
                {
                    String sql = "update Diem set masv='" + comboBox1.Text + "',mamh ='" + comboBox2.Text + "',diem ='" + textBox4.Text + "' where id = '" + textBox1.Text + "'";
                    Connect.ThemXuaXoa(sql);
                    MessageBox.Show("Sửa thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    load();
                }
                catch (Exception)
                {
                    MessageBox.Show("Thao tác không thực hiên được!", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection ketnoi = Connect.taoketnoi();

            ketnoi.Open();
            string     st  = "select count(*) from ChinhSach where macs='" + textBox1.Text + "'";
            int        i   = 0;
            SqlCommand cmd = new SqlCommand(st, ketnoi);

            i = (int)cmd.ExecuteScalar();
            if (i == 0)
            {
                MessageBox.Show("Mã chính sách không tồn tại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                textBox1.Text = "";
                textBox2.Text = "";
            }
            else
            {
                try
                {
                    String sql = "update ChinhSach set tencs=N'" + textBox2.Text + "',chedo =N'" + comboBox1.Text + "' where macs =N'" + textBox1.Text + "'";
                    Connect.ThemXuaXoa(sql);
                    load();
                }
                catch (Exception)
                {
                    MessageBox.Show("Thao tác không thực hiên được!", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
        }
Exemple #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult rs;

            rs = MessageBox.Show("Bạn thực sự muốn xóa ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (rs == DialogResult.OK)
            {
                SqlConnection ketnoi = Connect.taoketnoi();
                ketnoi.Open();
                string     st  = "select count(*) from Diem where id='" + textBox1.Text + "'";
                int        i   = 0;
                SqlCommand cmd = new SqlCommand(st, ketnoi);
                i = (int)cmd.ExecuteScalar();
                if (i == 0)
                {
                    MessageBox.Show("ID không tồn tại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox1.Text  = "";
                    comboBox1.Text = "";
                    comboBox2.Text = "";
                    textBox4.Text  = "";
                }

                else
                {
                    try
                    {
                        String sql = "delete from diem where id = '" + textBox1.Text + "'";
                        Connect.ThemXuaXoa(sql);
                        textBox1.Text  = "";
                        comboBox1.Text = "";
                        comboBox2.Text = "";
                        textBox4.Text  = "";
                        load();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Tài khoản này ko có trong hệ thống !!", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult rs;

            rs = MessageBox.Show("Nhom 3 - [email protected] \n Bạn thực sự muốn xóa chính sách này ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (rs == DialogResult.OK)
            {
                SqlConnection ketnoi = Connect.taoketnoi();
                ketnoi.Open();
                //int id = Convert.ToInt32(txbAcc.Text.Trim());
                string     st  = "select count(*) from ChinhSach where macs='" + textBox1.Text + "'";
                int        i   = 0;
                SqlCommand cmd = new SqlCommand(st, ketnoi);
                i = (int)cmd.ExecuteScalar();
                if (i == 0)
                {
                    MessageBox.Show("Mã chính sách không tồn tại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    textBox1.Text = "";
                    textBox2.Text = "";
                }
                else
                {
                    try
                    {
                        String sql = "delete from ChinhSach where macs = '" + textBox1.Text + "'";
                        Connect.ThemXuaXoa(sql);
                        textBox1.Text = "";
                        textBox2.Text = "";
                        load();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Thao tác không thực hiên được!", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
            }
        }