private void ProcessForm(int supplierid, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    PatternSupplierBO objPatternSupplier = new PatternSupplierBO(this.ObjContext);
                    if (supplierid > 0)
                    {
                        objPatternSupplier.ID = supplierid;
                        objPatternSupplier.GetObject();
                        objPatternSupplier.Name            = this.txtSupplierName.Text;
                        objPatternSupplier.Country         = int.Parse(this.ddlCountry.SelectedValue);
                        objPatternSupplier.Address1        = this.txtAddress1.Text;
                        objPatternSupplier.Address2        = this.txtAddress2.Text;
                        objPatternSupplier.City            = this.txtCity.Text;
                        objPatternSupplier.State           = this.txtState.Text;
                        objPatternSupplier.Postcode        = this.txtPostcode.Text;
                        objPatternSupplier.EmailAddress    = this.txtPostcode.Text;
                        objPatternSupplier.TelephoneNumber = this.txtEmailAddress.Text;
                        objPatternSupplier.Creator         = LoggedUser.ID;
                        objPatternSupplier.CreatedDate     = DateTime.Now;
                        objPatternSupplier.Modifier        = LoggedUser.ID;
                        objPatternSupplier.ModifiedDate    = DateTime.Now;


                        if (isDelete)
                        {
                            objPatternSupplier.Delete();
                        }
                    }
                    else
                    {
                        objPatternSupplier.Name            = this.txtSupplierName.Text;
                        objPatternSupplier.Country         = int.Parse(this.ddlCountry.SelectedValue);
                        objPatternSupplier.Address1        = this.txtAddress1.Text;
                        objPatternSupplier.Address2        = this.txtAddress2.Text;
                        objPatternSupplier.City            = this.txtCity.Text;
                        objPatternSupplier.State           = this.txtState.Text;
                        objPatternSupplier.Postcode        = this.txtPostcode.Text;
                        objPatternSupplier.EmailAddress    = this.txtPostcode.Text;
                        objPatternSupplier.TelephoneNumber = this.txtEmailAddress.Text;
                        objPatternSupplier.Creator         = LoggedUser.ID;
                        objPatternSupplier.CreatedDate     = DateTime.Now;
                        objPatternSupplier.Modifier        = LoggedUser.ID;
                        objPatternSupplier.ModifiedDate    = DateTime.Now;
                        objPatternSupplier.Add();
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while inserting or updating or deleting Suppliers in ViewSuppliers.aspx page", ex);
            }
        }
        private void PopulateDataGrid()
        {
            {
                // Hide Controls
                this.dvEmptyContent.Visible   = false;
                this.dvDataContent.Visible    = false;
                this.dvNoSearchResult.Visible = false;

                // Search text
                string searchText = this.txtSearch.Text.ToLower().Trim();

                // Populate Items
                PatternSupplierBO objPatternSupplier = new PatternSupplierBO();

                List <PatternSupplierBO> lstPatternSuplliers = new List <PatternSupplierBO>();
                if ((searchText != string.Empty) && (searchText != "search"))
                {
                    lstPatternSuplliers = (from o in objPatternSupplier.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList()
                                           where o.Name.ToLower().Contains(searchText) // ||
                                                                                       // o.Country.ToLower().Contains(searchText)
                                           select o).ToList();
                }
                else
                {
                    lstPatternSuplliers = objPatternSupplier.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList();
                }

                if (lstPatternSuplliers.Count > 0)
                {
                    this.RadGridSuppliers.AllowPaging = (lstPatternSuplliers.Count > this.RadGridSuppliers.PageSize);
                    this.RadGridSuppliers.DataSource  = lstPatternSuplliers;
                    this.RadGridSuppliers.DataBind();
                    Session["PatternSupplier"] = lstPatternSuplliers;

                    this.dvDataContent.Visible = true;
                }
                else if ((searchText != string.Empty && searchText != "search"))
                {
                    this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                    this.dvDataContent.Visible    = true;
                    this.dvNoSearchResult.Visible = true;
                }
                else
                {
                    this.dvEmptyContent.Visible = true;
                    this.btnAddSupplier.Visible = false;
                }

                this.RadGridSuppliers.Visible = (lstPatternSuplliers.Count > 0);
            }
        }
        protected void RadGridSuppliers_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is PatternSupplierBO)
                {
                    PatternSupplierBO objSupplier = (PatternSupplierBO)item.DataItem;

                    Literal litCountry = (Literal)item.FindControl("litCountry");
                    litCountry.Text = objSupplier.objCountry.ShortName.ToString();

                    HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                    linkEdit.Attributes.Add("qid", objSupplier.ID.ToString());
                    linkEdit.Attributes.Add("cty", objSupplier.Country.ToString());

                    HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete");
                    linkDelete.Attributes.Add("qid", objSupplier.ID.ToString());
                    linkDelete.Attributes.Add("cty", objSupplier.Country.ToString());
                    linkDelete.Visible = (objSupplier.PatternsWhereThisIsPatternSupplier.Count > 0) ? false : true;
                }
            }
        }