Пример #1
0
        public int update(string tablename,Object ObjMember)
        {
            int SuccessFlag;
            switch (tablename)
            {
                case "Logs_Data":
                    record = (EmailRecordInfo)ObjMember;
                    string dtLog = string.Format(@"UPDATE " + tablename + " SET  Email_Receiver='{0}', Teacher_Identity='{1}',Email_Theme='{2}',Time_Now='{3}',Email_Type='{4}', File_State'{5}',Enclosure_Path='{6}' WHERE Time_Now='{7}'"
                   ,record.Email_Receiver,record.Teacher_Identity,record.Email_Receiver,record.Time_Now,record.Email_Type,record.File_State,record.Enclosure_Path,record.Time_Now);
                    SuccessFlag = Oledbcommand(dtLog);
                    return SuccessFlag;

                case "SpareTime_Data":
                    supervisor = (SupervisorInfo)ObjMember;
                    string dtSpareTime = string.Format(@"insert into " + tablename + " values('{0}','{1}','{2}' ,{3},{4},{5},{6})", supervisor.SpareID,
                        supervisor.SupervisorId, supervisor.SupervisorName, supervisor.SpareWeek, supervisor.SpareDay, supervisor.SpareNumber, supervisor.Isassigned);

                    SuccessFlag = Oledbcommand(dtSpareTime);
                    return SuccessFlag;
                case "Teachers_Data":
                    teacher = (TeacherInfo)ObjMember;
                    string dtTeacher = string.Format(@"UPDATE "+tablename+" SET Teacher_ID ='{0}', Teacher ='{1}', Email ='{2}', Phone ='{3}', Title ='{4}', IsSupervisor ={5}, Teaching_Section ='{6}', Accept_ClassNumber ={7}, Class_Totality ={8}, Class_WeekNumber ={9}, Class_DayNumber ={10} WHERE  Teacher ='{11}'"
                        , teacher.TeacherId.ToString(), teacher.TeacherName.ToString(), teacher.Email.ToString(), teacher.Phone.ToString(), teacher.Title.ToString(), teacher.IsSupervisor, teacher.TeachingSection.ToString(),
                        teacher.AcceptClassNumber, teacher.ClassTotality, teacher.ClassWeekNumber, teacher.ClassDayNumber,teacher.TeacherName
                        );

                    SuccessFlag = Oledbcommand(dtTeacher);
                    return SuccessFlag;
                case "Placement_Data":
                    placement = (PlacementInfo)ObjMember;
                    string dtPlacement = string.Format(@"UPDATE " + tablename + " SET Class_ID='{0}',Teacher_ID='{1}',Teacher='{2}',Class_week={3},Class_Day={4},Class_Number={5},Supervisor_Name='{6}',Class_Address='{7}',Class_Content='{8}',Class_Name='{9}',Class_Type='{10}',Spcialty='{11}',Grade={12} WHERE  Class_ID='{13}'"
                   , placement.ClassId, placement.TeacherId, placement.TeacherName, placement.ClassWeek, placement.ClassDay, placement.ClassNumber, placement.SupervisorsName,
                   placement.ClassAddress, placement.ClassContent, placement.ClassName, placement.ClassType, placement.Spcialty, placement.Grade,placement.ClassId
                  );
                    SuccessFlag = Oledbcommand(dtPlacement);
                    return SuccessFlag;

            }
            return 0;
        }
Пример #2
0
        private int Week; //周数

        #endregion Fields

        #region Methods

        public void AutoSelectSpareTime(ProgressBar ProgressBar1)
        {
            List<SupervisorInfo> supervisorname = new List<SupervisorInfo>();//存储督导信息
            List<SupervisorInfo> listsparetime = new List<SupervisorInfo>();//用于存储经过对比课程表后的督导的上课时间
            List<string> ListInsertCommand = new List<string>();
            dtClasses = helper.getDs(strSelect_Class_Data, "Classes_Data").Tables[0];
            dtSupervisor = helper.getDs(strSelect_Teachers_Data, "Teachers_Data").Tables[0];
            dtSupervisor = dtSupervisor.Select("IsSupervisor=True").CopyToDataTable();
            List<DataRow[]> DrClassesArray = new List<DataRow[]>();//一个Datarow数组代表每一周每一天每一节次所有的上课记录
            for (int i = 0; i < dtSupervisor.Rows.Count;i++ )
            {

                SupervisorInfo sp = new SupervisorInfo();
                sp.SupervisorName = dtSupervisor.Rows[i][1].ToString();
                sp.SupervisorId = dtSupervisor.Rows[i][0].ToString();
                supervisorname.Add(sp);

            }
            //分别把每一周每一天每一节的记录分开,存储在DrClassArray数组中
            for (int i = 0; i < supervisorname.Count; i++)
            {
                for (int week = 1; week < 20; week++)
                {
                    for (int day = 1; day < 6; day++)
                    {
                        for (int index = 0; index < spareclass.Count; index++)
                        {
                            DataRow[] dr = dtClasses.Select(" Class_Week=" + week + "and Class_Day=" + day + " and Class_Number=" + spareclass[index] + "and Teacher='" + supervisorname[i].SupervisorName + "'");
                            if (dr.Length==0)
                            {
                                SupervisorInfo info = new SupervisorInfo();
                                info.SupervisorName = supervisorname[i].SupervisorName.ToString();
                                info.Isassigned = false;
                                foreach(SupervisorInfo s in supervisorname)
                                {
                               if (supervisorname[i].SupervisorName.Equals(s.SupervisorName))
                                 {
                                     info.SupervisorId = s.SupervisorId;
                                     info.SpareID = info.SupervisorId + week.ToString() + day.ToString() + spareclass[index].ToString();
                                        break;

                                 }

                                }
                                if (info.SupervisorId==""||info.SpareID=="")
                                {

                                    info.SupervisorId = supervisorname[i].SupervisorName;
                                     info.SpareID = info.SupervisorId + week.ToString() + day.ToString() + spareclass[index].ToString();

                                }
                                info.SpareWeek = week;
                                info.SpareDay = day;
                                info.SpareNumber = spareclass[index];
                                listsparetime.Add(info);
                            }
                            else
                            {
                                int[] array;
                                switch (spareclass[index])
                                {
                                    case 12:
                                        index += 3;
                                        break;
                                    case 13:
                                         array=new int []{12};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 4;
                                        break;
                                    case 23:
                                        array=new int []{12,13};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 3;
                                        break;
                                    case 24:
                                          array=new int []{12,13,23};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 3;
                                        break;
                                    case 34:
                                          array=new int []{13,23,24};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 2;
                                        break;
                                    case 35:
                                          array=new int []{13,24,23,34};
                                        DeleteError(array, week, day, listsparetime);
                                        index +=1;
                                        break;
                                    case 45:
                                          array=new int []{24,34,35};
                                        DeleteError(array, week, day, listsparetime);
                                        break;
                                    case 67:
                                        index += 3;
                                        break;
                                    case 68:
                                         array=new int []{67};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 3;
                                        break;
                                    case 78:
                                        array=new int []{67,68};
                                        DeleteError(array, week, day, listsparetime);
                                        index += 2;
                                        break;
                                    case 79:
                                        array=new int []{67,78,68};
                                        DeleteError(array, week, day, listsparetime);
                                        index +=1;
                                        break;
                                    case 89:
                                         array=new int []{68,79,78};
                                        DeleteError(array, week, day, listsparetime);
                                        break;
                                    case 1011:
                                        index +=2;
                                        break;
                                    case 1112:
                                         array=new int []{1011,1012};
                                        DeleteError(array, week, day, listsparetime);
                                        index +=1;
                                        break;
                                    case 1012:
                                         array=new int []{1011,1112};
                                        DeleteError(array, week, day, listsparetime);
                                        break;

                                }
                            }

                        }
                    }
                }
            }

               List<SupervisorInfo> newsupervisorlist= listsparetime.Distinct<SupervisorInfo>().ToList();

            //编写数据库插入语句
               foreach (SupervisorInfo supervisor in newsupervisorlist)
            {
             string insertcommand = string.Format(@"insert into SpareTime_Data values('{0}','{1}','{2}',{3},{4},{5},{6})", supervisor.SpareID,
                       supervisor.SupervisorId, supervisor.SupervisorName, supervisor.SpareWeek, supervisor.SpareDay, supervisor.SpareNumber, supervisor.Isassigned);
             ListInsertCommand.Add(insertcommand);
            }

            //使用数据库事务条件插入请求
            helper.insertToStockDataByBatch(ListInsertCommand, ProgressBar1);
        }
Пример #3
0
        public int Insert(Object ObjMember,string Flag)
        {
            int SuccessFlag;
            switch (Flag)
            {
                case "Classes_Data":
                    classes = (ClassInfo)ObjMember;
                    string dtClass = string.Format(@"insert into " + Flag +  " values('{0}','{1}','{2}' ,{3},{4},{5},'{6}','{7}','{8}','{9}','{10}')"
                    ,classes.ClassId,classes.TeacherId,classes.TeacherName,classes.ClassWeek,classes.ClassDay,classes.ClassNumber,classes.ClassName,
                    classes.ClassContent,classes.ClassType,classes.Spcialty);
                    SuccessFlag=Oledbcommand(dtClass);
                    return SuccessFlag;

                case "SpareTime_Data":
                    supervisor = (SupervisorInfo)ObjMember;
                    string dtSpareTime = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}',{3},{4},{5},{6})",supervisor.SpareID,
                        supervisor.SupervisorId,supervisor.SupervisorName,supervisor.SpareWeek,supervisor.SpareDay,supervisor.SpareNumber,supervisor.Isassigned);

                    SuccessFlag = Oledbcommand(dtSpareTime);
                    return SuccessFlag;
                case "Teachers_Data":
                    teacher = (TeacherInfo)ObjMember;
                    string dtTeacher = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}' ,'{3}','{4}',{5},'{6}',{7},{8},{9},{10})"
                        ,teacher.TeacherId.ToString(),teacher.TeacherName.ToString(),teacher.Email.ToString(),teacher.Phone.ToString(),teacher.Title.ToString(),teacher.IsSupervisor,teacher.TeachingSection.ToString(),
                        teacher.AcceptClassNumber,teacher.ClassTotality,teacher.ClassWeekNumber,teacher.ClassDayNumber
                        );

                    SuccessFlag = Oledbcommand(dtTeacher);
                    return SuccessFlag;
                case "Placement_Data":
                    placement = (PlacementInfo)ObjMember;
                    string dtPlacement = string.Format(@"insert into " + Flag + " values('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}','{8}','{9}','{10}','{11}',{12})"
                   ,placement.ClassId,placement.TeacherId,placement.TeacherName,placement.ClassWeek,placement.ClassDay,placement.ClassNumber,placement.SupervisorsName,
                   placement.ClassAddress,placement.ClassContent,placement.ClassName,placement.ClassType,placement.Spcialty,placement.Grade
                  );
                    SuccessFlag = Oledbcommand(dtPlacement);
                    return SuccessFlag;
                case "Logs_Data":
                    record = (EmailRecordInfo)ObjMember;
                    string dtLog = string.Format(@"insert into "+Flag+" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",record.Email_Receiver,record.Teacher_Identity,record.Email_Theme
                        ,record.Time_Now,record.Email_Type,record.File_State,record.Enclosure_Path);
                    SuccessFlag = Oledbcommand(dtLog);
                    return SuccessFlag;

            }
            return 0;
        }