protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var currentUserId = User.Identity.GetUserId();
                var currentUser   = context.Users.FirstOrDefault(x => x.Id == currentUserId);

                var gridData = context.Documents
                               .Where(x => x.SavedBy == currentUser.Name)
                               .Where(x => x.RequestStatusId == requested)
                               .Include(x => x.DocType)
                               .Include(x => x.RequestStatus)
                               .Select(x => new OperatorDocsVM()
                {
                    Id      = x.Id,
                    Name    = x.Name,
                    Type    = x.DocType.Name,
                    IssueBy = x.IssuedBy.Name,
                    Status  = x.RequestStatus.Name
                })
                               .ToList();
                DocumentsGV.DataSource = gridData;
                DocumentsGV.DataBind();
            }
        }
        private void PopulateGV()
        {
            var currentUserId = User.Identity.GetUserId();

            var gridData = context.Documents
                           .Where(x => x.IssuedBy.Id == currentUserId)
                           .Include(x => x.DocType)
                           .Include(x => x.RequestStatus)
                           .Select(x => new CustomerDocsVM()
            {
                Id          = x.Id,
                Name        = x.Name,
                IssueTo     = x.IssuedTo,
                DateNTime   = x.Date,
                Type        = x.DocType.Name,
                Description = x.Description,
                Status      = x.RequestStatus.Name
            })
                           .ToList();

            DocumentsGV.DataSource = gridData;
            DocumentsGV.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var sessionParam1 = Session["ApplicationID"];

                if ((sessionParam1 == null))
                {
                    Response.Redirect("ChooseApplication.aspx");
                }

                int applicationId = Convert.ToInt32(sessionParam1);

                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                zApplicationTable      currentApplication  = (from a in competitionDataBase.zApplicationTable
                                                              where a.ID == applicationId
                                                              select a).FirstOrDefault();
                zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                         where a.ID == currentApplication.FK_CompetitionTable
                                                         select a).FirstOrDefault();

                CompetitionCountDown competitionCountDown = new CompetitionCountDown();
                CountDownLabel.Text =
                    competitionCountDown.GetDaysBeforeCompetitionEndMessage(currentCompetition.ID);

                Label1.Text = currentApplication.Name;
                Label2.Text = currentCompetition.Name;

                if (currentApplication.StartProjectDate != null)
                {
                    DateTime dateTime = (DateTime)currentApplication.StartProjectDate;
                    string   tmpStr   = dateTime.ToString().Split(' ')[0];
                    string[] tmpArray = tmpStr.Split('.');
                    string   tmp2     = tmpArray[2] + "-" + tmpArray[1] + "-" + tmpArray[0];
                    startdata.Value = tmp2;
                }
                if (currentApplication.EndProjectDate != null)
                {
                    DateTime dateTime = (DateTime)currentApplication.EndProjectDate;
                    string   tmpStr   = dateTime.ToString().Split(' ')[0];
                    string[] tmpArray = tmpStr.Split('.');
                    string   tmp2     = tmpArray[2] + "-" + tmpArray[1] + "-" + tmpArray[0];
                    enddata.Value = tmp2;
                }
                DataTable dataTable = new DataTable();
                dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
                dataTable.Columns.Add(new DataColumn("Name", typeof(string)));
                dataTable.Columns.Add(new DataColumn("CreateDate", typeof(string)));

                List <zDocumentsTable> documentsList = (from a in competitionDataBase.zDocumentsTable
                                                        where a.FK_ApplicationTable == applicationId &&
                                                        a.Active == true
                                                        select a).ToList();

                foreach (zDocumentsTable currentDocument in documentsList)
                {
                    DataRow dataRow = dataTable.NewRow();
                    dataRow["ID"]   = currentDocument.ID;
                    dataRow["Name"] = currentDocument.Name;
                    if (currentDocument.Name == null)
                    {
                        dataRow["Name"] = "ссылка";
                        if (currentDocument.LinkOut != null)
                        {
                            string linkOutString = currentDocument.LinkOut;
                            if (linkOutString.Length > 100)
                            {
                                linkOutString   = linkOutString.Remove(100) + "...";
                                dataRow["Name"] = linkOutString;
                            }
                            else
                            {
                                dataRow["Name"] = currentDocument.LinkOut;
                            }
                        }
                    }
                    dataRow["CreateDate"] = currentDocument.AddDateTime.ToString().Split(' ')[0];
                    dataTable.Rows.Add(dataRow);
                }

                DocumentsGV.DataSource = dataTable;
                DocumentsGV.DataBind();


                List <zBlockTable> currentBlock = (from a in competitionDataBase.zBlockTable
                                                   where a.Active == true
                                                   select a).ToList();

                DataTable dataTable2 = new DataTable();
                dataTable2.Columns.Add(new DataColumn("ID", typeof(string)));
                dataTable2.Columns.Add(new DataColumn("BlockName", typeof(string)));
                dataTable2.Columns.Add(new DataColumn("Status", typeof(string)));
                dataTable2.Columns.Add(new DataColumn("EnableButton", typeof(bool)));
                Status status        = new Status();
                int    statusHistory = 2;
                foreach (zBlockTable current  in currentBlock)
                {
                    DataRow dataRow2 = dataTable2.NewRow();
                    dataRow2["ID"]        = current.ID;
                    dataRow2["BlockName"] = current.BlockName;
                    int blockStatus = status.GetStatusIdForBlockInApplication(current.ID, currentApplication.ID);
                    dataRow2["Status"]       = status.GetStatusNameByStatusId(blockStatus);
                    dataRow2["EnableButton"] = false;
                    if (status.IsDataReady(statusHistory))
                    {
                        dataRow2["EnableButton"] = true;
                    }
                    statusHistory = blockStatus;
                    dataTable2.Rows.Add(dataRow2);
                }

                BlockGV.DataSource = dataTable2;
                BlockGV.DataBind();

                List <zPartnersTable> partners = (from a in competitionDataBase.zPartnersTable
                                                  where a.Active == true
                                                  join b in competitionDataBase.zApplicationAndPartnersMappingTable
                                                  on a.ID equals b.FK_PartnersTable
                                                  where b.Active == true && b.FK_Application == applicationId
                                                  select a).ToList();
                DataTable dataTable3 = new DataTable();
                dataTable3.Columns.Add(new DataColumn("ID", typeof(string)));
                dataTable3.Columns.Add(new DataColumn("Surname", typeof(string)));
                dataTable3.Columns.Add(new DataColumn("Name", typeof(string)));
                dataTable3.Columns.Add(new DataColumn("Patronymic", typeof(string)));
                dataTable3.Columns.Add(new DataColumn("Role", typeof(bool)));
                foreach (zPartnersTable current in partners)
                {
                    DataRow dataRow3 = dataTable3.NewRow();
                    dataRow3["ID"]         = current.ID;
                    dataRow3["Surname"]    = current.Surname;
                    dataRow3["Name"]       = current.Name;
                    dataRow3["Patronymic"] = current.Patronymic;
                    dataRow3["Role"]       = false;
                    if (current.Role == null && current.Role == false)
                    {
                        dataRow3["Role"] = false;
                    }
                    if (current.Role == true)
                    {
                        dataRow3["Role"] = true;
                    }

                    dataTable3.Rows.Add(dataRow3);
                }
                PartnersGV.DataSource = dataTable3;
                PartnersGV.DataBind();
            }
        }