Пример #1
0
        private void frmSach_Load(object sender, EventArgs e)
        {
            tblSach = new XLSach();
            tblNCC  = new XLNhaCungCap();
            loadCTSach();
            loadNCC();
            rdTheoMa.Checked = true;
            daSach           = new SqlDataAdapter("Select * from SACH", XLSach.cnnStr);
            daNCC            = new SqlDataAdapter("Select * from NHACUNGCAP", XLNhaCungCap.cnnStr);
            try
            {
                daSach.Fill(tblSach);
                daNCC.Fill(tblNCC);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            var cmb = new SqlCommandBuilder(daSach);

            txtMaSach.DataBindings.Add("text", tblSach, "MaSach", true);
            txtNXB.DataBindings.Add("text", tblSach, "NXB", true);
            txtTacGia.DataBindings.Add("text", tblSach, "TacGia", true);
            txtTenSach.DataBindings.Add("text", tblSach, "TenSach", true);
            txtTheLoai.DataBindings.Add("text", tblSach, "TheLoai", true);
            nudSLTon.DataBindings.Add("value", tblSach, "SLTon", true);
            pSach.DataBindings.Add("Image", tblSach, "Hinh", true);
            cbNCC.DataBindings.Add("SelectedValue", tblSach, "MaNCC", true);
            DSSach = this.BindingContext[tblSach];
            enabledButton();
            dgvTTSach.AutoGenerateColumns = false;
            dgvTTSach.DataSource          = tblSach;
        }
Пример #2
0
        private void frmNCC_Load(object sender, EventArgs e)
        {
            tblNCC           = new XLNhaCungCap();
            rdTheoMa.Checked = true;
            daNCC            = new SqlDataAdapter("Select * from NHACUNGCAP", XLNhaCungCap.cnnStr);
            try
            {
                daNCC.Fill(tblNCC);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            var cmb = new SqlCommandBuilder(daNCC);

            txtMaNCC.DataBindings.Add("text", tblNCC, "MaNCC", true);
            txtTenNCC.DataBindings.Add("text", tblNCC, "TenNCC", true);
            txtDiaChi.DataBindings.Add("text", tblNCC, "DiaChi", true);
            txtSDT.DataBindings.Add("text", tblNCC, "SDT", true);
            DSNCC = this.BindingContext[tblNCC];
            enabledButton();
            dgvTTNCC.AutoGenerateColumns = false;
            dgvTTNCC.DataSource          = tblNCC;
        }