//Add for assignments private void button13_Click(object sender, EventArgs e) { count[0] += 1; number[0] = double.Parse(Grade1.Text); total[0] += number[0]; Grade1.Clear(); }
//Clear function private void ClearListBoxes() { Avg1.Clear(); Avg2.Clear(); Avg3.Clear(); Avg4.Clear(); Avg5.Clear(); Avg6.Clear(); GrdNeeded.Clear(); Ovrl.Clear(); like.Clear(); think.Clear(); Grade1.Clear(); Grade2.Clear(); Grade3.Clear(); Grade4.Clear(); Assign.Checked = false; Quizz.Checked = false; Labs.Checked = false; Midterm.Checked = false; checkBonus.Checked = false; W1.Clear(); W2.Clear(); W3.Clear(); W4.Clear(); }
/*如果用户登录,那么就展示全部课程*/ private void InitData() { string strCon = "Integrated Security=SSPI;Initial Catalog='NetDesign';Data Source='DESKTOP-HJQH3C9';User ID='sa'; Password = '******'; Connect Timeout = 30"; SqlConnection conn = new SqlConnection(strCon); DataSet ds = new DataSet(); string str = "SELECT sc.c_id AS 课程编号, c.c_name AS 课程名称, s.s_id AS 学号 , s.s_name AS 学生姓名, sc.sc_score AS 成绩 FROM SC sc LEFT JOIN Student s ON sc.s_id = s.s_id LEFT JOIN Course c ON sc.c_id = c.c_id ORDER BY sc.c_id; "; SqlDataAdapter da = new SqlDataAdapter(str, conn); conn.Open(); da.Fill(ds); conn.Close(); Grade1.DataSource = ds; Grade1.DataBind(); }
/// <summary> /// 減少人數 /// </summary> public void Decrease(OnlineStudent student) { if (student.GradeYear == "1" || student.GradeYear == "4" || student.GradeYear == "7" || student.GradeYear == "10") { Grade1.SetDecrease(student.School, 1); } else if (student.GradeYear == "2" || student.GradeYear == "5" || student.GradeYear == "8" || student.GradeYear == "11") { Grade2.SetDecrease(student.School, 1); } else if (student.GradeYear == "3" || student.GradeYear == "6" || student.GradeYear == "9" || student.GradeYear == "12") { Grade3.SetDecrease(student.School, 1); } NowStudentCount--; }
public Tuple <bool, string> SaveWorkerRuleRule(string cuUserId, dynamic item) { bool success = false; string msg = ""; string UserId, Department, DateFrom, DateTo, Remark, UserId1, UserId2, Team; int Score, Rule, Nature, Priority, WorkerRuleId; int? WorkerSettingId, Grade1, Grade2, Grade3, Grade4, LevelNo, GroupID, GroupID1, TeamFilter; if (checkHavePermission(cuUserId, "ADMIN", "Process Worker")) { try { UserId = item.UserId; Department = item.Department; DateFrom = item.DateFrom; DateTo = item.DateTo; Remark = item.Remark; UserId1 = item.UserId1; UserId2 = item.UserId2; Team = item.Team; Score = item.Score; Rule = item.Rule; Nature = item.Nature; Priority = item.Priority; WorkerRuleId = item.WorkerRuleId; WorkerSettingId = this.TryParseNullable(item.WorkerSettingId.ToString()); Grade1 = this.TryParseNullable(item.Grade1.ToString()); Grade2 = this.TryParseNullable(item.Grade2.ToString()); Grade3 = this.TryParseNullable(item.Grade3.ToString()); Grade4 = this.TryParseNullable(item.Grade4.ToString()); LevelNo = this.TryParseNullable(item.LevelNo.ToString()); GroupID = this.TryParseNullable(item.GroupID.ToString()); GroupID1 = this.TryParseNullable(item.GroupID1.ToString()); TeamFilter = this.TryParseNullable(item.TeamFilter.ToString()); SqlParameter[] sqlp = { new SqlParameter("CurUserId", cuUserId), new SqlParameter("WorkerRuleId", WorkerRuleId), new SqlParameter("WorkerRuleSettingID", DBNull.Value), new SqlParameter("Rule", Rule), new SqlParameter("Nature", Nature), new SqlParameter("Score", Score), new SqlParameter("UserId", DBNull.Value), new SqlParameter("LevelNo", DBNull.Value), new SqlParameter("GroupID", DBNull.Value), new SqlParameter("GroupID1", DBNull.Value), new SqlParameter("Team", DBNull.Value), new SqlParameter("TeamFilter", DBNull.Value), new SqlParameter("Grade1", DBNull.Value), new SqlParameter("Grade2", DBNull.Value), new SqlParameter("Priority", Priority), new SqlParameter("Grade3", DBNull.Value), new SqlParameter("Grade4", DBNull.Value), new SqlParameter("Department", DBNull.Value), new SqlParameter("DateFrom", DBNull.Value), new SqlParameter("DateTo", DBNull.Value), new SqlParameter("Criteria", DBNull.Value), new SqlParameter("Remark", Remark), new SqlParameter("UserId1", DBNull.Value), new SqlParameter("UserId2", DBNull.Value) }; if (WorkerSettingId.GetValueOrDefault(0) != 0) { sqlp[2].Value = WorkerSettingId; } if (!string.IsNullOrEmpty(UserId)) { sqlp[6].Value = UserId; } if (LevelNo.GetValueOrDefault(0) != 0) { sqlp[7].Value = LevelNo; } if (GroupID.GetValueOrDefault(0) != 0) { sqlp[8].Value = GroupID; } if (GroupID1.GetValueOrDefault(0) != 0) { sqlp[9].Value = GroupID1; } if (!string.IsNullOrEmpty(Team)) { sqlp[10].Value = Team; } if (TeamFilter.GetValueOrDefault(0) != 0) { sqlp[11].Value = TeamFilter; } if (Grade1.GetValueOrDefault(0) != 0) { sqlp[12].Value = Grade1; } if (Grade2.GetValueOrDefault(0) != 0) { sqlp[13].Value = Grade2; } if (Grade3.GetValueOrDefault(0) != 0) { sqlp[15].Value = Grade3; } if (Grade4.GetValueOrDefault(0) != 0) { sqlp[16].Value = Grade4; } if (!string.IsNullOrEmpty(Department)) { sqlp[17].Value = Department; } if (!string.IsNullOrEmpty(DateFrom)) { sqlp[18].Value = DateFrom; } if (!string.IsNullOrEmpty(DateTo)) { sqlp[19].Value = DateTo; } if (!string.IsNullOrEmpty(item.Criteria.ToString())) { string criteria = ""; foreach (var i in item.Criteria) { if (!string.IsNullOrEmpty(criteria)) { criteria += ';'; } criteria += i; } sqlp[20].Value = criteria; } if (!string.IsNullOrEmpty(UserId1)) { sqlp[22].Value = UserId1; } if (!string.IsNullOrEmpty(UserId2)) { sqlp[23].Value = UserId2; } var WorkerRuleSettingID = Db.Database.SqlQuery <int>("exec [K2_WorkerSaveWorkerRule_Rule] @CurUserId,@WorkerRuleId,@WorkerRuleSettingID,@Rule,@Nature,@Score,@UserId,@LevelNo,@GroupID,@GroupID1,@Team,@TeamFilter,@Grade1,@Grade2,@Priority,@Grade3,@Grade4,@Department,@DateFrom,@DateTo,@Criteria,@Remark,@UserId1,@UserId2", sqlp).FirstOrDefault(); success = true; msg = WorkerRuleSettingID.ToString(); } catch (Exception ex) { throw ex; } return(Tuple.Create(success, msg)); } else { throw new UnauthorizedAccessException(); } }
protected Tuple <byte[], string> generateExcel(dynamic stuff) { try { using (var reportViewer = new ReportViewer()) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; string RuleCode, UserId1, UserId2, Team, Department, DateFrom, DateTo, Criteria; int Rule, Score, Priority; int? LevelNo, GroupID, GroupID1, Grade1, Grade2, TeamFilter, Grade3, Grade4; RuleCode = stuff.RuleCode; Rule = stuff.Rule; Score = stuff.Score; UserId1 = stuff.UserId1; UserId2 = stuff.UserId2; Team = stuff.Team; Department = stuff.Department; DateFrom = stuff.DateFrom; DateTo = stuff.DateTo; Priority = stuff.Priority; Grade1 = this.TryParseNullable(stuff.Grade1.ToString()); Grade2 = this.TryParseNullable(stuff.Grade2.ToString()); Grade3 = this.TryParseNullable(stuff.Grade3.ToString()); Grade4 = this.TryParseNullable(stuff.Grade4.ToString()); LevelNo = this.TryParseNullable(stuff.LevelNo.ToString()); GroupID = this.TryParseNullable(stuff.GroupID.ToString()); GroupID1 = this.TryParseNullable(stuff.GroupID1.ToString()); TeamFilter = this.TryParseNullable(stuff.TeamFilter.ToString()); Criteria = ""; if (!string.IsNullOrEmpty(stuff.Criteria.ToString())) { foreach (var i in stuff.Criteria) { if (!string.IsNullOrEmpty(Criteria)) { Criteria += ';'; } Criteria += i; } if (!string.IsNullOrEmpty(Criteria)) { Criteria += ";"; } } reportViewer.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings.Get("SSRSLoginUser").ToString(), ConfigurationManager.AppSettings.Get("SSRSLoginPassword").ToString()); reportViewer.ServerReport.ReportServerCredentials = irsc; reportViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings.Get("SSRSPath").ToString()); reportViewer.ServerReport.ReportPath = ConfigurationManager.AppSettings.Get("SSTSFolderPath").ToString(); reportViewer.ServerReport.SetParameters(new ReportParameter("RuleCode", RuleCode)); reportViewer.ServerReport.SetParameters(new ReportParameter("Template", Rule.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("Score", Score.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("UserEmployeeID", UserId2)); reportViewer.ServerReport.SetParameters(new ReportParameter("UserMinGradeLevel", Grade3.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("UserMaxGradeLevel", Grade4.ToString())); if (GroupID1.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("UserGroupID", GroupID1.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("UserDepartment", Department)); reportViewer.ServerReport.SetParameters(new ReportParameter("UserTeam", Team)); if (TeamFilter.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("UserTeamFilter", TeamFilter.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("isDefault", Priority.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerEmployeeID", UserId1)); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerMinGradeLevel", Grade1.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerMaxGradeLevel", Grade2.ToString())); if (GroupID.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerGroupID", GroupID.ToString())); } if (LevelNo.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerOrgChartLevel", LevelNo.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("OtherCriteria", Criteria)); if (!string.IsNullOrEmpty(DateFrom)) { reportViewer.ServerReport.SetParameters(new ReportParameter("StartDate", DateFrom + " 00:00:00")); } if (!string.IsNullOrEmpty(DateTo)) { reportViewer.ServerReport.SetParameters(new ReportParameter("EndDate", DateTo + " 00:00:00")); } byte[] resultByte = reportViewer.ServerReport.Render("Excel", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //string saveExcel = ConfigurationManager.AppSettings.Get("SSRSSaveExcel").ToString(); //if (saveExcel == "1") //{ // using (FileStream fs = new FileStream(@ConfigurationManager.AppSettings.Get("SSRSSavePath").ToString() + fileName, FileMode.Create)) // { // fs.Write(resultByte, 0, resultByte.Length); // } //} return(Tuple.Create(resultByte, fileName)); } } catch (Exception ex) { throw ex; } }