示例#1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMahoadon.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã hóa đơn!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMahoadon.Focus();
                return;
            }
            if (txtNgaynhap.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập ngày nhập!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNgaynhap.Focus();
                return;
            }
            if (cboMaNCC.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã nhà cung cấp!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMaNCC.Focus();
                return;
            }
            if (cboManhanvien.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã nhân viên!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboManhanvien.Focus();
                return;
            }
            sql = "Insert into tblHoaDonNhap(MaHDN, NgayNhap, MaNV, MaNCC, TongTien) values ( N'" + txtMahoadon.Text.Trim() + "', '" + ThucThiSQL.ConvertDateTime(txtNgaynhap.Text) + "', N'" + cboManhanvien.Text.Trim() + "', N'" + cboMaNCC.Text.Trim() + "', N'" + Convert.ToDouble(txtThanhtien.Text) + "')";
            ThucThiSQL.CapNhatDuLieu(sql);
            btnLuu.Enabled        = false;
            grbChitietHDN.Enabled = true;
            Hienthi_Luoi();
        }