示例#1
0
        private void btnXacnhan_Click(object sender, EventArgs e)
        {
            if (txtThongTinHoTen.Text != "")
            {
                string hovaten = txtThongTinHoTen.Text;
                string Sdt     = txtThongTinSoDT.Text;

                string SmatTrai = txtSmatTrai.Text;
                string AmatTrai = txtAmatTrai.Text;
                string CmatTrai = txtCmatTrai.Text;

                string SmatPhai = txtSmatPhai.Text;
                string AmatPhai = txtAmatPhai.Text;
                string CmatPhai = txtCmatPhai.Text;
                string Add      = txtADD.Text;

                string            message = "Bạn có muốn thêm khách hàng này vào cơ sở dữ liệu";
                string            caption = "Thêm khách hàng!";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result;

                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    XulyDuLieu.insertTable(hovaten, Sdt, SmatTrai, AmatTrai, CmatTrai, SmatPhai, AmatPhai, CmatPhai, Add);
                    btnThemThongTin.Visible = true;
                    btnSuaThongtin.Visible  = true;
                    btnXoa.Visible          = true;

                    btnXacnhan.Visible = false;

                    LamMoiGroup();

                    Id = 0;
                }
            }
            else
            {
                MessageBox.Show("Đừng để trống tên khách hàng");
            }
            loadData("Select id, hovaten as [Họ và Tên], sodienthoai as [Số điện thoại], " +
                     "SmatTrai as [S Trái], AmatTrai as [A Trái], CmatTrai as [C Trái]," +
                     "SmatPhai as [S Phải], AmatPhai as [A Phải], CmatPhai as [C Phải], addMat from tbl_khachhang");
        }