Exemplo n.º 1
0
        private void ProductgridBind()
        {
            ppMsg = new PopupMessage();
            try
            {
                int rowNo = 1;
                dgProductMaster.AutoGenerateColumns = false;
                _entities = new TSEntities();

                List <ProductMasterVM> modelList = new List <ProductMasterVM>();

                var data = _entities.tbl_ProductMaster.OrderBy(x => x.p_Name);

                foreach (var item in data)
                {
                    ProductMasterVM model = new ProductMasterVM();
                    model.rowNo  = rowNo;
                    model.id     = item.id;
                    model.p_Name = item.p_Name;
                    model.rate   = item.rate + " /-";

                    modelList.Add(model);

                    rowNo++;
                }
                dgProductMaster.DataSource = modelList;

                lblTotalRows.Text = modelList.Count.ToString() + " Rows";
            }
            catch (Exception x)
            {
                ppMsg.infoMessage("Something went wrong. Contact your system administrator!");
            }
        }
Exemplo n.º 2
0
        private void txtpName_KeyPress(object sender, KeyPressEventArgs e)
        {
            ppMsg = new PopupMessage();
            try
            {
                int rowNo = 1;

                dgProductMaster.AutoGenerateColumns = false;
                _entities = new TSEntities();

                List <ProductMasterVM> productMasterListVM = new List <ProductMasterVM>();

                List <tbl_ProductMaster> data;

                if (txtpName.Text == "")
                {
                    data = _entities.tbl_ProductMaster.ToList();
                }
                else
                {
                    data = _entities.tbl_ProductMaster.Where(x => x.p_Name.Contains(txtpName.Text.Trim().ToString())).ToList();
                }

                foreach (var item in data)
                {
                    ProductMasterVM list = new ProductMasterVM();
                    list.rowNo  = rowNo;
                    list.id     = item.id;
                    list.p_Name = item.p_Name;

                    list.rate = item.rate.ToString() + " /-";

                    productMasterListVM.Add(list);
                    rowNo++;
                }

                dgProductMaster.DataSource = productMasterListVM;

                lblTotalRows.Text = productMasterListVM.Count.ToString() + " Rows";
            }
            catch (Exception x)
            {
                ppMsg.infoMessage("Something went wrong. Contact your system administrator!");
            }
        }