Exemple #1
0
        protected void CreateSaveButtonClick(object sender, EventArgs e)
        {
            var userIdtmp = Session["UserID"];

            if (userIdtmp == null)
            {
                Response.Redirect("~/CuratorMainPage.aspx");
            }
            int userId = (int)userIdtmp;

            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            zCompetitionsTable     newCompetition      = new zCompetitionsTable();

            newCompetition.Name = NameTextBox.Text;

            newCompetition.Budjet              = Convert.ToDouble(BudjetTextBox.Text);
            newCompetition.FK_Curator          = userId;
            newCompetition.StartDate           = Calendar1.SelectedDate;
            newCompetition.EndDate             = Calendar2.SelectedDate;
            newCompetition.Active              = true;
            newCompetition.OpenForApplications = false;
            competitionDataBase.zCompetitionsTable.InsertOnSubmit(newCompetition);
            competitionDataBase.SubmitChanges();
            foreach (ListItem current in CheckBoxList1.Items)
            {
                zActionsCompetitionsMappingTable actionlink = new zActionsCompetitionsMappingTable();
                actionlink.FK_Competiton = newCompetition.ID;
                actionlink.FK_ActionPR   = Convert.ToInt32(current.Value);
                actionlink.Active        = current.Selected;
                competitionDataBase.zActionsCompetitionsMappingTable.InsertOnSubmit(actionlink);
                competitionDataBase.SubmitChanges();
            }
            Session["CompetitionID"] = newCompetition.ID;
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Готово!');", true);
        }
Exemple #2
0
        protected void StartStopButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase       = new CompetitionDataContext();
                zCompetitionsTable     competitionToChangeStatus = (from a in competitionDataBase.zCompetitionsTable
                                                                    where a.ID == iD
                                                                    select a).FirstOrDefault();
                if (competitionToChangeStatus != null)
                {
                    if (competitionToChangeStatus.OpenForApplications == null)
                    {
                        competitionToChangeStatus.OpenForApplications = true;
                    }
                    else
                    {
                        competitionToChangeStatus.OpenForApplications = !competitionToChangeStatus.OpenForApplications;
                    }
                    competitionDataBase.SubmitChanges();
                }
                else
                {
                    //error
                }
            }
            Response.Redirect("ChooseCompetition.aspx");
        }
Exemple #3
0
        private int GetDaysBeforeCompetitionEnd(int competitionId)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            DateTime           today = DateTime.Today;
            zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                     where a.ID == competitionId &&
                                                     a.Active == true
                                                     select a).FirstOrDefault();

            if (currentCompetition == null)
            {
                return(-1);
            }
            if (currentCompetition.EndDate == null)
            {
                return(-1);
            }
            DateTime competitionEndTime = Convert.ToDateTime(currentCompetition.EndDate);

            if (today > competitionEndTime)
            {
                return(-1);
            }

            double days = (competitionEndTime - today).TotalDays;

            if (days > 0)
            {
                return(Convert.ToInt32(days));
            }
            return(-1);
        }
Exemple #4
0
 protected void GetTamplateWithNoMarkButton(object sender, EventArgs e)
 {
     Button button = (Button)sender;
     {
         int iD = Convert.ToInt32(button.CommandArgument);
         CompetitionDataContext competitionDataBase = new CompetitionDataContext();
         zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                       where a.ID == iD
                                                       select a).FirstOrDefault();
         if (currentCompetition != null)
         {
             if (currentCompetition.TemplateDocWithoutMarksName != null)
             {
                 if (currentCompetition.TemplateDocWithoutMarksName.Any())
                 {
                     string templatesWithNoMark = Server.MapPath("~/documents/templatesWithNoMark") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocWithoutMarksName;
                     HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                     HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + currentCompetition.TemplateDocWithoutMarksName);
                     HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(templatesWithNoMark));
                     HttpContext.Current.Response.End();
                     Response.End();
                 }
             }
         }
     }
 }
Exemple #5
0
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var sessionParam = Session["CompetitionID"];

            if (sessionParam == null)
            {
                //error
                Response.Redirect("ChooseCompetition.aspx");
            }
            int iD = (int)sessionParam;

            if (iD > 0)
            {
                zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                         where a.Active == true &&
                                                         a.ID == iD
                                                         select a).FirstOrDefault();
                if (currentCompetition == null)
                {
                    //error
                    Response.Redirect("ChooseCompetition.aspx");
                }
                String path = Server.MapPath("~/documents/templatesWithNoMark") + "\\\\" + currentCompetition.ID.ToString() + "\\\\" + currentCompetition.TemplateDocWithoutMarksName;
                HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + currentCompetition.TemplateDocWithoutMarksName);
                HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(path));
                HttpContext.Current.Response.End();
                Response.End();
            }
        }
Exemple #6
0
        protected bool competitionIsClosed(zApplicationTable currentApplication)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                          where a.ID == currentApplication.FK_CompetitionTable
                                                          select a).FirstOrDefault();

            return(!currentCompetition.OpenForApplications);
        }
        protected void SaveButtonClick(object sender, EventArgs e)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var sessionParam = Session["CompetitionID"];
            var userId       = Session["UserID"];

            if (sessionParam != null && userId != null)
            {
                int iD   = (int)sessionParam;
                int user = (int)userId;
                if (iD > 0)
                {
                    zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                             where a.Active == true && a.ID == iD
                                                             select a).FirstOrDefault();
                    if (currentCompetition != null)
                    {
                        foreach (ListItem current in CheckBoxList1.Items)
                        {
                            zActionsCompetitionsMappingTable action = (from a in competitionDataBase.zActionsCompetitionsMappingTable
                                                                       where a.FK_Competiton == iD &&
                                                                       a.FK_ActionPR == Convert.ToInt32(current.Value)
                                                                       select a).FirstOrDefault();
                            if (action != null)
                            {
                                if (current.Selected == true)
                                {
                                    action.Active = true;
                                    competitionDataBase.SubmitChanges();
                                }
                            }
                            else
                            {
                                action               = new zActionsCompetitionsMappingTable();
                                action.Active        = current.Selected;
                                action.FK_Competiton = iD;
                                action.FK_ActionPR   = Convert.ToInt32(current.Value);
                                competitionDataBase.zActionsCompetitionsMappingTable.InsertOnSubmit(action);
                                competitionDataBase.SubmitChanges();
                            }
                        }

                        currentCompetition.Name       = NameTextBox.Text;
                        currentCompetition.Budjet     = Convert.ToDouble(BudjetTextBox.Text);
                        currentCompetition.FK_Curator = user;
                        currentCompetition.StartDate  = Calendar1.SelectedDate;
                        currentCompetition.EndDate    = Calendar2.SelectedDate;
                        competitionDataBase.SubmitChanges();
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Готово!');", true);
                    }
                }
            }
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Ошибка!');", true);
        }
Exemple #8
0
        protected void GetDocButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                var userIdtmp = Session["UserID"];
                if (userIdtmp == null)
                {
                    Response.Redirect("~/Default.aspx");
                }
                int userId = (int)userIdtmp;
                var appid  = button.CommandArgument;
                int idapp  = Convert.ToInt32(appid);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                              join b in competitionDataBase.zApplicationTable
                                                              on a.ID equals b.FK_CompetitionTable
                                                              where b.ID == idapp
                                                              select a).FirstOrDefault();

                string dirPath          = Server.MapPath("~/documents/byApplication/" + idapp);
                string templateFilePath = Server.MapPath("~/documents/templates") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocName;
                string newFileName      = "Заявка " + currentCompetition.TemplateDocName + ".doc";
                newFileName = newFileName.Replace(":", "_");
                string        newFilePath   = dirPath + "\\" + newFileName;
                string        zipFile       = Server.MapPath("~/documents/generatedZipFiles/") + idapp + ".zip";
                string        extractPath   = Server.MapPath("~/documents/extract/");
                CreateXmlFile createXmlFile = new CreateXmlFile();
                string        asdadasdda    = System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip";
                createXmlFile.CreateDocument(templateFilePath, newFilePath, idapp, 0);

                if (File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip"))
                {
                    File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip");
                    ZipFile.CreateFromDirectory(dirPath, zipFile);
                    HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=file.zip");
                    HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(zipFile));
                    HttpContext.Current.Response.End();
                }
                else
                {
                    ZipFile.CreateFromDirectory(dirPath, zipFile);
                    HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=file.zip");
                    HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(zipFile));
                    HttpContext.Current.Response.End();
                }
                Response.End();
            }
        }
        protected void GetDocButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();

                zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTables
                                                         join b in competitionDataBase.zApplicationTable
                                                         on a.ID equals b.FK_CompetitionTable
                                                         where b.ID == iD
                                                         select a).FirstOrDefault();
                if (currentCompetition != null)
                {
                    var userIdtmp = Session["UserID"];
                    if (userIdtmp == null)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    int userId = (int)userIdtmp;

                    if (currentCompetition.TemplateDocName != null)
                    {
                        if (currentCompetition.TemplateDocName.Any())
                        {
                            string templateFilePath = Server.MapPath("~/documents/templates") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocName;
                            string newFileName      = DateTime.Now.ToString() + " " + currentCompetition.TemplateDocName;
                            newFileName = newFileName.Replace(":", "_");
                            string newFileDirectory = Server.MapPath("~/documents/generated") + "\\" + userId.ToString();
                            string newFilePath      = newFileDirectory + "\\" + newFileName;

                            Directory.CreateDirectory(newFileDirectory);
                            CreateDocument(templateFilePath, newFilePath, iD);

                            HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + currentCompetition.TemplateDocName);
                            HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(newFilePath));
                            HttpContext.Current.Response.End();
                            Response.End();
                        }
                    }
                }
            }
        }
Exemple #10
0
 protected void DeleteButtonClick(object sender, EventArgs e)
 {
     Button button = (Button)sender;
     {
         int iD = Convert.ToInt32(button.CommandArgument);
         CompetitionDataContext competitionDataBase = new CompetitionDataContext();
         zCompetitionsTable     competitionToDelete = (from a in competitionDataBase.zCompetitionsTable
                                                       where a.ID == iD
                                                       select a).FirstOrDefault();
         if (competitionToDelete != null)
         {
             competitionToDelete.Active = false;
             competitionDataBase.SubmitChanges();
         }
         else
         {
             //error
         }
     }
 }
Exemple #11
0
        protected void OpenButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                zCompetitionsTable     currentApplication  = (from a in competitionDataBase.zCompetitionsTable
                                                              where a.Active == true &&
                                                              a.ID == iD
                                                              select a).FirstOrDefault();
                if (currentApplication != null)
                {
                    currentApplication.Sended = true;
                    //currentApplication.SendedDataTime = DateTime.Now;
                    competitionDataBase.SubmitChanges();
                }
            }
            Response.Redirect("CuratorCompetition.aspx");
        }
Exemple #12
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Button send   = (Button)e.Row.FindControl("OpenButton");
            Button change = (Button)e.Row.FindControl("ChangeButton");

            if (send != null && change != null)
            {
                CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext();
                zCompetitionsTable     sended = (from a in CompetitionsDataBase.zCompetitionsTable
                                                 where a.Active == true &&
                                                 a.ID == Convert.ToInt32(send.CommandArgument)
                                                 select a).FirstOrDefault();
                if (sended.Sended == true)
                {
                    send.Enabled   = false;
                    change.Enabled = false;
                }
                else
                {
                    send.Enabled   = true;
                    change.Enabled = true;
                }
            }
        }
Exemple #13
0
        protected void CreateSaveButtonClick(object sender, EventArgs e)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var sessionParam = Session["CompetitionID"];

            if (sessionParam == null)
            {
                //error
                Response.Redirect("ChooseCompetition.aspx");
            }
            else
            {
                int iD = (int)sessionParam;
                if (iD > 0)
                {
                    if ((NameTextBox.Text.Length > 0) && (DescriptionTextBox.Text.Length > 0))
                    {
                        zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                                 where a.Active == true &&
                                                                 a.ID == iD
                                                                 select a).FirstOrDefault();
                        if (currentCompetition == null)
                        {
                            //error
                            Response.Redirect("ChooseCompetition.aspx");
                        }
                        else
                        {
                            currentCompetition.Name   = NameTextBox.Text;
                            currentCompetition.Number = DescriptionTextBox.Text;
                            currentCompetition.Budjet = Convert.ToDouble(BudjetTextBox.Text);
                            //  currentCompetition.FK_Curator = Convert.ToInt32(DropDownList1.SelectedIndex);
                            currentCompetition.StartDate = Calendar1.SelectedDate;
                            currentCompetition.EndDate   = Calendar2.SelectedDate;
                            if (FileUpload1.HasFile)
                            {
                                try
                                {
                                    String path = Server.MapPath("~/documents/templates");
                                    Directory.CreateDirectory(path + "\\\\" + currentCompetition.ID.ToString());
                                    FileUpload1.PostedFile.SaveAs(path + "\\\\" + currentCompetition.ID.ToString() + "\\\\" + FileUpload1.FileName);
                                    currentCompetition.TemplateDocName = FileUpload1.FileName;
                                    // FileStatusLabel.Text = "Файл загружен!";
                                }
                                catch (Exception ex)
                                {
                                    //  FileStatusLabel.Text = "Не удалось загрузить файл.";
                                }
                            }
                            if (FileUpload2.HasFile)
                            {
                                try
                                {
                                    String path = Server.MapPath("~/documents/templatesWithNoMark");
                                    Directory.CreateDirectory(path + "\\\\" + currentCompetition.ID.ToString());
                                    FileUpload2.PostedFile.SaveAs(path + "\\\\" + currentCompetition.ID.ToString() + "\\\\" + FileUpload2.FileName);
                                    currentCompetition.TemplateDocWithoutMarksName = FileUpload2.FileName;
                                    // FileStatusLabel.Text = "Файл загружен!";
                                }
                                catch (Exception ex)
                                {
                                    //  FileStatusLabel.Text = "Не удалось загрузить файл.";
                                }
                            }
                            competitionDataBase.SubmitChanges();
                        }
                    }
                }
                else
                {
                    if ((NameTextBox.Text.Length > 0) && (DescriptionTextBox.Text.Length > 0))
                    {
                        zCompetitionsTable newCompetition = new zCompetitionsTable();
                        newCompetition.Name   = NameTextBox.Text;
                        newCompetition.Number = DescriptionTextBox.Text;
                        newCompetition.Budjet = Convert.ToDouble(BudjetTextBox.Text);
                        // newCompetition.FK_Curator = Convert.ToInt32(DropDownList1.SelectedIndex);
                        newCompetition.StartDate           = Calendar1.SelectedDate;
                        newCompetition.EndDate             = Calendar2.SelectedDate;
                        newCompetition.Active              = true;
                        newCompetition.OpenForApplications = false;
                        competitionDataBase.zCompetitionsTable.InsertOnSubmit(newCompetition);
                        competitionDataBase.SubmitChanges();
                        if (FileUpload1.HasFile)
                        {
                            try
                            {
                                String path = Server.MapPath("~/documents/templates");
                                Directory.CreateDirectory(path + "\\\\" + newCompetition.ID.ToString());
                                FileUpload1.PostedFile.SaveAs(path + "\\\\" + newCompetition.ID.ToString() + "\\\\" + FileUpload1.FileName);
                                newCompetition.TemplateDocName = FileUpload1.FileName;
                                // FileStatusLabel.Text = "Файл загружен!";
                            }
                            catch (Exception ex)
                            {
                                //  FileStatusLabel.Text = "Не удалось загрузить файл.";
                            }
                        }
                        if (FileUpload2.HasFile)
                        {
                            try
                            {
                                String path = Server.MapPath("~/documents/templatesWithNoMark");
                                Directory.CreateDirectory(path + "\\\\" + newCompetition.ID.ToString());
                                FileUpload2.PostedFile.SaveAs(path + "\\\\" + newCompetition.ID.ToString() + "\\\\" + FileUpload2.FileName);
                                newCompetition.TemplateDocWithoutMarksName = FileUpload2.FileName;
                                // FileStatusLabel.Text = "Файл загружен!";
                            }
                            catch (Exception ex)
                            {
                                //  FileStatusLabel.Text = "Не удалось загрузить файл.";
                            }
                        }
                        competitionDataBase.SubmitChanges();
                    }
                }
            }
            Response.Redirect("ChooseCompetition.aspx");
        }
Exemple #14
0
        protected void GetDocButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();

                zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                         join b in competitionDataBase.zApplicationTable
                                                         on a.ID equals b.FK_CompetitionTable
                                                         where b.ID == iD
                                                         select a).FirstOrDefault();
                if (currentCompetition != null)
                {
                    var userIdtmp = Session["UserID"];
                    if (userIdtmp == null)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    int userId = (int)userIdtmp;

                    if (currentCompetition.TemplateDocName != null)
                    {
                        if (currentCompetition.TemplateDocName.Any())
                        {
                            string templateFilePath = Server.MapPath("~/documents/templates") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocName;
                            string newFileName      = "Заявка пользователя на конкурс " + currentCompetition.TemplateDocName;
                            newFileName = newFileName.Replace(":", "_");
                            string newFileDirectory = Server.MapPath("~/documents/generated") + "\\" + iD.ToString();
                            string newFilePath      = newFileDirectory + "\\" + newFileName;


                            Directory.CreateDirectory(newFileDirectory);
                            CreateXmlFile createXmlFile = new CreateXmlFile();
                            int           docType       = 0;

                            try
                            {
                                RadioButtonList newRadioButtonList =
                                    button.Parent.FindControl("RadioButtonList1") as RadioButtonList;
                                docType = Convert.ToInt32(newRadioButtonList.SelectedValue);
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                            createXmlFile.CreateDocument(templateFilePath, newFilePath, iD, docType);
                            string convertedFilePath = createXmlFile.ConvertedFilePath;



                            HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=document." + createXmlFile.ConvertedFileExtension);
                            HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(convertedFilePath));
                            HttpContext.Current.Response.End();
                            Response.End();

                            /*  System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                             * response.ClearContent();
                             * response.Clear();
                             * response.ContentType = "text/plain";
                             * response.AddHeader("Content-Disposition", "attachment; filename=document." + createXmlFile.ConvertedFileExtension);
                             * response.TransmitFile(convertedFilePath);
                             * response.Flush();
                             * response.Clear();
                             * response.Redirect("~/User/UserMainPage.aspx");
                             * response.End();
                             *
                             */
                            /*
                             * Response.WriteFile(convertedFilePath);
                             * Response.Redirect("~/User/UserMainPage.aspx");*/
                        }
                    }
                }
            }
            //Response.Redirect("UserMainPage.aspx");
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CompetitionDataContext curator = new CompetitionDataContext();

                /* List<UsersTable> curators = (from a in curator.UsersTable
                 *                      where a.AccessLevel == 15 && a.Active == true
                 *                      select a).ToList();
                 *
                 * ListItem tmpItem2 = new ListItem();
                 * tmpItem2.Text = "Выберите куратора";
                 * tmpItem2.Value = "0";
                 * DropDownList1.Items.Add(tmpItem2);
                 *
                 * foreach (UsersTable current in curators)
                 * {
                 *   ListItem tmpItem = new ListItem();
                 *   tmpItem.Text = current.Email;
                 *   tmpItem.Value = current.ID.ToString();
                 *   DropDownList1.Items.Add(tmpItem);
                 * }
                 */
                var sessionParam = Session["CompetitionID"];
                if (sessionParam == null)
                {
                    //error
                    Response.Redirect("ChooseCompetition.aspx");
                }
                else
                {
                    int iD = (int)sessionParam;
                    if (iD > 0)
                    {
                        CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                        zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                                      where a.Active == true &&
                                                                      a.ID == iD
                                                                      select a).FirstOrDefault();
                        if (currentCompetition == null)
                        {
                            //error
                            Response.Redirect("ChooseCompetition.aspx");
                        }
                        else
                        {
                            NameTextBox.Text        = currentCompetition.Name;
                            DescriptionTextBox.Text = currentCompetition.Number;
                            BudjetTextBox.Text      = currentCompetition.Budjet.ToString();
                            //DropDownList1.SelectedIndex = Convert.ToInt32(currentCompetition.FK_Curator);
                            Calendar1.SelectedDate = Convert.ToDateTime(currentCompetition.StartDate);
                            Calendar2.SelectedDate = Convert.ToDateTime(currentCompetition.EndDate);
                            if (currentCompetition.TemplateDocName != null)
                            {
                                if (currentCompetition.TemplateDocName.Any())
                                {
                                    LinkButton1.Text = currentCompetition.TemplateDocName;
                                }
                                else
                                {
                                    LinkButton1.Visible = false;
                                    LinkButton1.Enabled = false;
                                }
                            }
                            else
                            {
                                LinkButton1.Visible = false;
                                LinkButton1.Enabled = false;
                            }

                            if (currentCompetition.TemplateDocWithoutMarksName != null)
                            {
                                if (currentCompetition.TemplateDocWithoutMarksName.Any())
                                {
                                    LinkButton2.Text = currentCompetition.TemplateDocWithoutMarksName;
                                }
                                else
                                {
                                    LinkButton2.Visible = false;
                                    LinkButton2.Enabled = false;
                                }
                            }
                            else
                            {
                                LinkButton2.Visible = false;
                                LinkButton2.Enabled = false;
                            }
                        }
                    }
                }
            }
        }
        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();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)

            {
                CompetitionDataContext    curator = new CompetitionDataContext();
                List <zTaskPRManualTable> comp    = (from a in curator.zTaskPRManualTable where a.Active == true select a).ToList();
                foreach (zTaskPRManualTable n in comp)
                {
                    ListItem TmpItem = new ListItem();
                    TmpItem.Text  = n.TaskPR;
                    TmpItem.Value = n.ID.ToString();
                    CheckBoxList1.Items.Add(TmpItem);
                }


                var sessionParam = Session["CompetitionID"];
                if (sessionParam != null)
                {
                    int iD = (int)sessionParam;
                    if (iD > 0)
                    {
                        CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                        zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                                      where a.Active == true && a.ID == iD
                                                                      select a).FirstOrDefault();
                        if (currentCompetition == null)
                        {
                            Response.Redirect("CuratorCompetition.aspx");
                        }
                        else
                        {
                            NameTextBox.Text   = currentCompetition.Name;
                            BudjetTextBox.Text = currentCompetition.Budjet.ToString();
                            foreach (ListItem current in CheckBoxList1.Items)
                            {
                                zActionsCompetitionsMappingTable action = (from a in competitionDataBase.zActionsCompetitionsMappingTable
                                                                           where a.Active == true && a.FK_Competiton == iD &&
                                                                           a.FK_ActionPR == Convert.ToInt32(current.Value)
                                                                           select a).Distinct().FirstOrDefault();
                                if (action != null)
                                {
                                    if (action.FK_ActionPR == Convert.ToInt32(current.Value))
                                    {
                                        current.Selected = true;
                                    }
                                }
                                else
                                {
                                }
                            }
                            Calendar1.SelectedDate = Convert.ToDateTime(currentCompetition.StartDate);
                            Calendar2.SelectedDate = Convert.ToDateTime(currentCompetition.EndDate);
                        }
                    }
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Ошибка!');", true);
                }
            }
        }