Ejemplo n.º 1
0
        private void Load_Data_Grid(int id)
        {
            Product           repository = new Product();
            ProductVendorLink repo       = new ProductVendorLink();
            var result = repository.GetAll().ToArray();

            gridProduct.DataSource = result;
            gridProduct.DataBind();

            var tbl2 = repo.Get(id);

            foreach (GridViewRow row in gridProduct.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
                if (tbl2 != null)
                {
                    foreach (var t in tbl2)
                    {
                        if (t.ProductId == Convert.ToInt32(gridProduct.DataKeys[row.RowIndex].Value))
                        {
                            cb.Checked = true;
                        }
                    }
                }
            }
        }
        private void Load_Data_Grid()
        {
            ProductVendorLink repository = new ProductVendorLink();
            var result = repository.Get(id);

            if (result != null)
            {
                gridProduct.DataSource = result;
                gridProduct.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (vendorName.SelectedIndex == 0)
            {
                this.ShowErrorNotification("Please Select Proper Vendor");
            }

            else
            {
                ProductVendorLink           repository = new ProductVendorLink();
                tblProductVendorLink        tbl        = new tblProductVendorLink();
                List <tblProductVendorLink> list       = new List <tblProductVendorLink>();
                foreach (GridViewRow row in gridProduct.Rows)
                {
                    CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
                    if (cb.Checked)
                    {
                        list.Add(new tblProductVendorLink {
                            VendorId = Convert.ToInt32(vendorName.SelectedValue), ProductId = Convert.ToInt32(gridProduct.DataKeys[row.RowIndex].Value)
                        });
                        count++;
                    }
                }

                // method call to add those product with vendor link

                repository.Bulk_Add(list);
                this.ShowSuccessfulNotification("Product linked to Vendor");

                if (count == 0)
                {
                    this.ShowErrorNotification("Please Select any Product");
                }
            }
        }