private void btn_accept_Click(object sender, EventArgs e)
        {
            readonly_textboxes(true);
            btn_editphieukham.Visible = true;
            btn_accept.Visible        = false;
            btn_cancel.Visible        = false;

            if (txt_hotenbn.Text != temp_hoten || txt_diachibn.Text != temp_address || txt_sdtbn.Text != temp_phone ||
                txt_tuoibn.Text != temp_tuoi || txt_para.Text != temp_PARA || txt_nghenghiep.Text != temp_nghenghiep ||
                txt_tiencangd.Text != temp_tiencangd || txt_tiencanbn.Text != temp_tiencanbt)
            {
                string sql = "update benhnhan set ten=\"" + txt_hotenbn.Text + "\", address=\"" + txt_diachibn.Text + "\", phone_num=\""
                             + txt_sdtbn.Text + "\", tuoi=\"" + txt_tuoibn.Text + "\", PARA=\"" + txt_para.Text + "\", nghe_nghiep=\"" + txt_nghenghiep.Text
                             + "\", tiencan_gd=\"" + txt_tiencangd.Text + "\", tiencan_bt=\"" + txt_tiencanbn.Text + "\" where idBN=" + txt_idbn.Text;
                try
                {
                    db.OpenConnection();
                    db.ExecuteNonQuery(sql);
                    db.CloseConnection();
                    updateDscho();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            loaddsbn("select * from benhnhan");
            groupbox_dichvu.Enabled = groupbox_dsbn.Enabled = groupbox_timkiem.Enabled = true;
        }
Exemple #2
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                string          path    = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "config/connection_info.cfg");
                string[]        coninfo = System.IO.File.ReadAllLines(path);
                ConnDb.ConnData db      = new ConnDb.ConnData(coninfo[0], coninfo[1], coninfo[2], coninfo[3]);

                string insert = "insert into thuoc(ten_thuoc, dvt, so_luong, gia_mua, gia_ban, han_sd) values('" + txt_tenthuoc.Text + "', '" + txt_dvt.Text + "', '" +
                                txt_soluong.Text + "', '" + txt_giamua.Text + "', '" + txt_giaban.Text + "', '" + txt_hsd.Text + "')";

                db.OpenConnection();
                db.ExecuteNonQuery(insert);
                db.CloseConnection();

                txt_tenthuoc.Clear();
                txt_soluong.Clear();
                txt_hsd.Clear();
                txt_giamua.Clear();
                txt_giaban.Clear();
                txt_dvt.Clear();

                Owner.Activate();
                Activate();
            } catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            int selected = dtgv_dsthuoc.SelectedRows[0].Index;

            var confirmationResult = MessageBox.Show("Bạn có chắc muốn xóa " + dtgv_dsthuoc.Rows[selected].Cells["tenthuoc"].Value.ToString() + "?", "Xác nhận", MessageBoxButtons.YesNo);

            if (confirmationResult == DialogResult.No)
            {
                return;
            }
            string query = "delete from thuoc where idThuoc=" + dtgv_dsthuoc.Rows[selected].Cells["id"].Value.ToString();

            try
            {
                db.OpenConnection();
                db.ExecuteNonQuery(query);
                db.CloseConnection();
                MessageBox.Show("Done!");
                update_gridview_dsthuoc("select * from thuoc");
            } catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }