Ejemplo n.º 1
0
        private void btnTiepTanThem_Click(object sender, EventArgs e)
        {
            OracleDataProvider.conn.Open();
            OracleCommand cmdIn = new OracleCommand("qlbv.add_benhnhan", OracleDataProvider.conn);

            cmdIn.Parameters.Clear();
            cmdIn.CommandType = CommandType.StoredProcedure;
            cmdIn.Parameters.Add(new OracleParameter("name_bn", tbxTiepTanTenBN.Text));
            cmdIn.Parameters.Add(new OracleParameter("add_bn", tbxTiepTanDiaChi.Text));
            cmdIn.Parameters.Add(new OracleParameter("phone", tbxTiepTanDT.Text));
            int t = (radioBtnTiepTanNam.Checked == true ? 1 : 0);

            cmdIn.Parameters.Add(new OracleParameter("phai1", t.ToString()));
            cmdIn.Parameters.Add(new OracleParameter("datens", dateTimePickerNgSinh.Value.ToString("MM-dd-yy")));
            cmdIn.Parameters.Add(new OracleParameter("ic", tbxTiepTanCMND.Text));
            cmdIn.Parameters.Add("idbn", OracleDbType.Varchar2, 1000).Direction = ParameterDirection.Output;
            cmdIn.Parameters["idbn"].Size = 255;

            int ret = cmdIn.ExecuteNonQuery();

            txbDieuPhoiMaBN.Text = cmdIn.Parameters["idbn"].Value.ToString();
            if (ret == -1)
            {
                MessageBox.Show("Them thanh cong!");
            }

            OracleDataProvider.DisConnect();

            OracleDataProvider.conn.Open();
            string    sql = "select * from QLBV.BENHNHAN ORDER BY MABN DESC";
            DataTable dt  = OracleDataProvider.GetDataTable(sql);

            dataGridViewTiepTanTTBN.DataSource = dt;
        }
Ejemplo n.º 2
0
        private void btnUserAlterOK_Click(object sender, EventArgs e)
        {
            OracleDataProvider.Connect(connect);
            string sql = null;

            if (cbxUserAlterRoleCu.Text != "")
            {
                sql = "revoke " + cbxUserAlterRoleCu.Text + " from " + cbxUserAlter.SelectedItem.ToString();
                // sql += "; grant " + cbxUserAlterRoleMoi.SelectedItem.ToString() + " to " + cbxUserAlter.SelectedItem.ToString()+";";
                OracleCommand cmd = new OracleCommand(sql, OracleDataProvider.conn);
                int           ret = cmd.ExecuteNonQuery();
            }
            cbxUserAlterRoleCu.Text = "";
            //OracleDataProvider.conn.Open();
            sql = "grant " + cbxUserAlterRoleMoi.SelectedItem.ToString() + " to " + cbxUserAlter.SelectedItem.ToString();
            OracleCommand cmd1 = new OracleCommand(sql, OracleDataProvider.conn);
            int           ret1 = cmd1.ExecuteNonQuery();

            OracleDataProvider.DisConnect();
        }
Ejemplo n.º 3
0
        private void btnAddRoleOK_Click(object sender, EventArgs e)
        {
            string role = "select role from dba_roles where common = " + "\'NO\' AND role = '" + txbAddRole.Text + "'";

            OracleDataProvider.Connect(fLogin.cn);
            DataTable dt = OracleDataProvider.GetDataTable(role);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Đã tồn tại rồi !");
            }
            else
            {
                OracleDataProvider.conn.Open();
                String        queryRevoke = "CREATE ROLE " + txbAddRole.Text;
                OracleCommand cmdRevoke   = new OracleCommand(queryRevoke, OracleDataProvider.conn);
                int           ret         = cmdRevoke.ExecuteNonQuery();
                if (ret == -1)
                {
                    MessageBox.Show("Thêm Role thành công!");
                }
            }
            OracleDataProvider.DisConnect();
        }
Ejemplo n.º 4
0
        private void btnUserDeleteOK_Click(object sender, EventArgs e)
        {
            string username = null;

            if (cbxUserDelete.SelectedIndex != -1)
            {
                username = cbxUserDelete.SelectedItem.ToString();
            }
            OracleDataProvider.Connect(fLogin.cn);
            string dlItem = "drop user " + username;

            if (checkBoxUserDeleteCascade.Checked == true)
            {
                dlItem += " " + checkBoxUserDeleteCascade.Text;
            }
            OracleCommand cmd = new OracleCommand(dlItem, OracleDataProvider.conn);
            int           ret = cmd.ExecuteNonQuery();

            if (ret == -1)
            {
                MessageBox.Show("Đã xóa user thành công!");
            }
            OracleDataProvider.DisConnect();
        }
Ejemplo n.º 5
0
 private void fQLChuyenMon_FormClosing(object sender, FormClosingEventArgs e)
 {
     OracleDataProvider.DisConnect();
 }
Ejemplo n.º 6
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            username = txbUsername.Text;
            password = txbPassword.Text;
            string connect = OracleDataProvider.stringConnection("10.211.55.4", 1521, "orcl3", username, password);

            try
            {
                OracleDataProvider.Connect(connect);
                cn = connect;
                if (username.Equals("QLBV"))
                {
                    var frm = new fAdmin();
                    this.Hide();
                    frm.ShowDialog();
                    this.Show();
                    OracleDataProvider.DisConnect();
                }
                else
                {
                    string    sql = "select DISTINCT ROLE from role_tab_privs";
                    DataTable dt  = OracleDataProvider.GetDataTable(sql);
                    if (dt.Rows[0][0].ToString().Equals("BV_BS"))
                    {
                        var frm = new fBacSi();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_TTDP"))
                    {
                        var frm = new fTiepTanDieuPhoi();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_NVKT"))
                    {
                        var frm = new fKeToan();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_QLCM"))
                    {
                        var frm = new fQLChuyenMon();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_KTV"))
                    {
                        var frm = new fKyThuatVien();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_QLTV"))
                    {
                        var frm = new fQLTaiVu();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_QLTNNS"))
                    {
                        var frm = new fQLTaiNguyenNhanSu();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_NVTV"))
                    {
                        var frm = new fTaiVu();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                    if (dt.Rows[0][0].ToString().Equals("BV_NVBT"))
                    {
                        var frm = new fBanThuoc();
                        this.Hide();
                        frm.ShowDialog();
                        this.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //if (txbUsername.Text == "admin" && txbPassword.Text == "admin")
            //{
            //    fAdmin f = new fAdmin();
            //    this.Hide();
            //    f.ShowDialog();
            //    this.Show();
            //}
            //else
            //{
            //    MessageBox.Show("Sai mật khẩu hoặc password !", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //}
        }