//查询数据库获取班级的个数 private void GetClass() { string sql = "select ClassId,ClassName from dbo.Class"; DataSet ForTable = DBHelpSQL.Query(sql); ClassIdArr = new string[ForTable.Tables[0].Rows.Count]; ClassNameArr = new string[ForTable.Tables[0].Rows.Count]; for (int i = 0; i < ForTable.Tables[0].Rows.Count; i++) { ClassIdArr[i] = ForTable.Tables[0].Rows[i]["ClassId"].ToString(); ClassNameArr[i] = ForTable.Tables[0].Rows[i]["ClassName"].ToString(); } }
//存储表单选中的数据 private void getPlanValue() { string name = ""; int count = 0; string Day = ""; int ClassId = 0; int q = 0; string TimeSlot = ""; string[] middleDataArr = new string[93 * ClassIdArr.Length]; for (int k = 1; k <= dateCount; k++) { for (int t = 1; t <= 3; t++) { name = k + "-" + t; middleDataArr[count] = Request.Form[name]; count++; } } //存储之前先把当前月份的记录清除 for (int a = 0; a < middleDataArr.Length; a++) { if (middleDataArr[a] != null) { q++; } } if (q > 0) { string sql = "delete from dbo.PlanTable where Month = '" + newDate.Month.ToString() + "'"; sql = string.Format(sql, newDate.Month.ToString()); DBHelpSQL.ExcuteSQL(sql); } for (int m = 0; m < middleDataArr.Length; m++) { if (middleDataArr[m] != null) { ClassId = int.Parse(middleDataArr[m].Split('-').GetValue(0).ToString()); Day = middleDataArr[m].Split('-').GetValue(1).ToString(); TimeSlot = middleDataArr[m].Split('-').GetValue(2).ToString(); string sql2 = "insert into dbo.PlanTable(ClassId,TimeSlot,Year,Month,Day) values(" + ClassId + "," + TimeSlot + "," + newDate.Year.ToString() + "," + newDate.Month.ToString() + "," + Day + ")"; sql2 = string.Format(sql2, ClassId, TimeSlot, newDate.Year.ToString(), newDate.Month.ToString(), Day); DBHelpSQL.ExcuteSQL(sql2); } } }
//判断是否选中 public Boolean OrNotCho(int Day, string ClassId, string SlotNo) { string TMonth = this.DropDownList1.SelectedValue; string slotTime = ""; string sql = "select TimeSlot from dbo.PlanTable where Year=" + Year + " and Month=" + TMonth + " and Day=" + Day + " and ClassId=" + ClassId; DataSet ForPlanTable = DBHelpSQL.Query(sql); if (ForPlanTable.Tables[0].Rows.Count != 0) { if (ForPlanTable.Tables[0].Rows.Count > 1) { for (int n = 0; n < ForPlanTable.Tables[0].Rows.Count; n++) { slotTime += ForPlanTable.Tables[0].Rows[n]["TimeSlot"].ToString(); if (n < ForPlanTable.Tables[0].Rows.Count - 1) { slotTime += ","; } } } else { slotTime = ForPlanTable.Tables[0].Rows[0]["TimeSlot"].ToString(); } } if (slotTime == "") { return(false); } else { int r = slotTime.IndexOf(SlotNo); if (slotTime.IndexOf(SlotNo) >= 0) { return(true); } else { return(false); } } }