private void btnDeleteCompanySelect_Click(object sender, EventArgs e)
        {
            var               db          = new Model1();
            string            message     = string.Empty;
            List <NHACUNGCAP> listCompany = new List <NHACUNGCAP>();

            foreach (DataGridViewRow row in dgvAllCompany.Rows)
            {
                bool isSelected = Convert.ToBoolean(row.Cells["ckDelete"].Value);
                if (isSelected)
                {
                    var company = new NHACUNGCAP
                    {
                        IdNhaCungCap = row.Cells["MaNhaCungCap"].Value.ToString(),
                        IdNguyenLieu = row.Cells["hiddenIdNguyenLieu"].Value.ToString(),
                    };
                    db.NhaCungCap.Attach(company);
                    listCompany.Add(company);
                    message += Environment.NewLine;
                    message += row.Cells["TenCongTy"].Value.ToString() + " cung cấp nguyên liệu: " + row.Cells["NguyenLieu"].Value.ToString();
                }
            }

            db.NhaCungCap.RemoveRange(listCompany);
            db.SaveChanges();
            LoadAllCompany();
            MessageBox.Show("Thông tin các nguyên liệu của nhà cung cấp đã được xóa:" + message);
        }
        private void btnRegisterCompany_Click(object sender, EventArgs e)
        {
            var db = new Model1();

            List <NHACUNGCAP> listCompany = new List <NHACUNGCAP>();

            foreach (KeyValuePair <string, double> source in dicDanhSachChonNguyenLieu)
            {
                var company = new NHACUNGCAP
                {
                    IdNhaCungCap  = txtIDCompany.Text,
                    TenNhaCungCap = txtCompanyName.Text,
                    DiaChi        = txtAddress.Text,
                    SoDienThoai   = txtPhone.Text,
                    IdNguyenLieu  = source.Key,
                    Gia           = source.Value,
                    NgayDangKy    = DateTime.Now
                };
                listCompany.Add(company);
            }
            db.NhaCungCap.AddRange(listCompany);
            db.SaveChanges();
            LoadAllCompany();
        }