Exemple #1
0
        protected void FillGridMain()
        {
            TTSHWCFServiceClient cl = new TTSHWCFServiceClient();

            try
            {
                List <Grant_Details> lstgrantDetail = new List <Grant_Details>();
                lstgrantDetail          = cl.FillGrantDetailGrid().ToList();
                RptGrantGrid.DataSource = lstgrantDetail;
                RptGrantGrid.DataBind();
            }
            catch (Exception ex)
            {
                this.MsgBox(ex.Message.ToString().Replace("'", " "));
            }
        }
Exemple #2
0
        void SearchBox_ButtonSearchClick(object sender, EventArgs e)
        {
            SearchBox.SearchInputValue = ((TextBox)(SearchBox.FindControl("txtSearch"))).Text;
            TTSHWCFServiceClient client = new TTSHWCFServiceClient();

            if (string.IsNullOrEmpty(SearchBox.ErrorString))
            {
                Search[] lst = SearchBox.SearchOutput;

                try
                {
                    client.Open();
                    string UserID = Convert.ToString(Session["UserID"]).ToUpper();
                    Project_DataOwner[] oDOList    = client.GetProjectsByDO("Grant", UserID);
                    DataOwner_Entity[]  oDataOwner = client.GetAllDataOwner("TAdmin");

                    var AdminArray = (from s in oDataOwner
                                      select s.GUID).ToList();

                    bool IsAdmin = AdminArray.Contains(UserID);


                    List <Search> oNewGrid   = new List <Search>();
                    List <Search> oOldSearch = new List <Search>();

                    if (IsAdmin == false)
                    {
                        if (lst != null && lst.Count() > 0 && oDOList != null && oDOList.Count() > 0)
                        {
                            oOldSearch = lst.ToList();
                            oNewGrid   = oOldSearch.Where(z => z.iRecordExists == 0).Where(z => oDOList.Any(x => x.s_DisplayProject_ID == z.s_Display_Project_ID)).ToList();
                            //oNewGrid.ForEach(i => i.Status = "New");
                            oOldSearch.RemoveAll(z => z.iRecordExists == 0);
                            oOldSearch.AddRange(oNewGrid);

                            foreach (var element in oOldSearch)
                            {
                                if (element.iRecordExists == 0)
                                {
                                    element.Status = "New";
                                }
                                else
                                {
                                    bool flag = false;
                                    foreach (var item in oDOList)
                                    {
                                        if (item.s_DisplayProject_ID == element.s_Display_Project_ID)
                                        {
                                            flag = true;
                                            break;
                                        }
                                        else
                                        {
                                            flag = false;
                                        }
                                    }
                                    if (flag == true)
                                    {
                                        element.Status = "Edit";
                                    }
                                    else
                                    {
                                        element.Status = "View";
                                    }
                                }
                            }

                            oOldSearch = oOldSearch.OrderByDescending(z => z.i_ID).ToList();

                            RptGrantGrid.DataSource = oOldSearch; /*use the object according to your need*/
                            RptGrantGrid.DataBind();
                        }
                        else
                        {
                            foreach (var element in lst)
                            {
                                if (element.iRecordExists == 0)
                                {
                                    element.Status = "New";
                                }
                                else
                                {
                                    bool flag = false;
                                    foreach (var item in oDOList)
                                    {
                                        if (item.s_DisplayProject_ID == element.s_Display_Project_ID)
                                        {
                                            flag = true;
                                            break;
                                        }
                                        else
                                        {
                                            flag = false;
                                        }
                                    }
                                    if (flag == true)
                                    {
                                        element.Status = "Edit";
                                    }
                                    else
                                    {
                                        element.Status = "View";
                                    }
                                }
                            }

                            RptGrantGrid.DataSource = lst; /*use the object according to your need*/
                            RptGrantGrid.DataBind();
                        }
                    }
                    else
                    {
                        oOldSearch = lst.ToList();
                        oNewGrid   = oOldSearch.Where(z => z.iRecordExists == 0).ToList();
                        oOldSearch.RemoveAll(z => z.iRecordExists == 0);
                        oOldSearch.AddRange(oNewGrid);

                        foreach (var element in oOldSearch)
                        {
                            if (element.iRecordExists == 0)
                            {
                                element.Status = "New";
                            }
                            else
                            {
                                element.Status = "Edit";
                            }
                        }
                        oOldSearch = oOldSearch.OrderByDescending(z => z.i_Project_ID).ToList();

                        RptGrantGrid.DataSource = oOldSearch; /*use the object according to your need*/
                        RptGrantGrid.DataBind();
                    }
                }
                catch (Exception ex)
                {
                }
                client.Close();
            }
            else
            {
                RptGrantGrid.DataSource = null;
                RptGrantGrid.DataBind();
            }
        }