Beispiel #1
0
        private void GridviewApdate() //Обновление гридвью
        {
            TextBox1.Text = null;
            TextBox2.Text = null;
            CompetitionDataContext manual = new CompetitionDataContext();
            DataTable dataTable           = new DataTable();

            dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
            dataTable.Columns.Add(new DataColumn("IndicatorName", typeof(string)));
            dataTable.Columns.Add(new DataColumn("IndicatorValue", typeof(int)));
            List <zIndicatorManualTable> List = (from a in manual.zIndicatorManualTable
                                                 where a.Active == true
                                                 select a).ToList();

            foreach (zIndicatorManualTable current in List)
            {
                DataRow dataRow = dataTable.NewRow();
                dataRow["ID"]             = current.ID;
                dataRow["IndicatorName"]  = current.IndicatorName;
                dataRow["IndicatorValue"] = Convert.ToInt32(current.IndicatorValue);
                dataTable.Rows.Add(dataRow);
            }
            IndicatorGV.DataSource = dataTable;
            IndicatorGV.DataBind();
        }
Beispiel #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");
        }
Beispiel #3
0
        protected void DeleteButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase  = new CompetitionDataContext();
                zConstantListTable     constantListToDelete = (from a in competitionDataBase.zConstantListTable
                                                               where a.ID == iD
                                                               select a).FirstOrDefault();
                List <zCollectedDataTable> constatvalue = (from a in competitionDataBase.zCollectedDataTable
                                                           where a.Active && a.FK_ConstantListTable == constantListToDelete.ID
                                                           select a).ToList();
                if (constantListToDelete != null)
                {
                    constantListToDelete.Active = false;
                    competitionDataBase.SubmitChanges();
                    foreach (zCollectedDataTable n in constatvalue)
                    {
                        n.Active = false;
                        competitionDataBase.SubmitChanges();
                    }
                }
                else
                {
                    //error
                }
            }
            Response.Redirect("ChooseConstantList.aspx");
        }
        private ListItem[] GetColumnsInThisApplicationWithBitDataType(int sectionId, int competitionId)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            List <zColumnTable>    columnList          = (from a in competitionDataBase.zColumnTable
                                                          where a.Active
                                                          join b in competitionDataBase.zSectionTable
                                                          on a.FK_SectionTable equals b.ID
                                                          where b.Active == true &&
                                                          b.ID != sectionId &&
                                                          b.FK_CompetitionsTable == competitionId
                                                          select a).Distinct().ToList();
            List <zColumnTable> onlyBitColumnList = new List <zColumnTable>();
            DataType            dataType          = new DataType();

            foreach (zColumnTable currentColumn in columnList)
            {
                if (dataType.IsDataTypeBit(currentColumn.DataType))
                {
                    onlyBitColumnList.Add(currentColumn);
                }
            }

            ListItem[] newListItemAray = new ListItem[onlyBitColumnList.Count];

            for (int i = 0; i < onlyBitColumnList.Count; i++)
            {
                ListItem newItem = new ListItem();
                newItem.Text       = onlyBitColumnList[i].Name;
                newItem.Value      = onlyBitColumnList[i].ID.ToString();
                newListItemAray[i] = newItem;
            }
            return(newListItemAray);
        }
        protected void ExpertDeleteButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (button != null)
            {
                var IdTmp = Session["GroupID"];
                if (IdTmp == null)
                {
                    Response.Redirect("Main.aspx");
                }
                int groupid = Convert.ToInt32(IdTmp);

                CompetitionDataContext            CompetitionsDataBase = new CompetitionDataContext();
                zExpertAndExpertGroupMappingTable expertdelete         =
                    (from a in CompetitionsDataBase.zExpertAndExpertGroupMappingTable
                     where a.FK_UsersTable == Convert.ToInt32(button.CommandArgument) &&
                     a.Active == true &&
                     a.FK_ExpertGroupTable == groupid
                     select a).FirstOrDefault();
                if (expertdelete != null)
                {
                    expertdelete.Active = false;
                    CompetitionsDataBase.SubmitChanges();
                }
            }
            Response.Redirect("CompetitionExpertEdit.aspx");
        }
Beispiel #6
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Button exp    = (Button)e.Row.FindControl("ExpertChangeButton");
            Button accept = (Button)e.Row.FindControl("AcceptButton");
            Button back   = (Button)e.Row.FindControl("BackToUserButton");

            if (exp != null && accept != null)
            {
                CompetitionDataContext   CompetitionsDataBase = new CompetitionDataContext();
                List <zApplicationTable> applicationsList     = (from a in CompetitionsDataBase.zApplicationTable
                                                                 where a.Active == true && a.Accept == false && a.ID == Convert.ToInt32(accept.CommandArgument)
                                                                 join b in CompetitionsDataBase.zCompetitionsTable
                                                                 on a.FK_CompetitionTable equals b.ID
                                                                 where b.Active == true
                                                                 select a).ToList();


                foreach (var n in applicationsList)
                {
                    if (n.Sended == false)
                    {
                        exp.Enabled    = false;
                        accept.Enabled = false;
                        back.Enabled   = false;
                    }
                    else
                    {
                        exp.Enabled    = true;
                        accept.Enabled = true;
                        back.Enabled   = true;
                    }
                }
            }
        }
        void DeleteRowButtonClick(object sender, EventArgs e)
        {
            ImageButton button = (ImageButton)sender;
            {
                SaveChanges();
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                var userIdParam   = Session["UserID"];
                int userId        = Convert.ToInt32(userIdParam);
                var applicationId = Session["ApplicationID"];
                int appid         = Convert.ToInt32(applicationId);
                int partnerid     = Convert.ToInt32(button.CommandArgument);

                zPartnersTable currentPartner = (from a in competitionDataBase.zPartnersTable
                                                 where a.Active == true && a.ID == partnerid
                                                 join b in competitionDataBase.zApplicationAndPartnersMappingTable
                                                 on a.ID equals b.FK_PartnersTable
                                                 where b.Active == true && b.FK_Application == appid
                                                 select a).FirstOrDefault();
                currentPartner.Active = false;
                competitionDataBase.SubmitChanges();

                zApplicationAndPartnersMappingTable currentLink =
                    (from a in competitionDataBase.zApplicationAndPartnersMappingTable
                     where a.Active == true && a.FK_PartnersTable == partnerid &&
                     a.FK_Application == appid
                     select a).FirstOrDefault();

                currentLink.Active = false;
                competitionDataBase.SubmitChanges();
                Response.Redirect("ChooseApplicationAction.aspx");
            }
        }
Beispiel #8
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();
                 }
             }
         }
     }
 }
Beispiel #9
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var userIdtmp = Session["UserID"];

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

            Button newapp = (Button)e.Row.FindControl("NewApplication");

            if (newapp != null)
            {
                CompetitionDataContext   competitionDataBase = new CompetitionDataContext();
                List <zApplicationTable> applicationexist    = (from a in competitionDataBase.zApplicationTable where
                                                                a.FK_UsersTable == userId && a.Sended == true && a.Active == true
                                                                join b in competitionDataBase.zCompetitionsTable
                                                                on a.FK_CompetitionTable equals b.ID
                                                                where b.Active == true
                                                                select a).Distinct().ToList();

                if (applicationexist.Count != 0)
                {
                    newapp.Enabled = false;
                    Label1.Visible = true;
                }
                else
                {
                    Label2.Visible = true;
                }
            }
        }
Beispiel #10
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);
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext();
                List <zExpertGroup>    groupList            = (from a in CompetitionsDataBase.zExpertGroup
                                                               where a.Active == true
                                                               select a).ToList();
                if (groupList != null)
                {
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add("ID", typeof(string));
                    dataTable.Columns.Add("Name", typeof(string));

                    foreach (zExpertGroup current in groupList)
                    {
                        DataRow dataRow = dataTable.NewRow();
                        dataRow["ID"]   = current.ID;
                        dataRow["Name"] = current.Name;
                        dataTable.Rows.Add(dataRow);
                    }
                    sovetExpertsGV.DataSource = dataTable;
                    sovetExpertsGV.DataBind();
                }
            }
        }
        protected void ExpertAddButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            if (button != null)
            {
                var appIdTmp = Session["ApplicationID"];
                if (appIdTmp == null)
                {
                    Response.Redirect("ApllicationExpertEdit.aspx");
                }
                int applicationId = Convert.ToInt32(appIdTmp);

                CompetitionDataContext CompetitionsDataBase = new CompetitionDataContext();
                zExpertsAndApplicationMappingTable expertAndApplicationConnection = (from a in CompetitionsDataBase.zExpertsAndApplicationMappingTable
                                                                                     where a.FK_UsersTable == Convert.ToInt32(button.CommandArgument)
                                                                                     && a.FK_ApplicationsTable == applicationId
                                                                                     select a).FirstOrDefault();
                if (expertAndApplicationConnection != null)
                {
                    expertAndApplicationConnection.Active = true;
                    CompetitionsDataBase.SubmitChanges();
                }
                else
                {
                    expertAndApplicationConnection = new zExpertsAndApplicationMappingTable();
                    expertAndApplicationConnection.Active = true;
                    expertAndApplicationConnection.FK_ApplicationsTable = applicationId;
                    expertAndApplicationConnection.FK_UsersTable = Convert.ToInt32(button.CommandArgument);
                    CompetitionsDataBase.zExpertsAndApplicationMappingTable.InsertOnSubmit(expertAndApplicationConnection);
                    CompetitionsDataBase.SubmitChanges();
                }
            }
            Response.Redirect("ApllicationExpertEdit.aspx");
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            var sessionParam1 = Session["ApplicationID"];
            var sessionParam2 = Session["UserID"];

            if ((sessionParam1 == null) || (sessionParam2 == null))
            {
                //error
                Response.Redirect("~/Default.aspx");
            }
            int applicationId = Convert.ToInt32(sessionParam1);
            int userId        = Convert.ToInt32(sessionParam2);

            CompetitionDataContext    competitionDataBase = new CompetitionDataContext();
            List <zExpertPointsValue> currentApplication  = (from a in competitionDataBase.zExpertPointsValue where a.Active == true &&
                                                             a.FK_ApplicationTable == applicationId && a.FK_ExpertsTable == userId
                                                             select a).ToList();

            foreach (zExpertPointsValue current in currentApplication)
            {
                current.Sended         = true;
                current.SendedDataTime = DateTime.Now;
                competitionDataBase.SubmitChanges();
            }
            Response.Redirect("~/Default.aspx");
        }
Beispiel #14
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();
            }
        }
Beispiel #15
0
        protected void CompetitionsGVRowDataBound(object sender, GridViewRowEventArgs e)
        {
            Button open   = (Button)e.Row.FindControl("OpenButton");
            Button change = (Button)e.Row.FindControl("ChangeButton");

            if (open != null && change != null)
            {
                CompetitionDataContext    CompetitionsDataBase = new CompetitionDataContext();
                List <zCompetitionsTable> compList             = (from a in CompetitionsDataBase.zCompetitionsTable
                                                                  where a.Active == true && a.ID == Convert.ToInt32(open.CommandArgument)
                                                                  select a).ToList();

                foreach (var n in compList)
                {
                    if (n.OpenForApplications == true)
                    {
                        open.Enabled   = false;
                        change.Enabled = false;
                    }
                    else
                    {
                        open.Enabled   = true;
                        change.Enabled = true;
                    }
                }
            }
        }
        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");
        }
Beispiel #17
0
        public double   GetValueFromCollectedData(int rowId, int columnId)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            zColumnTable           currentColumn       = (from a in competitionDataBase.zColumnTable
                                                          where a.ID == columnId
                                                          select a).FirstOrDefault();
            DataType dataType = new DataType();

            if (columnId != null)
            {
                zCollectedDataTable currenCollectedDataTable = (from a in competitionDataBase.zCollectedDataTable
                                                                where a.Active == true &&
                                                                a.FK_ColumnTable == columnId &&
                                                                a.FK_CollectedRowsTable == rowId
                                                                select a).FirstOrDefault();

                if (dataType.IsDataTypeFloat(currentColumn.DataType) || dataType.IsCellCalculateInRow(currentColumn.DataType))
                {
                    return((double)currenCollectedDataTable.ValueDouble);
                }
                if (dataType.IsDataTypeInteger(currentColumn.DataType))
                {
                    return((double)currenCollectedDataTable.ValueInt);
                }
                if (dataType.IsDataTypeBit(currentColumn.DataType))
                {
                    if ((bool)currenCollectedDataTable.ValueBit)
                    {
                        return(1);
                    }
                }
            }
            return(0);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var userId = Session["UserID"];

            if (userId == null)
            {
                FormsAuthentication.SignOut();
                Session.Abandon();
                Response.Redirect("~/Account/Login.aspx");
            }
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            UsersTable             user = (from usersTables in competitionDataBase.UsersTable
                                           where usersTables.ID == (int)userId
                                           select usersTables).FirstOrDefault();

            if (user != null)
            {
                Session["UserID"] = user.ID;
                Directions(user);
            }
            else
            {
                FormsAuthentication.SignOut();
                Session.Abandon();
                Response.Redirect("~/Account/Login.aspx");
            }
        }
        protected void AddRowButton_Click(object sender, EventArgs e)
        {
            SaveChanges();
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var userIdParam   = Session["UserID"];
            int userId        = Convert.ToInt32(userIdParam);
            var applicationId = Session["ApplicationID"];
            int appid         = Convert.ToInt32(applicationId);


            zPartnersTable newPartner = new zPartnersTable();

            newPartner.Active = true;
            newPartner.Role   = false;
            competitionDataBase.zPartnersTable.InsertOnSubmit(newPartner);
            competitionDataBase.SubmitChanges();

            zApplicationAndPartnersMappingTable newLink = new zApplicationAndPartnersMappingTable();

            newLink.Active           = true;
            newLink.FK_Application   = appid;
            newLink.FK_PartnersTable = newPartner.ID;
            competitionDataBase.zApplicationAndPartnersMappingTable.InsertOnSubmit(newLink);
            competitionDataBase.SubmitChanges();
            Response.Redirect("ChooseApplicationAction.aspx");
        }
        protected void OpenButtonClick(object sender, EventArgs e)
        {
            SaveDates();
            Button button = (Button)sender;
            {
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                zDocumentsTable        currentDocument     = (from a in competitionDataBase.zDocumentsTable
                                                              where a.ID == Convert.ToInt32(button.CommandArgument)
                                                              select a).FirstOrDefault();
                if (currentDocument != null)
                {
                    if (currentDocument.LinkOut != null)
                    {
                        Response.Redirect(currentDocument.LinkOut);
                    }
                    else if (currentDocument.Name != null)
                    {
                        String path = Server.MapPath("~/documents/byApplication") + "\\\\" +
                                      currentDocument.FK_ApplicationTable.ToString() + "\\\\" + currentDocument.Name;
                        //  Response.Redirect(,false);

                        HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                        HttpContext.Current.Response.AppendHeader("Content-Disposition",
                                                                  "attachment; filename=" + currentDocument.Name);
                        HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(path));
                        HttpContext.Current.Response.End();

                        Response.End();
                    }
                }
            }
        }
        public void SaveChanges()
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();

            foreach (GridViewRow currentRow in PartnersGV.Rows)
            {
                Label    partnerID  = (Label)currentRow.FindControl("ID");
                TextBox  surname    = (TextBox)currentRow.FindControl("Surname");
                TextBox  name       = (TextBox)currentRow.FindControl("Name");
                TextBox  patronymic = (TextBox)currentRow.FindControl("Patronymic");
                CheckBox role       = (CheckBox)currentRow.FindControl("Role");

                if (partnerID != null)
                {
                    zPartnersTable currentpartner = (from a in competitionDataBase.zPartnersTable
                                                     where a.ID == Convert.ToInt32(partnerID.Text)
                                                     select a).FirstOrDefault();
                    if (currentpartner != null)
                    {
                        if (surname.Text.Any() && name.Text.Any() && patronymic.Text.Any())
                        {
                            currentpartner.Surname    = surname.Text;
                            currentpartner.Name       = name.Text;
                            currentpartner.Patronymic = patronymic.Text;
                            currentpartner.Role       = role.Checked;
                            competitionDataBase.SubmitChanges();
                        }
                    }
                }
            }
        }
Beispiel #22
0
        public string   GetDropDownSelectedValueString(zColumnTable currentColumn, zCollectedDataTable currentCollectedData, int applicationId, int currentRowId)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            DataType dataType = new DataType();

            #region ConstantDropDown

            if (dataType.IsDataTypeConstantDropDown(currentColumn.DataType))
            {
                zCollectedDataTable getCollectedData =
                    (from a in competitionDataBase.zCollectedDataTable
                     where a.ID == currentCollectedData.ValueFK_CollectedDataTable
                     select a).FirstOrDefault();
                return(getCollectedData.ValueText);
            }

            #endregion
            #region OtherTableDropDown

            if (dataType.IsDataTypeDropDown(currentColumn.DataType))
            {
                zCollectedDataTable getCollectedData =
                    (from a in competitionDataBase.zCollectedDataTable
                     where a.ID == currentCollectedData.ValueFK_CollectedDataTable
                     select a).FirstOrDefault();
                return(getCollectedData.ValueText);
            }

            #endregion
            return("");
        }
Beispiel #23
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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var sessionParam1 = Session["CompetitionID"];
                var sessionParam2 = Session["SectionID"];
                if ((sessionParam1 == null) || (sessionParam2 == null))
                {
                    //error
                    Response.Redirect("ChooseSection.aspx");
                }
                else
                {
                    CompetitionDataContext newCompetition = new CompetitionDataContext();

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

                    ListItem tmpItem2 = new ListItem();
                    tmpItem2.Text  = "Выберите блок к которому относится форма";
                    tmpItem2.Value = "0";
                    DropDownList1.Items.Add(tmpItem2);

                    foreach (zBlockTable current in blocks)
                    {
                        ListItem tmpItem = new ListItem();
                        tmpItem.Text  = current.BlockName;
                        tmpItem.Value = current.ID.ToString();
                        DropDownList1.Items.Add(tmpItem);
                    }

                    int competitionId = (int)sessionParam1;
                    int sectionId     = (int)sessionParam2;
                    if (sectionId > 0)
                    {
                        CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                        zSectionTable          currentSection      = (from a in competitionDataBase.zSectionTable
                                                                      where a.Active == true &&
                                                                      a.ID == sectionId &&
                                                                      a.FK_CompetitionsTable == competitionId
                                                                      select a).FirstOrDefault();
                        if (currentSection == null)
                        {
                            //error
                            Response.Redirect("ChooseSection.aspx");
                        }
                        else
                        {
                            NameTextBox.Text            = currentSection.Name;
                            DescriptionTextBox.Text     = currentSection.Description;
                            DropDownList1.SelectedIndex = Convert.ToInt32(currentSection.FK_BlockID);
                            MaxRowCountTextBox.Text     = currentSection.ColumnMaxCount.ToString();
                        }
                    }
                }
            }
        }
Beispiel #25
0
        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 competitionDataBase = new CompetitionDataContext();

                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.Active == true && a.Sended == true
                                                            join b in competitionDataBase.zCompetitionsTable
                                                            on a.FK_CompetitionTable equals b.ID
                                                            where b.Active == true
                                                            join c in competitionDataBase.zExpertsAndApplicationMappingTable
                                                            on a.ID equals c.FK_ApplicationsTable
                                                            where c.Active == true && c.FK_UsersTable == userId
                                                            select a).Distinct().ToList();

                List <zApplicationTable> notreadyapp = new List <zApplicationTable>();
                foreach (zApplicationTable current in applicationList)
                {
                    List <zExpertPointsValue> notsended = (from a in competitionDataBase.zExpertPointsValue
                                                           where a.Active == true && a.Sended == false &&
                                                           a.FK_ApplicationTable == current.ID && a.FK_ExpertsTable == userId
                                                           select a).ToList();
                    if (notsended.Count == 6)
                    {
                        notreadyapp.Add(current);
                    }
                }


                foreach (zApplicationTable currentApplication in notreadyapp)
                {
                    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);
                }

                ApplicationGV.DataSource = dataTable;
                ApplicationGV.DataBind();
            }
        }
Beispiel #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // XmlCreate xmlCreate = new XmlCreate();

            /*  TextBox1.Text = xmlCreate.StartTable() +
             *                xmlCreate.StartRow() +
             *                xmlCreate.StartCell() +
             *                "123" +
             *                xmlCreate.EndCell() +
             *                xmlCreate.EndRow() +
             *                xmlCreate.EndTable();
             */
            var userIdtmp = Session["UserID"];

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

            if (!Page.IsPostBack)
            {
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();

                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 && a.Sended == false
                                                            join b in competitionDataBase.zCompetitionsTables
                                                            on a.FK_CompetitionTable equals b.ID
                                                            where b.Active == true &&
                                                            b.OpenForApplications == 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.zCompetitionsTables
                                                  where a.ID == (Convert.ToInt32(currentApplication.FK_CompetitionTable))
                                                  select a.Name).FirstOrDefault();
                    dataTable.Rows.Add(dataRow);
                }

                /*DataSet newDataSet = new DataSet();
                 * newDataSet.Tables.Add(dataTable);
                 * string filePath = @"C:\1\1112.xml";
                 * newDataSet.WriteXml(filePath);
                 */
                ApplicationGV.DataSource = dataTable;
                ApplicationGV.DataBind();
            }
        }
        protected void CreateSaveButtonClick(object sender, EventArgs e)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var sessionParam1 = Session["CompetitionID"];
            var sessionParam2 = Session["SectionID"];

            if ((sessionParam1 == null) || (sessionParam2 == null))
            {
                //error
                Response.Redirect("ChooseSection.aspx");
            }
            else
            {
                int competitionId = (int)sessionParam1;
                int sectionId     = (int)sessionParam2;
                if (sectionId > 0)
                {
                    if ((NameTextBox.Text.Length > 0) && (DescriptionTextBox.Text.Length > 0))
                    {
                        zSectionTable currentSection = (from a in competitionDataBase.zSectionTable
                                                        where a.Active == true &&
                                                        a.ID == sectionId &&
                                                        a.FK_CompetitionsTable == competitionId
                                                        select a).FirstOrDefault();
                        if (currentSection == null)
                        {
                            //error
                            Response.Redirect("ChooseSection.aspx");
                        }
                        else
                        {
                            currentSection.Name           = NameTextBox.Text;
                            currentSection.Description    = DescriptionTextBox.Text;
                            currentSection.FK_BlockID     = Convert.ToInt32(DropDownList1.SelectedIndex);
                            currentSection.ColumnMaxCount = Convert.ToInt32(MaxRowCountTextBox.Text);

                            competitionDataBase.SubmitChanges();
                        }
                    }
                }
                else
                {
                    if ((NameTextBox.Text.Length > 0) && (DescriptionTextBox.Text.Length > 0))
                    {
                        zSectionTable newSection = new zSectionTable();
                        newSection.Name                 = NameTextBox.Text;
                        newSection.Description          = DescriptionTextBox.Text;
                        newSection.FK_BlockID           = Convert.ToInt32(DropDownList1.SelectedIndex);
                        newSection.ColumnMaxCount       = Convert.ToInt32(MaxRowCountTextBox.Text);
                        newSection.Active               = true;
                        newSection.FK_CompetitionsTable = competitionId;
                        competitionDataBase.zSectionTable.InsertOnSubmit(newSection);
                        competitionDataBase.SubmitChanges();
                    }
                }
            }
            Response.Redirect("ChooseSection.aspx");
        }
Beispiel #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CompetitionDataContext   CompetitionsDataBase = new CompetitionDataContext();
                List <zApplicationTable> applicationsList     = (from a in CompetitionsDataBase.zApplicationTable
                                                                 where a.Active == true && a.Accept == false
                                                                 join b in  CompetitionsDataBase.zCompetitionsTable
                                                                 on a.FK_CompetitionTable equals b.ID
                                                                 where b.Active == true
                                                                 select a).ToList();


                if (applicationsList != null)
                {
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add("ID", typeof(string));
                    dataTable.Columns.Add("Name", typeof(string));
                    dataTable.Columns.Add("Email", typeof(string));
                    dataTable.Columns.Add("Autor", typeof(string));
                    dataTable.Columns.Add("Competition", 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["Email"] = (from a in CompetitionsDataBase.UsersTable
                                            where a.ID == currentApplication.FK_UsersTable
                                            select a.Email).FirstOrDefault();

                        if (currentApplication.Sended == false)
                        {
                            dataRow["SendedDataTime"] = "Заявка в процессе заполнения";
                        }
                        else
                        {
                            dataRow["SendedDataTime"] = currentApplication.SendedDataTime.ToString().Split(' ')[0];
                        }
                        dataRow["Competition"] = (from a in CompetitionsDataBase.zCompetitionsTable
                                                  where a.ID == currentApplication.FK_CompetitionTable
                                                  select a.Name).FirstOrDefault();

                        dataTable.Rows.Add(dataRow);
                    }
                    ApplicationGV.DataSource = dataTable;
                    ApplicationGV.DataBind();
                }
            }
            else
            {
                Label1.Visible = true;
            }
        }
Beispiel #29
0
        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);
                    }
                }
            }
        }
Beispiel #30
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);
        }