protected void Button1_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 CompetitionsDataBase = new CompetitionDataContext(); foreach (GridViewRow dataRow in EvaluateGV.Rows) { Label labelID = (Label)dataRow.FindControl("ID"); TextBox valueTextBox = (TextBox)dataRow.FindControl("ValueTextBox"); if (labelID != null) { zExpertPointsValue currentExpertPointValue = (from a in CompetitionsDataBase.zExpertPointsValue where a.ID == Convert.ToInt32(labelID.Text) select a).FirstOrDefault(); if (currentExpertPointValue != null) { if (valueTextBox.Text.Any()) { currentExpertPointValue.Value = valueTextBox.Text; } currentExpertPointValue.LastChangeDataTime = DateTime.Now; CompetitionsDataBase.SubmitChanges(); } } } #region doComment var commentIdTemp = ViewState["CommentID"]; if (commentIdTemp != null) { int commentId = (int)commentIdTemp; zExpertPointsValue commentExpertPointValue = (from a in CompetitionsDataBase.zExpertPointsValue where a.ID == commentId select a).FirstOrDefault(); if (commentExpertPointValue != null) { if (CommentTextBox.Text.Any()) { commentExpertPointValue.Value = CommentTextBox.Text; } commentExpertPointValue.LastChangeDataTime = DateTime.Now; CompetitionsDataBase.SubmitChanges(); } } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { 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 CompetitionsDataBase = new CompetitionDataContext(); List <zExpertPoints> expertPointsList = (from a in CompetitionsDataBase.zExpertPoints where a.Active == true && a.ID != 6 select a).ToList(); DataTable dataTable = new DataTable(); dataTable.Columns.Add("ID", typeof(string)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Text", typeof(string)); dataTable.Columns.Add("ErrorText", typeof(string)); dataTable.Columns.Add("MaxValue", typeof(int)); dataTable.Columns.Add("MinValue", typeof(int)); foreach (zExpertPoints currentExpertPoint in expertPointsList) { zExpertPointsValue currentExpertPointValue = (from a in CompetitionsDataBase.zExpertPointsValue where a.FK_ApplicationTable == applicationId && a.FK_ExpertsTable == userId && a.FK_ExpertPoints == currentExpertPoint.ID && a.Sended == false select a).FirstOrDefault(); if (currentExpertPointValue == null) { currentExpertPointValue = new zExpertPointsValue(); currentExpertPointValue.FK_ApplicationTable = applicationId; currentExpertPointValue.FK_ExpertsTable = userId; currentExpertPointValue.FK_ExpertPoints = currentExpertPoint.ID; currentExpertPointValue.Sended = false; currentExpertPointValue.Active = true; CompetitionsDataBase.zExpertPointsValue.InsertOnSubmit(currentExpertPointValue); CompetitionsDataBase.SubmitChanges(); } DataRow dataRow = dataTable.NewRow(); dataRow["ID"] = currentExpertPointValue.ID; dataRow["Name"] = currentExpertPoint.Name; dataRow["ErrorText"] = "Значение должно быть в диапазоне от 0 до " + currentExpertPoint.MaxValue; dataRow["MaxValue"] = currentExpertPoint.MaxValue; dataRow["MinValue"] = currentExpertPoint.MinValue; if (currentExpertPointValue.Value != null) { dataRow["Text"] = currentExpertPointValue.Value; } else { dataRow["Text"] = ""; } dataTable.Rows.Add(dataRow); } EvaluateGV.DataSource = dataTable; EvaluateGV.DataBind(); #region doComment zExpertPointsValue commentExpertPointValue = (from a in CompetitionsDataBase.zExpertPointsValue where a.FK_ApplicationTable == applicationId && a.FK_ExpertsTable == userId && a.FK_ExpertPoints == 6 select a).FirstOrDefault(); if (commentExpertPointValue == null) { commentExpertPointValue = new zExpertPointsValue(); commentExpertPointValue.FK_ApplicationTable = applicationId; commentExpertPointValue.FK_ExpertsTable = userId; commentExpertPointValue.LastChangeDataTime = DateTime.Now; commentExpertPointValue.FK_ExpertPoints = 6; commentExpertPointValue.Sended = false; CompetitionsDataBase.zExpertPointsValue.InsertOnSubmit(commentExpertPointValue); CompetitionsDataBase.SubmitChanges(); } if (commentExpertPointValue.Value != null) { CommentTextBox.Text = commentExpertPointValue.Value; } else { CommentTextBox.Text = ""; } ViewState["CommentID"] = commentExpertPointValue.ID; #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"); } }
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"); }