protected void DeleteExpertButtonClick(object sender, EventArgs e) { var sessionParam1 = Session["ApplicationID"]; ImageButton button = (ImageButton)sender; if (sessionParam1 == null && button != null) { //error Response.Redirect("~/Default.aspx"); } int applicationId = Convert.ToInt32(sessionParam1); int userId = Convert.ToInt32(button.CommandArgument); CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.Accept == false && a.ID == applicationId && a.Sended == true select a).FirstOrDefault(); if (currentApplication != null) { zExpertsAndApplicationMappingTable expertlink = (from a in competitionDataBase.zExpertsAndApplicationMappingTable where a.Active == true && a.FK_ApplicationsTable == applicationId && a.FK_UsersTable == userId select a).FirstOrDefault(); if (expertlink != null) { expertlink.Active = false; competitionDataBase.SubmitChanges(); } } Response.Redirect("ApplicationExpertsAndExpertsGroupEdit.aspx"); }
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 SendButtonClick(object sender, EventArgs e) { Button button = (Button)sender; { var userIdtmp = Session["UserID"]; if (userIdtmp == null) { Response.Redirect("~/Default.aspx"); } int userId = (int)userIdtmp; int iD = Convert.ToInt32(button.CommandArgument); CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.ID == iD select a).FirstOrDefault(); List <zApplicationTable> existApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.Sended == true && a.FK_UsersTable == userId select a).ToList(); if (currentApplication != null && existApplication.Count == 0) //Если других заявок нет то отправляем сразу { SendApplication(currentApplication.ID); } else if (currentApplication != null && existApplication.Count != 0) { bool canSendApplicationByDates = true; bool canSendApplicationByFkCompetition = true; foreach (zApplicationTable n in existApplication) { if (!DoesDateRangesCross(currentApplication.StartProjectDate, currentApplication.EndProjectDate, n.StartProjectDate, n.EndProjectDate)) { canSendApplicationByDates = false; } if (n.FK_CompetitionTable == currentApplication.FK_CompetitionTable) { canSendApplicationByFkCompetition = false; } } if (canSendApplicationByDates && canSendApplicationByFkCompetition) { SendApplication(currentApplication.ID); } else if (!canSendApplicationByFkCompetition) { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Вы уже подали заявку на данный конкурс!');", true); } else if (!canSendApplicationByDates) { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Даты реализации данного проекта пересекаются с датами отправленной Вами ранее заявки!');", true); } } } }
protected void AddExpertGroupClick(object sender, EventArgs e) { var sessionParam1 = Session["ApplicationID"]; ImageButton button = (ImageButton)sender; if (sessionParam1 == null && button != null) { //error Response.Redirect("~/Default.aspx"); } int applicationId = Convert.ToInt32(sessionParam1); int groupId = Convert.ToInt32(button.CommandArgument); CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.Accept == false && a.ID == applicationId && a.Sended == true select a).FirstOrDefault(); if (currentApplication != null) { List <zExpertAndExpertGroupMappingTable> currentgroup = (from a in competitionDataBase.zExpertAndExpertGroupMappingTable where a.Active == true && a.FK_ExpertGroupTable == groupId select a).ToList(); if (currentgroup != null) { foreach (var n in currentgroup) { zExpertsAndApplicationMappingTable expertlink = (from a in competitionDataBase.zExpertsAndApplicationMappingTable where a.FK_ApplicationsTable == applicationId && a.FK_UsersTable == n.FK_UsersTable select a).FirstOrDefault(); if (expertlink == null) { zExpertsAndApplicationMappingTable newexpertlink = new zExpertsAndApplicationMappingTable(); newexpertlink.Active = true; newexpertlink.FK_ApplicationsTable = currentApplication.ID; newexpertlink.FK_UsersTable = n.FK_UsersTable; competitionDataBase.zExpertsAndApplicationMappingTable.InsertOnSubmit(newexpertlink); competitionDataBase.SubmitChanges(); } else { if (expertlink.Active == false) { expertlink.Active = true; competitionDataBase.SubmitChanges(); } } } } } Response.Redirect("ApplicationExpertsAndExpertsGroupEdit.aspx"); }
protected void SendApplication(int applicationId) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.ID == applicationId select a).FirstOrDefault(); currentApplication.Sended = true; currentApplication.SendedDataTime = DateTime.Now; competitionDataBase.SubmitChanges(); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Заявка отправлена на рассмотрение!');", true); Response.Redirect("UserMainPage.aspx"); }
public string GetDaysBeforeCompetitionEndMessageByApplicationId(int applicationId) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplicationTable = (from a in competitionDataBase.zApplicationTable where a.ID == applicationId && a.Active == true select a).FirstOrDefault(); if (currentApplicationTable == null) { return(GetDaysBeforeCompetitionEndMessage(-1)); } if (currentApplicationTable.FK_CompetitionTable == null) { return(GetDaysBeforeCompetitionEndMessage(-1)); } return(GetDaysBeforeCompetitionEndMessage(Convert.ToInt32(currentApplicationTable.FK_CompetitionTable))); }
public bool IsCompetitionEndDateExpiredByApplication(int applicationId) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplicationTable = (from a in competitionDataBase.zApplicationTable where a.ID == applicationId && a.Active == true select a).FirstOrDefault(); if (currentApplicationTable == null) { return(IsCompetitionEndDateExpired(-1)); } if (currentApplicationTable.FK_CompetitionTable == null) { return(IsCompetitionEndDateExpired(-1)); } return(IsCompetitionEndDateExpired(Convert.ToInt32(currentApplicationTable.FK_CompetitionTable))); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var appIdTmp = Session["ApplicationID"]; if (appIdTmp == null) { Response.Redirect("Main.aspx"); } int applicationId = Convert.ToInt32(appIdTmp); CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext(); zApplicationTable name = (from a in CompetitionsDataBase.zApplicationTable where a.ID == applicationId select a).FirstOrDefault(); Label1.Text = "Заключения экспертов на заявку: " + name.Name; ExpertsPointGV.DataSource = GetFilledDataTable(GetExpertsInApplicationList(applicationId)); ExpertsPointGV.DataBind(); } }
protected void BackToUserButtonClick(object sender, EventArgs e) { Button button = (Button)sender; if (button != null) { int iD = Convert.ToInt32(button.CommandArgument); CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.ID == iD && a.Sended == true select a).FirstOrDefault(); if (currentApplication != null) { currentApplication.Sended = false; competitionDataBase.SubmitChanges(); } } Response.Redirect("ChooseApplication.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var sessionParam = Session["ApplicationID"]; var konkursid = Session["ID_Konkurs"]; int iD = 0; if (sessionParam != null) { iD = (int)sessionParam; } int idkon = 0; if (konkursid != null) { idkon = (int)konkursid; } CompetitionDataContext competitionDataBase = new CompetitionDataContext(); if (iD > 0) { zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.ID == iD && a.FK_CompetitionTable == idkon select a).FirstOrDefault(); if (currentApplication == null) { //error Response.Redirect("~/Default.aspx"); } else { ApplicationNameTextBox.Text = currentApplication.Name; string currenCompetitionName = (from a in competitionDataBase.zCompetitionsTable where a.ID == currentApplication.FK_CompetitionTable select a.Name).FirstOrDefault(); } } } }
protected void SaveDates() { 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(); if (currentApplication != null) { var start = Request["ctl00$MainContent$startdata"]; var end = Request["ctl00$MainContent$enddata"]; try { currentApplication.StartProjectDate = Convert.ToDateTime(start).Date; } catch { } try { currentApplication.EndProjectDate = Convert.ToDateTime(end).Date; } catch { } competitionDataBase.SubmitChanges(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var userIdtmp = Session["UserID"]; if (userIdtmp == null) { Response.Redirect("~/Default.aspx"); } int userId = (int)userIdtmp; CompetitionDataContext competitionDataBase = new CompetitionDataContext(); CompetitionCountDown competitionCountDown = new CompetitionCountDown(); Tab1.CssClass = "Clicked"; MainView.ActiveViewIndex = 0; #region competitions { DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("ID", typeof(string))); dataTable.Columns.Add(new DataColumn("Number", typeof(string))); dataTable.Columns.Add(new DataColumn("Name", typeof(string))); dataTable.Columns.Add(new DataColumn("Budjet", typeof(string))); dataTable.Columns.Add(new DataColumn("StartDate", typeof(string))); dataTable.Columns.Add(new DataColumn("EndDate", typeof(string))); List <zCompetitionsTable> competitionsList = (from a in competitionDataBase.zCompetitionsTable where a.Active == true && a.OpenForApplications == true select a).ToList(); foreach (zCompetitionsTable currentCompetition in competitionsList) { if (competitionCountDown.IsCompetitionEndDateExpired(currentCompetition.ID)) { continue; } DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentCompetition.ID; dataRow["Name"] = currentCompetition.Name; dataRow["Number"] = currentCompetition.Number; dataRow["Budjet"] = Convert.ToInt32(currentCompetition.Budjet); dataRow["StartDate"] = currentCompetition.StartDate.ToString().Split(' ')[0]; dataRow["EndDate"] = currentCompetition.EndDate.ToString().Split(' ')[0]; dataTable.Rows.Add(dataRow); } MainGV.DataSource = dataTable; MainGV.DataBind(); } #endregion /// в первую таблицу все те у которых конкурс еще открыт а заявка не отправлена /// во вторую все те у которых заявка отправлена /// в третью все те у которых закрыта заявка #region currentApplications { 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("CompetitionName", typeof(string))); dataTable.Columns.Add(new DataColumn("StatusLabelEnabled", typeof(bool))); dataTable.Columns.Add(new DataColumn("SendButtonEnabled", typeof(bool))); List <zApplicationTable> applicationList = (from a in competitionDataBase.zApplicationTable where a.FK_UsersTable == userId && a.Sended == false && a.Active == true join b in competitionDataBase.zCompetitionsTable on a.FK_CompetitionTable equals b.ID where b.Active == true && b.OpenForApplications == true select a).Distinct().ToList(); Status status = new Status(); foreach (zApplicationTable currentApplication in applicationList) { if (competitionCountDown.IsCompetitionEndDateExpiredByApplication(currentApplication.ID)) { continue; } DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentApplication.ID; dataRow["Name"] = currentApplication.Name; dataRow["CompetitionName"] = (from a in competitionDataBase.zCompetitionsTable where a.ID == (Convert.ToInt32(currentApplication.FK_CompetitionTable)) select a.Name).FirstOrDefault(); if (status.IsApplicationReadyToSend(currentApplication.ID)) { dataRow["StatusLabelEnabled"] = false; dataRow["SendButtonEnabled"] = true; } else { dataRow["StatusLabelEnabled"] = true; dataRow["SendButtonEnabled"] = false; } dataTable.Rows.Add(dataRow); } ApplicationGV.DataSource = dataTable; ApplicationGV.DataBind(); } #endregion #region applicationsArchive { 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("CompetitionName", typeof(string))); dataTable.Columns.Add(new DataColumn("SendedDate", typeof(string))); dataTable.Columns.Add(new DataColumn("Accept", typeof(string))); List <zApplicationTable> applicationList = (from a in competitionDataBase.zApplicationTable where a.FK_UsersTable == userId && a.Active == true && a.Sended == true join b in competitionDataBase.zCompetitionsTable on a.FK_CompetitionTable equals b.ID where b.Active == true select a).Distinct().ToList(); foreach (zApplicationTable currentApplication in applicationList) { DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentApplication.ID; dataRow["Name"] = currentApplication.Name; dataRow["CompetitionName"] = (from a in competitionDataBase.zCompetitionsTable where a.ID == (Convert.ToInt32(currentApplication.FK_CompetitionTable)) select a.Name).FirstOrDefault(); if (currentApplication.SendedDataTime == null) { dataRow["SendedDate"] = "Не отправлялось на рассмотрение"; } else { dataRow["SendedDate"] = currentApplication.SendedDataTime.ToString().Split(' ')[0]; } zApplicationTable accept = (from a in competitionDataBase.zApplicationTable where a.ID == (Convert.ToInt32(currentApplication.ID)) select a).FirstOrDefault(); if (accept.Accept == true) { dataRow["Accept"] = "Принята"; } else { dataRow["Accept"] = "На рассмотрении"; } dataTable.Rows.Add(dataRow); } ArchiveApplicationGV.DataSource = dataTable; ArchiveApplicationGV.DataBind(); } #endregion #region draftApplications { 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("CompetitionName", typeof(string))); List <zApplicationTable> applicationList = (from a in competitionDataBase.zApplicationTable where a.FK_UsersTable == userId && a.Active == true join b in competitionDataBase.zCompetitionsTable on a.FK_CompetitionTable equals b.ID where b.Active == true select a).Distinct().ToList(); foreach (zApplicationTable currentApplication in applicationList) { if (competitionIsClosed(currentApplication) || competitionCountDown.IsCompetitionEndDateExpiredByApplication(currentApplication.ID)) { DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentApplication.ID; dataRow["Name"] = currentApplication.Name; dataRow["CompetitionName"] = (from a in competitionDataBase.zCompetitionsTable where a.ID == (Convert.ToInt32(currentApplication.FK_CompetitionTable)) select a.Name).FirstOrDefault(); dataTable.Rows.Add(dataRow); } } DraftGridView.DataSource = dataTable; DraftGridView.DataBind(); } #endregion } }
protected void AcceptButtonClick(object sender, EventArgs e) { Button button = (Button)sender; if (button != null) { int iD = Convert.ToInt32(button.CommandArgument); CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.Accept == false && a.ID == iD && a.Sended == true select a).FirstOrDefault(); if (currentApplication != null) { List <zExpertPoints> expertPointsList = (from a in competitionDataBase.zExpertPoints where a.Active == true && a.ID != 6 select a).ToList(); List <zExpertsAndApplicationMappingTable> allexperts = (from a in competitionDataBase.zExpertsAndApplicationMappingTable where a.Active == true && a.FK_ApplicationsTable == iD select a).ToList(); foreach (zExpertsAndApplicationMappingTable currentExpert in allexperts) { zExpertPointsValue currentExpertPointComment = (from a in competitionDataBase.zExpertPointsValue where a.FK_ApplicationTable == iD && a.FK_ExpertsTable == currentExpert.FK_UsersTable && a.FK_ExpertPoints == 6 select a).FirstOrDefault(); if (currentExpertPointComment == null) { zExpertPointsValue expertcoment = new zExpertPointsValue(); expertcoment.Active = true; expertcoment.FK_ApplicationTable = currentApplication.ID; expertcoment.FK_ExpertsTable = currentExpert.FK_UsersTable; expertcoment.FK_ExpertPoints = 6; expertcoment.Sended = false; competitionDataBase.zExpertPointsValue.InsertOnSubmit(expertcoment); competitionDataBase.SubmitChanges(); } else { if (currentExpertPointComment.Active == false) { currentExpertPointComment.Active = true; competitionDataBase.SubmitChanges(); } } foreach (zExpertPoints currentExpertPoint in expertPointsList) { zExpertPointsValue currentExpertPointValue = (from a in competitionDataBase.zExpertPointsValue where a.FK_ApplicationTable == iD && a.FK_ExpertsTable == currentExpert.FK_UsersTable && a.FK_ExpertPoints == currentExpertPoint.ID select a).FirstOrDefault(); if (currentExpertPointValue == null) { zExpertPointsValue expertpoints = new zExpertPointsValue(); expertpoints.Active = true; expertpoints.FK_ApplicationTable = currentApplication.ID; expertpoints.FK_ExpertsTable = currentExpert.FK_UsersTable; expertpoints.FK_ExpertPoints = currentExpertPoint.ID; expertpoints.Sended = false; competitionDataBase.zExpertPointsValue.InsertOnSubmit(expertpoints); competitionDataBase.SubmitChanges(); } else { if (currentExpertPointValue.Active == false) { currentExpertPointValue.Active = true; competitionDataBase.SubmitChanges(); } } } } currentApplication.Accept = true; competitionDataBase.SubmitChanges(); } Response.Redirect("ChooseApplication.aspx"); } }
public bool IsApplicationReadyToSend(int applicationId) { List <zBlockTable> blockList = (from a in _competitionDataBase.zBlockTable where a.Active == true select a).ToList(); zApplicationTable currentApplication = (from a in _competitionDataBase.zApplicationTable where a.ID == applicationId && a.Active == true select a).FirstOrDefault(); if (currentApplication == null) { return(false); } if (currentApplication.StartProjectDate == null) { return(false); } if (currentApplication.EndProjectDate == null) { return(false); } List <zPartnersTable> one = (from a in _competitionDataBase.zPartnersTable where a.Active == true && a.Role == true select a).ToList(); zPartnersTable currentone = (from a in _competitionDataBase.zPartnersTable where a.Active == true && a.Role == true join b in _competitionDataBase.zApplicationAndPartnersMappingTable on a.ID equals b.FK_PartnersTable where b.Active == true && b.FK_Application == Convert.ToInt32(currentApplication.ID) select a).FirstOrDefault(); if (one != null && currentone != null) { List <int> lider = (from a in one where a.Name == currentone.Name && a.Surname == currentone.Surname && a.Patronymic == currentone.Patronymic select a.ID).ToList(); if (lider.Count > 1) { return(false); } } List <zPartnersTable> two = (from a in _competitionDataBase.zPartnersTable where a.Active == true && a.Role == false select a).ToList(); zPartnersTable currenttwo = (from a in _competitionDataBase.zPartnersTable where a.Active == true && a.Role == false join b in _competitionDataBase.zApplicationAndPartnersMappingTable on a.ID equals b.FK_PartnersTable where b.Active == true && b.FK_Application == Convert.ToInt32(currentApplication.ID) select a).FirstOrDefault(); if (two != null && currenttwo != null) { List <int> teamuser = (from a in two where a.Name == currenttwo.Name && a.Surname == currenttwo.Surname && a.Patronymic == currenttwo.Patronymic select a.ID).ToList(); if (teamuser.Count >= 2) { return(false); } } foreach (zBlockTable block in blockList) { if (GetStatusIdForBlockInApplication(block.ID, applicationId) != statusAllData) { return(false); } } return(true); }
protected void Page_Load(object sender, EventArgs e) { var sessionParam = Session["ApplicationID"]; var userIdParam = Session["UserID"]; var blokParam = Session["BlockID"]; if (!Page.IsPostBack) { if (sessionParam == null) { //error Response.Redirect("ChooseApplication.aspx"); } else { int iD = (int)sessionParam; int userId = (int)userIdParam; int idblock = (int)blokParam; CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zApplicationTable currenApplication = (from a in competitionDataBase.zApplicationTable where a.ID == iD select a).FirstOrDefault(); List <zSectionTable> sectionList = (from a in competitionDataBase.zSectionTable where a.FK_CompetitionsTable == currenApplication.FK_CompetitionTable && a.Active == true && a.FK_BlockID == idblock select a).ToList(); FillingPages newPagesParams = new FillingPages(); newPagesParams.CurrentPage = 0; newPagesParams.ApplicationId = iD; newPagesParams.BlockId = idblock; newPagesParams.SectionId = new List <int>(); foreach (zSectionTable currentSection in sectionList) { newPagesParams.PagesCount++; newPagesParams.SectionId.Add(currentSection.ID); } Session["PagesParams"] = newPagesParams; Session["IsGoBack"] = false; Response.Redirect("FillSection.aspx"); /* * 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("Status", typeof (string))); * * List<zSectionTable> sectionList = (from a in competitionDataBase.zSectionTable * where a.FK_CompetitionsTable == currenApplication.FK_CompetitionTable * && a.Active == true && a.FK_BlockID == idblock * select a).ToList(); * * foreach (zSectionTable zurrentSection in sectionList) * { * DataRow dataRow = dataTable.NewRow(); * dataRow["ID"] = zurrentSection.ID; * dataRow["Name"] = zurrentSection.Name; * dataRow["Status"] = "Не заполнено/заполнено"; * dataTable.Rows.Add(dataRow); * } * * ApplicationGV.DataSource = dataTable; * ApplicationGV.DataBind(); */ } } }
protected void CreateEditButton_Click(object sender, EventArgs e) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); var sessionParam = Session["ApplicationID"]; var konkursid = Session["ID_Konkurs"]; var userIdParam = Session["UserID"]; int iD = 0; if (sessionParam != null) { iD = (int)sessionParam; } int idkon = 0; if (konkursid != null) { idkon = (int)konkursid; } int userId = (int)userIdParam; zApplicationTable currentApplication; if (iD > 0) { if (ApplicationNameTextBox.Text.Length > 0) { currentApplication = (from a in competitionDataBase.zApplicationTable where a.Active == true && a.ID == iD select a).FirstOrDefault(); if (currentApplication == null) { //error Response.Redirect("~/Default.aspx"); } else { currentApplication.Name = ApplicationNameTextBox.Text; competitionDataBase.SubmitChanges(); Session["ApplicationID"] = currentApplication.ID; Response.Redirect("ChooseApplicationAction.aspx"); } } } else { if (ApplicationNameTextBox.Text.Length > 0) { currentApplication = new zApplicationTable(); currentApplication.Name = ApplicationNameTextBox.Text; currentApplication.FK_CompetitionTable = idkon; currentApplication.Active = true; currentApplication.FK_UsersTable = userId; currentApplication.CretaDateTime = DateTime.Now; currentApplication.Sended = false; currentApplication.Accept = false; competitionDataBase.zApplicationTable.InsertOnSubmit(currentApplication); competitionDataBase.SubmitChanges(); Session["ApplicationID"] = currentApplication.ID; Response.Redirect("ChooseApplicationAction.aspx"); } } Response.Redirect("~/Default.aspx"); }
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) { var userIdtmp = Session["UserID"]; if (userIdtmp == null) { Response.Redirect("~/Default.aspx"); } int userId = (int)userIdtmp; if (!Page.IsPostBack) { CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext(); List <zCompetitionsTable> competitionsList = (from a in CompetitionsDataBase.zCompetitionsTable where a.Active == true && a.FK_Curator == userId select a).ToList(); foreach (zCompetitionsTable current in competitionsList) { List <zApplicationTable> applicationsList = (from a in CompetitionsDataBase.zApplicationTable where a.Active == true && a.Sended == true && a.FK_CompetitionTable == current.ID select a).ToList(); System.Data.DataTable dataTable = new System.Data.DataTable(); dataTable.Columns.Add("ID", typeof(string)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Competition", typeof(string)); dataTable.Columns.Add("Experts", typeof(string)); dataTable.Columns.Add("Email", typeof(string)); dataTable.Columns.Add("Accept", typeof(string)); dataTable.Columns.Add("SendedDataTime", typeof(string)); foreach (zApplicationTable currentApplication in applicationsList) { DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentApplication.ID; dataRow["Name"] = currentApplication.Name; dataRow["SendedDataTime"] = currentApplication.SendedDataTime.ToString().Split(' ')[0]; dataRow["Competition"] = (from a in CompetitionsDataBase.zCompetitionsTable where a.ID == currentApplication.FK_CompetitionTable select a.Name).FirstOrDefault(); dataRow["Email"] = (from a in CompetitionsDataBase.UsersTable where a.ID == currentApplication.FK_UsersTable select a.Email).FirstOrDefault(); zApplicationTable status = (from a in CompetitionsDataBase.zApplicationTable where a.ID == currentApplication.ID select a).FirstOrDefault(); if (status.Accept == true) { dataRow["Accept"] = "Принята"; } else { dataRow["Accept"] = "На рассмотрении"; } List <UsersTable> expertsList = (from a in CompetitionsDataBase.UsersTable join b in CompetitionsDataBase.zExpertsAndApplicationMappingTable on a.ID equals b.FK_UsersTable where a.AccessLevel == 5 && a.Active == true && b.FK_ApplicationsTable == currentApplication.ID && b.Active == true select a).ToList(); string expertNamesList = ""; foreach (UsersTable currentExpert in expertsList) { expertNamesList += currentExpert.Email + " \n"; } dataRow["Experts"] = expertNamesList; dataTable.Rows.Add(dataRow); } ApplicationGV.DataSource = dataTable; ApplicationGV.DataBind(); } } }
protected void BackButtonClick(object sender, EventArgs e) { Button button = (Button)sender; if (button != null) { int iD = Convert.ToInt32(button.CommandArgument); CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext(); zApplicationTable currentapplication = (from a in CompetitionsDataBase.zApplicationTable where a.Active == true && a.Accept == true && a.ID == Convert.ToInt32(button.CommandArgument) select a).FirstOrDefault(); if (currentapplication != null) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); List <zExpertPoints> expertPointsList = (from a in competitionDataBase.zExpertPoints where a.Active == true && a.ID != 6 select a).ToList(); List <zExpertsAndApplicationMappingTable> allexperts = (from a in competitionDataBase.zExpertsAndApplicationMappingTable where a.Active == true && a.FK_ApplicationsTable == iD select a).ToList(); foreach (zExpertsAndApplicationMappingTable currentExpert in allexperts) { zExpertPointsValue currentExpertPointComment = (from a in competitionDataBase.zExpertPointsValue where a.FK_ApplicationTable == iD && a.FK_ExpertsTable == currentExpert.FK_UsersTable && a.FK_ExpertPoints == 6 select a).FirstOrDefault(); if (currentExpertPointComment != null) { if (currentExpertPointComment.Active == true) { currentExpertPointComment.Active = false; competitionDataBase.SubmitChanges(); } } foreach (zExpertPoints currentExpertPoint in expertPointsList) { zExpertPointsValue currentExpertPointValue = (from a in competitionDataBase.zExpertPointsValue where a.FK_ApplicationTable == iD && a.FK_ExpertsTable == currentExpert.FK_UsersTable && a.FK_ExpertPoints == currentExpertPoint.ID select a).FirstOrDefault(); if (currentExpertPointValue != null) { if (currentExpertPointValue.Active == true) { currentExpertPointValue.Active = false; competitionDataBase.SubmitChanges(); } } } } currentapplication.Accept = false; CompetitionsDataBase.SubmitChanges(); } } Response.Redirect("ReadyApplications.aspx"); }