예제 #1
0
 private void ConfigureDataBase(string serverName, string userId, string password, string ApplicationPath)
 {
     try
     {
         SClass ClassS = new SClass();
         if (ClassS.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
         {
             ClassS.UpdateAppConfig("MsSqlServer", serverName);
             ClassS.UpdateAppConfig("MsSqlUserId", userId);
             ClassS.UpdateAppConfig("MsSqlPassword", password);
             ClassS.UpdateAppConfig("ApplicationPath", ApplicationPath);
             serverName      = ((ConfigurationManager.AppSettings["MsSqlServer"] == null || ConfigurationManager.AppSettings["MsSqlServer"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlServer"].ToString());
             userId          = ((ConfigurationManager.AppSettings["MsSqlUserId"] == null || ConfigurationManager.AppSettings["MsSqlUserId"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlUserId"].ToString());
             password        = ((ConfigurationManager.AppSettings["MsSqlPassword"] == null || ConfigurationManager.AppSettings["MsSqlPassword"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlPassword"].ToString());
             ApplicationPath = ((ConfigurationManager.AppSettings["ApplicationPath"] == null || ConfigurationManager.AppSettings["ApplicationPath"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["ApplicationPath"].ToString());
             if (ClassS.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
             {
                 Environment.ExitCode = 100;
                 base.Close();
             }
             else
             {
                 Environment.ExitCode = 101;
                 base.Close();
             }
         }
     }
     catch (Exception)
     {
     }
 }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SClass sClass = db.SClasses.Find(id);

            db.SClasses.Remove(sClass);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public void Delete(int id)
        {
            SClass sc = GetSClass(id);

            if (sc != null)
            {
                cont.SClassSet.Remove(sc);
                cont.SaveChanges();
            }
        }
예제 #4
0
        public SClass Add(short num, string let)
        {
            SClass sc = new SClass();

            sc.Number = num;
            sc.Letter = let;
            cont.SClassSet.Add(sc);
            cont.SaveChanges();
            return(sc);
        }
예제 #5
0
		} /*btnGiveFeedBack_Click*/

		public void tsLoad_Mousedown(object sender, MouseEventArgs e) {
			ToolStripItem ts = sender as ToolStripMenuItem;
			if (e.Button == MouseButtons.Right) {
				if (ts != null) SgList.remove((int)ts.Tag);
				SClass.serializeSavedGames(this);
			} else {
				if (ts != null) Mastermind = SgList.load((int)ts.Tag, this);
				CtrlController.removeAllControls();
				CtrlController.drawFrm();
			}
		} /*tsLoad_Mousedown*/
예제 #6
0
        public Student Add(string name, Indiv_plan iplan, SClass sc)
        {
            Student st = new Student();

            st.Name       = name;
            st.Indiv_plan = iplan;
            st.SClass     = sc;
            cont.StudentSet.Add(st);
            cont.SaveChanges();
            return(st);
        }
예제 #7
0
 public ActionResult Edit([Bind(Include = "SClassID,Name,TeacherID")] SClass sClass)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sClass).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SClassID = new SelectList(db.Teachers, "TeacherID", "Name", sClass.SClassID);
     return(View(sClass));
 }
예제 #8
0
        public void Edit(int id, short num, string let)
        {
            SClass sc = GetSClass(id);

            if (sc != null)
            {
                sc.Number = num;
                sc.Letter = let;
                cont.SaveChanges();
            }
        }
예제 #9
0
        public void Edit(int id, string name, int classID, Indiv_plan iplan, SClass sc)
        {
            Student st = GetStudent(id);

            if (st != null)
            {
                st.Name       = name;
                st.Indiv_plan = iplan;
                st.SClass     = sc;
                cont.SaveChanges();
            }
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "SClassID,Name,TeacherID")] SClass sClass)
        {
            if (ModelState.IsValid)
            {
                db.SClasses.Add(sClass);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SClassID = new SelectList(db.Teachers, "TeacherID", "Name", sClass.SClassID);
            return(View(sClass));
        }
        public Lesson Add(short num, Schedule sch, SClass sc, Subject sub)
        {
            Lesson ls = new Lesson();

            ls.Number   = num;
            ls.Schedule = sch;
            ls.SClass   = sc;
            ls.Subject  = sub;
            cont.LessonSet.Add(ls);
            cont.SaveChanges();
            return(ls);
        }
        public void Edit(int id, short num, Schedule sch, SClass sc, Subject sub)
        {
            Lesson ls = GetLesson(id);

            if (ls != null)
            {
                ls.Number   = num;
                ls.Schedule = sch;
                ls.SClass   = sc;
                ls.Subject  = sub;
                cont.SaveChanges();
            }
        }
예제 #13
0
        // GET: SClasses/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SClass sClass = db.SClasses.Find(id);

            if (sClass == null)
            {
                return(HttpNotFound());
            }
            return(View(sClass));
        }
예제 #14
0
        // GET: SClasses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SClass sClass = db.SClasses.Find(id);

            if (sClass == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SClassID = new SelectList(db.Teachers, "TeacherID", "Name", sClass.SClassID);
            return(View(sClass));
        }
예제 #15
0
        private bool CheckDataBase()
        {
            bool   isTrue          = false;
            string serverName      = (ConfigurationManager.AppSettings["MsSqlServer"] == null || ConfigurationManager.AppSettings["MsSqlServer"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlServer"].ToString();
            string userId          = (ConfigurationManager.AppSettings["MsSqlUserId"] == null || ConfigurationManager.AppSettings["MsSqlUserId"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlUserId"].ToString();
            string password        = (ConfigurationManager.AppSettings["MsSqlPassword"] == null || ConfigurationManager.AppSettings["MsSqlPassword"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlPassword"].ToString();
            string ApplicationPath = (ConfigurationManager.AppSettings["ApplicationPath"] == null || ConfigurationManager.AppSettings["ApplicationPath"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["ApplicationPath"].ToString();
            string isSqlServer     = (ConfigurationManager.AppSettings["isServerConnection"] == null || ConfigurationManager.AppSettings["isServerConnection"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["isServerConnection"].ToString();
            SClass objDb           = new SClass();

            if (objDb.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
            {
                return(true);
            }
            return(false);
        }
예제 #16
0
        private void btnOkServer_Click(object sender, EventArgs e)
        {
            string server   = cmbServers1.Text + "\\" + cmbInstance1.Text;
            string userId   = textBox1.Text;
            string password = textBox2.Text;

            progressBar1.Visible = true;
            panel2.Enabled       = false;
            Thread backgroundThread = new Thread((ThreadStart) delegate
            {
                SClass sClass = new SClass();
                if (!radioButton3.Checked)
                {
                    cmbPath.DataSource = sClass.GetOmPath(server, null, null);
                }
                else
                {
                    cmbPath.DataSource = sClass.GetOmPath(server, userId, password);
                }
                if (cmbPath.InvokeRequired)
                {
                    cmbPath.BeginInvoke((Action) delegate
                    {
                        cmbPath.DisplayMember = "location";
                    });
                }
                try
                {
                    progressBar1.BeginInvoke((Action) delegate
                    {
                        progressBar1.Visible = false;
                    });
                    panel2.BeginInvoke((Action) delegate
                    {
                        panel2.Enabled = true;
                    });
                }
                catch (Exception)
                {
                }
            });

            backgroundThread.Start();
        }
예제 #17
0
        public PlanElem Add(short mo, short tu, short we, short th, short fr, short sa,
                            Subject sub, string type, Indiv_plan ip, SClass sc)
        {
            PlanElem pl = new PlanElem();

            pl.Mo         = mo;
            pl.Tu         = tu;
            pl.We         = we;
            pl.Th         = th;
            pl.Fr         = fr;
            pl.Sa         = sa;
            pl.Subject    = sub;
            pl.Type       = type;
            pl.Indiv_plan = ip;
            pl.SClass     = sc;
            cont.PlanElemSet.Add(pl);
            cont.SaveChanges();
            return(pl);
        }
예제 #18
0
        //Adding
        public UObjectViewModel(UObject elem, FormType type, string elemName)
        {
            db     = new UniversityContext();
            Type   = type;
            Parent = elem;

            Type objectType = Assembly.GetExecutingAssembly().GetType($"UniversityDB.Models.{elemName}");

            Current          = (UObject)Activator.CreateInstance(objectType);
            Current.Parent   = elem;
            Current.ParentId = elem.Id;
            SClass classInfo = db.Classes.Where(c => c.Name == elemName).SingleOrDefault();

            Current.Class   = classInfo;
            Current.ClassId = classInfo.Id;
            IsReadOnly      = (Type == FormType.View) ? true : false;

            SaveCommand   = new Command(Save);
            CancelCommand = new Command(Cancel);
        }
예제 #19
0
        public void Edit(int id, short mo, short tu, short we, short th, short fr, short sa,
                         Subject sub, string type, Indiv_plan ip, SClass sc)
        {
            PlanElem pl = GetPlanElem(id);

            if (pl != null)
            {
                pl.Mo         = mo;
                pl.Tu         = tu;
                pl.We         = we;
                pl.Th         = th;
                pl.Fr         = fr;
                pl.Sa         = sa;
                pl.Subject    = sub;
                pl.Type       = type;
                pl.Indiv_plan = ip;
                pl.SClass     = sc;
                cont.SaveChanges();
            }
        }
예제 #20
0
        //public string GetBBS(OleDbConnection objConn, int ID, int UID)
        //{
        //    bool flag;
        //    StringBuilder builder;
        //    int num;
        //    goto Label_003B;
        //Label_0002:
        //    switch (num)
        //    {
        //        case 0:
        //            if (flag)
        //            {
        //                goto Label_0363;
        //            }
        //            num = 4;
        //            goto Label_0002;

        //        case 1:
        //        case 10:
        //            goto Label_01D6;

        //        case 2:
        //            goto Label_01A9;

        //        case 3:
        //            //builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_Speak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //            num = 10;
        //            goto Label_0002;

        //        case 4:
        //            return "";

        //        case 5:
        //            if ((1 == 0) || (0 == 0))
        //            {
        //                goto Label_01D6;
        //            }
        //            goto Label_0363;

        //        case 6:
        //            return builder.ToString();

        //        case 7:
        //            //if (reader.Read())
        //            //{
        //            //    num = 11;
        //            //}
        //            //else
        //            //{
        //                num = 6;
        //            //}
        //            goto Label_0002;

        //        case 8:
        //            flag = true;
        //            builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_Speak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //            num = 2;
        //            goto Label_0002;

        //        case 9:
        //            //if (!reader.Read())
        //            //{
        //            //    goto Label_01A9;
        //            //}
        //            num = 8;
        //            goto Label_0002;

        //        case 11:
        //            //if (!(reader["IsAdminRe"].ToString() == "False"))
        //            //{
        //                builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_AdminSpeak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //                num = 5;
        //            //}
        //            //else
        //            //{
        //            //    num = 3;
        //            //}
        //            goto Label_0002;
        //    }
        //Label_003B:
        //    flag = false;
        //    builder = new StringBuilder();
        //    //OleDbCommand command = new OleDbCommand("SELECT TOP 1 B.*,U.UserName FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE B.ID=" + ID.ToString() + " AND B.UID=" + UID.ToString() + " AND ReID=0", objConn);
        //    //reader = command.ExecuteReader();
        //    num = 9;
        //    goto Label_0002;
        //Label_01A9:
        //    //reader.Close();
        //    num = 0;
        //    goto Label_0002;
        //Label_01D6:
        //    num = 7;
        //    goto Label_0002;
        //Label_0363:
        //    //command.CommandText = "SELECT  B.*,U.UserName FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE  ReID=" + ID.ToString();
        //    //reader = command.ExecuteReader();
        //    num = 1;
        //    goto Label_0002;
        //}

        //public string GetBBSForManage(OleDbConnection objConn, int ID)
        //{
        //    bool flag;
        //    StringBuilder builder;
        //    OleDbDataReader reader;
        //    int num;
        //    goto Label_003B;
        //Label_0002:
        //    switch (num)
        //    {
        //        case 0:
        //        case 7:
        //        case 8:
        //            num = 3;
        //            goto Label_0002;

        //        case 1:
        //            //reader.Close();
        //            return builder.ToString();

        //        case 2:
        //            builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_Speak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //            num = 7;
        //            goto Label_0002;

        //        case 3:
        //            if (reader.Read())
        //            {
        //                num = 4;
        //            }
        //            else
        //            {
        //                num = 1;
        //            }
        //            goto Label_0002;

        //        case 4:
        //            if (!(reader["IsAdminRe"].ToString() == "False"))
        //            {
        //                builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_AdminSpeak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //                num = 8;
        //            }
        //            else
        //            {
        //                num = 2;
        //            }
        //            goto Label_0002;

        //        case 5:
        //            if (flag)
        //            {
        //                //OleDbCommand command=new OleDbCommand(); //new了一个新的实例
        //                //command.CommandText = "SELECT  B.*,U.UserName FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE  ReID=" + ID.ToString();
        //                //reader = command.ExecuteReader();
        //                num = 0;
        //            }
        //            else
        //            {
        //                num = 11;
        //            }
        //            goto Label_0002;

        //        case 6:
        //            if (!reader.Read())
        //            {
        //                goto Label_017C;
        //            }
        //            num = 10;
        //            goto Label_0002;

        //        case 9:
        //            goto Label_017C;

        //        case 10:
        //            if ((1 != 0) && (0 != 0))
        //            {
        //            }
        //            flag = true;
        //            builder.Append(string.Concat(new object[] { "<div class=BBS_Box><span class=BBS_Speak style='float:left'></span><span class=BBS_User>", reader["UserName"], ":</span><span class=BBS_Title>", reader["Caption"].ToString(), "</span><span class=BBS_Date>[", reader["SubmitDate"], "]</span><div class=BBS_Content>", reader["Content"].ToString().Replace("\r\n", "<br />"), "</div></div>" }));
        //            num = 9;
        //            goto Label_0002;

        //        case 11:
        //            return "";
        //    }
        //Label_003B:
        //    flag = false;
        //    builder = new StringBuilder();
        //    //reader = new OleDbCommand("SELECT TOP 1 B.*,U.UserName FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE B.ID=" + ID.ToString() + "  AND ReID=0", objConn).ExecuteReader();
        //    num = 6;
        //    goto Label_0002;
        //Label_017C:
        //    reader.Close();
        //    num = 5;
        //    goto Label_0002;
        //}

        //public string[] getBBSInfo(int ID)
        //{
        //    //OleDbDataReader reader = null; //赋初值
        //Label_0027:;
        //    string[] strArray = new string[] { "", "", "", "", "", "", "" };
        //    int num = 1;
        //Label_0002:
        //    switch (num)
        //    {
        //        case 0:
        //        case 5:
        //            //reader = this.b.ExecuteReader();
        //            num = 4;
        //            goto Label_0002;

        //        case 1:
        //            if (ID <= 0)
        //            {
        //                //this.b.CommandText = "SELECT TOP 1 Caption,Content,UserName,SubmitDate,ReDate,Status,ReID FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE ReID=0 ORDER BY ID DESC";

        //                num = 5;
        //            }
        //            else
        //            {
        //                num = 6;
        //            }
        //            goto Label_0002;

        //        case 2:
        //            //strArray[0] = reader["Caption"].ToString();
        //            //strArray[1] = reader["Content"].ToString();
        //            //strArray[2] = reader["UserName"].ToString();
        //            //strArray[3] = reader["SubmitDate"].ToString();
        //            //strArray[4] = reader["ReDate"].ToString();
        //            //strArray[5] = reader["Status"].ToString();
        //            //strArray[6] = reader["ReID"].ToString();
        //            num = 3;
        //            goto Label_0002;

        //        case 3:
        //            break;

        //        case 4:
        //            //if (!reader.Read())
        //            //{
        //                break;
        //            //}
        //            num = 2;
        //            goto Label_0002;

        //        case 6:
        //            //this.b.CommandText = "SELECT TOP 1 Caption,Content,UserName,SubmitDate,ReDate,Status,ReID FROM BBS B INNER JOIN [User] U ON B.UID=U.UID WHERE ID=" + ID.ToString();
        //            num = 0;
        //            goto Label_0002;

        //        default:
        //            goto Label_0027;
        //    }
        //    //reader.Close();
        //    return strArray;
        //}

        public string[] getEmailAccount()
        {
Label_0017:
            if ((1 != 0) && (0 != 0))
            {
            }
            string[] strArray = new string[] { "" };
            //this.b.CommandText = "SELECT TOP 1 Par FROM OQSSSysInfo WHERE ParName='Email'";
            SqlDataReader reader = new SClass().GetParBySysBaseInfo("Email");
            int           num    = 0;

Label_0002:
            switch (num)
            {
            case 0:
                if (!reader.Read())
                {
                    break;
                }
                num = 2;
                goto Label_0002;

            case 1:
                break;

            case 2:
                strArray = Regex.Split(reader["Par"].ToString(), @"{\$\$}", RegexOptions.IgnoreCase);
                num      = 1;
                goto Label_0002;

            default:
                goto Label_0017;
            }
            reader.Close();
            return(strArray);
        }
예제 #21
0
        /// <summary>
        /// 下載學期排課資料
        /// </summary>
        /// <param name="Connections"></param>
        /// <param name="SchoolYear"></param>
        /// <param name="Semester"></param>
        /// <param name="Progress"></param>
        /// <returns></returns>
        public bool Download(List<Connection> Connections, string SchoolYear, string Semester,Action<int> Progress)
        {
            this.IsSuccess = true;
            this.SchoolYear = SchoolYear;
            this.Semester = Semester;

            try
            {
                if (Progress!=null)
                    Progress(0);

                SIntegrationResult<SClass> CourseSectionClassResult = SClass.Select(Connections, SchoolYear, Semester);

                ClassResult = SClass.Select(Connections);

                IsSuccess &= ClassResult.IsSuccess;

                //取得排課專屬的班級名稱
                List<string> ClassNames = ClassResult.Data
                    .Select(x => x.ClassName)
                    .ToList();

                #region 因為排課課程分課是取得獨立課程的名稱,所以需將ID做轉換。
                Dictionary<string,string> ClassNameIDMaps = new Dictionary<string,string>();

                foreach(SClass Class in ClassResult.Data)
                {
                    string[] ClassIDs = Class.ID.Split(new char[]{','});

                    string DSNS = ClassIDs[0];
                    string ClassName = DSNS+","+Class.ClassName;

                    if (!ClassNameIDMaps.ContainsKey(ClassName))
                        ClassNameIDMaps.Add(ClassName,Class.ID);
                }
                #endregion

                //若課程分段的班級資料,沒有在排課專屬的班級資料中,就加入
                foreach (SClass Class in CourseSectionClassResult.Data)
                {
                    if (!ClassNames.Contains(Class.ClassName))
                    {
                        string[] ClassIDs = Class.ID.Split(new char[] { ',' });

                        if (ClassIDs.Length >= 1)
                        {
                            string DSNS = ClassIDs[0];
                            SClass ExtraClass = new SClass();
                            ExtraClass.ClassName = Class.ClassName;

                            ExtraClass.ID = DSNS +","+ Class.ClassName;
                            ExtraClass.GradeYear = string.Empty;
                            ExtraClass.NamingRule = string.Empty;
                            ExtraClass.TeacherName = string.Empty;
                            ExtraClass.TimeTableID = string.Empty;

                            ClassResult.Data.Add(ExtraClass);
                        }
                    }
                }

                ClassBusysResult = SClassBusy.Select(Connections);
                IsSuccess &= ClassBusysResult.IsSuccess;

                if (Progress != null)
                    Progress(10);

                #region 取得教師資料,留意做特殊處理。
                //取得課程分段的教師資料
                SIntegrationResult<STeacher> CourseSectionTeacherResult = STeacher.SelectByCourseSection(Connections,SchoolYear,Semester);

                //取得排課專屬的教師資料
                TeacherResult = STeacher.Select(Connections, "_.GetTeacherEx");

                //取得排課專屬的教師名稱
                List<string> TeacherNames = TeacherResult.Data
                    .Select(x => x.Name)
                    .ToList();

                //若課程分段的教師資料,沒有在排課專屬的教師資料中,就加入
                foreach (STeacher Teacher in CourseSectionTeacherResult.Data)
                {
                    if (!TeacherNames.Contains(Teacher.Name))
                    {
                        TeacherResult.Data.Add(Teacher);
                    }
                }

                IsSuccess &= TeacherResult.IsSuccess && CourseSectionTeacherResult.IsSuccess;

                FullTeacherResult = STeacher.Select(Connections, "_.GetTeacher");

                IsSuccess &= FullTeacherResult.IsSuccess;
                #endregion

                if (Progress != null)
                    Progress(20);

                TeacherBusysResult = STeacherBusy.Select(Connections);
                IsSuccess &= TeacherBusysResult.IsSuccess;

                if (Progress != null)
                    Progress(30);

                ClassroomResult = SClassroom.Select(Connections);
                IsSuccess &= ClassroomResult.IsSuccess;

                if (Progress != null)
                    Progress(40);

                ClassroomBusysResult = SClassroomBusy.Select(Connections);
                IsSuccess &= ClassroomBusysResult.IsSuccess;

                if (Progress != null)
                    Progress(50);

                LocationResult = SLocation.Select(Connections);
                IsSuccess &= LocationResult.IsSuccess;

                if (Progress != null)
                    Progress(60);

                TimeTableResult = STimeTable.Select(Connections);
                IsSuccess &= TimeTableResult.IsSuccess;

                if (Progress != null)
                    Progress(70);

                TimeTableSecsResult = STimeTableSec.Select(Connections);
                IsSuccess &= TimeTableSecsResult.IsSuccess;

                if (Progress != null)
                    Progress(80);

                CourseSectionResult = SCourseSection.Select(Connections, SchoolYear, Semester);

                #region 取得課程分段後做ID轉換,嘗試對應到獨立的班級清單。
                foreach (SCourseSection Section in CourseSectionResult.Data)
                {
                    if (ClassNameIDMaps.ContainsKey(Section.ClassID))
                        Section.ClassID = ClassNameIDMaps[Section.ClassID];
                }
                #endregion

                IsSuccess &= CourseSectionResult.IsSuccess;

                if (Progress != null)
                    Progress(90);
            }
            catch (Exception e)
            {
                IsSuccess = false;
                throw e;
            }

            if (IsSuccess) Subjects = CourseSectionResult.Data.Select(x => x.Subject).Distinct().ToList();

            Progress(100);

            return IsSuccess;
        }
예제 #22
0
        private void SetElement(XElement Element, Action<int> Progress)
        {
            try
            {
                this.SchoolYear = Element.AttributeText("SchoolYear");
                this.Semester = Element.AttributeText("Semester");

                ClassResult = new SIntegrationResult<SClass>();
                ClassResult.Data = new List<SClass>();

                XElement elmClasses = Element.Element("Classes");

                if (elmClasses != null)
                {
                    foreach (XElement SubElement in elmClasses.Elements("Class"))
                    {
                        SClass Class = new SClass();
                        Class.Load(SubElement);
                        ClassResult.Data.Add(Class);
                    }
                }

                ClassBusysResult = new SIntegrationResult<SClassBusy>();
                ClassBusysResult.Data = new List<SClassBusy>();

                XElement elmClassBuys = Element.Element("ClassBusys");

                if (elmClassBuys != null)
                {
                    foreach (XElement SubElement in elmClassBuys.Elements("ClassBusy"))
                    {
                        SClassBusy ClassBusy = new SClassBusy();
                        ClassBusy.Load(SubElement);
                        ClassBusysResult.Data.Add(ClassBusy);
                    }
                }

                Progress.Invoke(10);

                TeacherResult = new SIntegrationResult<STeacher>();
                TeacherResult.Data = new List<STeacher>();

                XElement elmTeachers = Element.Element("Teachers");

                if (elmTeachers != null)
                {
                    foreach (XElement SubElement in elmTeachers.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        TeacherResult.Data.Add(Teacher);
                    }
                }

                FullTeacherResult = new SIntegrationResult<STeacher>();
                FullTeacherResult.Data = new List<STeacher>();

                XElement elmFullTeacher = Element.Element("FullTeachers");

                if (elmFullTeacher != null)
                {
                    foreach (XElement SubElement in elmFullTeacher.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        FullTeacherResult.Data.Add(Teacher);
                    }
                }

                Progress.Invoke(20);

                TeacherBusysResult = new SIntegrationResult<STeacherBusy>();
                TeacherBusysResult.Data = new List<STeacherBusy>();

                XElement elmTeacherBusy = Element.Element("TeacherBusys");

                if (elmTeacherBusy != null)
                {
                    foreach (XElement SubElement in  elmTeacherBusy.Elements("TeacherBusy"))
                    {
                        STeacherBusy TeacherBusy = new STeacherBusy();
                        TeacherBusy.Load(SubElement);
                        TeacherBusysResult.Data.Add(TeacherBusy);
                    }
                }

                Progress.Invoke(30);

                CourseSectionResult = new SIntegrationResult<SCourseSection>();
                CourseSectionResult.Data = new List<SCourseSection>();

                XElement elmCourseSections = Element.Element("CourseSections");

                if (elmCourseSections != null)
                {
                    foreach (XElement SubElement in elmCourseSections.Elements("CourseSection"))
                    {
                        SCourseSection CourseSection = new SCourseSection();
                        CourseSection.Load(SubElement);
                        CourseSectionResult.Data.Add(CourseSection);
                    }
                }

                Progress.Invoke(40);

                ClassroomResult = new SIntegrationResult<SClassroom>();
                ClassroomResult.Data = new List<SClassroom>();

                XElement elmClassrooms = Element.Element("Classrooms");

                if (elmClassrooms!=null)
                {
                    foreach (XElement SubElement in elmClassrooms.Elements("Classroom"))
                    {
                        SClassroom Classroom = new SClassroom();

                        Classroom.Load(SubElement);

                        ClassroomResult.Data.Add(Classroom);
                    }
                }

                Progress.Invoke(50);

                ClassroomBusysResult = new SIntegrationResult<SClassroomBusy>();
                ClassroomBusysResult.Data = new List<SClassroomBusy>();

                XElement elmClassroomBusys = Element.Element("ClassroomBusys");

                if (elmClassroomBusys != null)
                {
                    foreach (XElement SubElement in elmClassroomBusys.Elements("ClassroomBusy"))
                    {
                        SClassroomBusy ClassroomBusy = new SClassroomBusy();
                        ClassroomBusy.Load(SubElement);
                        ClassroomBusysResult.Data.Add(ClassroomBusy);
                    }
                }

                Progress.Invoke(60);

                LocationResult = new SIntegrationResult<SLocation>();
                LocationResult.Data = new List<SLocation>();

                XElement elmLocations = Element.Element("Locations");

                if (elmLocations != null)
                {
                    foreach (XElement SubElement in elmLocations.Elements("Location"))
                    {
                        SLocation Location = new SLocation();

                        Location.Load(SubElement);

                        LocationResult.Data.Add(Location);
                    }
                }

                Progress.Invoke(70);

                TimeTableResult = new SIntegrationResult<STimeTable>();
                TimeTableResult.Data = new List<STimeTable>();

                XElement elmTimeTables = Element.Element("TimeTables");

                if (elmTimeTables != null)
                {
                    foreach (XElement SubElement in elmTimeTables.Elements("TimeTable"))
                    {
                        STimeTable TimeTable = new STimeTable();

                        TimeTable.Load(SubElement);

                        TimeTableResult.Data.Add(TimeTable);
                    }
                }

                Progress.Invoke(80);

                TimeTableSecsResult = new SIntegrationResult<STimeTableSec>();
                TimeTableSecsResult.Data = new List<STimeTableSec>();

                XElement elmTimeTableSecs = Element.Element("TimeTableSecs");

                if (elmTimeTableSecs != null)
                {
                    foreach (XElement SubElement in elmTimeTableSecs.Elements("TimeTableSec"))
                    {
                        STimeTableSec TimeTableSec = new STimeTableSec();

                        TimeTableSec.Load(SubElement);

                        TimeTableSecsResult.Data.Add(TimeTableSec);
                    }
                }

                Progress.Invoke(90);

                Subjects = CourseSectionResult.Data.Select(x => x.Subject).Distinct().ToList();

                Progress.Invoke(100);

                IsSuccess = true;
            }
            catch (Exception e)
            {
                IsSuccess = false;

                throw e;
            }
        }
예제 #23
0
		} /*toolStripNew_Click*/

		private void toolStripSave_Click(object sender, EventArgs e) {
			SgList.add(this);
			SClass.serializeSavedGames(this);
		} /*toolStripSave_Click*/
예제 #24
0
        //public void saveBBS(string sTitle, string sContent, int ReID, int UID, int blnIsAdmintRe, int intStatus)
        //{
        //Label_001F:;
        //    //this.b.CommandText = "INSERT INTO BBS(Caption,Content,ReID,UID,SubmitDate,IsAdminRe,Status) VALUES('" + sTitle + "','" + sContent.Replace("'", "''") + "'," + ReID.ToString() + "," + UID.ToString() + ",'" + DateTime.Now.ToString() + "'," + blnIsAdmintRe.ToString() + "," + intStatus.ToString() + ")";
        //    //this.b.ExecuteNonQuery();
        //    int num = 4;
        //Label_0002:
        //    switch (num)
        //    {
        //        case 0:
        //            num = 3;
        //            goto Label_0002;

        //        case 1:
        //            //this.b.CommandText = " UPDATE BBS SET Status=3,ReDate='" + DateTime.Now.ToString() + "' WHERE ID=" + ReID.ToString();
        //            //this.b.ExecuteNonQuery();
        //            return;

        //        case 2:
        //            break;

        //        case 3:
        //            if ((1 != 0) && (0 != 0))
        //            {
        //            }
        //            if (blnIsAdmintRe != 0)
        //            {
        //                //this.b.CommandText = " UPDATE BBS SET Status=2,ReDate='" + DateTime.Now.ToString() + "' WHERE ID=" + ReID.ToString();
        //                //this.b.ExecuteNonQuery();
        //                num = 2;
        //            }
        //            else
        //            {
        //                num = 1;
        //            }
        //            goto Label_0002;

        //        case 4:
        //            if (ReID <= 0)
        //            {
        //                break;
        //            }
        //            num = 0;
        //            goto Label_0002;

        //        default:
        //            goto Label_001F;
        //    }
        //}

        public string saveStyleToLib(long UID, string sStyleName, string sStyleContent)
        {
            string        str;
            string        str2   = null; //赋初值
            SqlDataReader reader = null; //赋初值

Label_003F:
            str = "";
            int num = 10;

Label_0002:
            switch (num)
            {
            case 0:
                if (sStyleName.Length < 0x33)
                {
                    //str2 = FormsAuthentication.HashPasswordForStoringInConfigFile(sStyleContent, "MD5").ToLower();

                    str2 = new Business.Helper.RequestQueryString().EncryptQueryString(sStyleContent);     //框架加密
                    //this.b.CommandText = "SELECT TOP 1 ID FROM StyleLib WHERE UID=" + UID.ToString() + " AND FingerPrint='" + str2 + "'";
                    reader = new SClass().GetStyleLibByParas(UID.ToString(), str2);

                    num = 2;
                }
                else
                {
                    num = 3;
                }
                goto Label_0002;

            case 1:
                num = 5;
                goto Label_0002;

            case 2:
                if (!reader.Read())
                {
                    //this.b.CommandText = "INSERT INTO StyleLib(UID,StyleName,StyleContent,FingerPrint) VALUES(" + UID.ToString() + ",'" + sStyleName + "','" + sStyleContent.Replace("'", "''") + "','" + str2 + "')";
                    num = 7;
                }
                else
                {
                    num = 4;
                }
                goto Label_0002;

            case 3:
                return("未成功入库:样式名长度大于50");

            case 4:
                //this.b.CommandText = "";
                str = "未成功入库,因为在库中已经有相同样式内容的记录";
                num = 9;
                goto Label_0002;

            case 5:
                if (!(sStyleName == ""))
                {
                    num = 0;
                }
                else
                {
                    num = 11;
                }
                goto Label_0002;

            case 6:
                new SClass().InsertStyleLib(UID.ToString(), sStyleName, sStyleContent.Replace("'", "''"), str2);
                str = "样式入库完成";
                num = 8;
                goto Label_0002;

            case 7:
            case 9:
                reader.Dispose();
                num = 12;
                goto Label_0002;

            case 8:
                return(str);

            case 10:
                if (sStyleContent == "")
                {
                    break;
                }
                num = 1;
                goto Label_0002;

            case 11:
                break;

            case 12:
                //if (!(this.b.CommandText != ""))
                //{
                //    return str;
                //}
                num = 6;
                goto Label_0002;

            default:
                goto Label_003F;
            }
            return("参数为空");
        }
예제 #25
0
        //public void BBS_Update(int BBSID)  //现在不包含bbs
        //{
        //    //this.b.CommandText = "UPDATE BBS SET Status=1 WHERE ID=" + BBSID.ToString() + " AND Status<>2";
        //    //this.b.ExecuteNonQuery();
        //}

        public void fromStyleLibCopy(long ID, long TargetSID, long UID)
        {
            string        str;
            SqlDataReader reader;
            SqlDataReader reader1;
            int           num = 0; //赋初值
            int           num2;

            goto Label_0023;
Label_0002:
            switch (num2)
            {
            case 0:
                return;

            case 1:
                goto Label_00F5;

            case 2:
                if (!reader.Read())
                {
                    goto Label_00F5;
                }
                num2 = 3;
                goto Label_0002;

            case 3:
                str  = reader["StyleContent"].ToString();
                num2 = 1;
                goto Label_0002;

            case 4:
                if (num != 0)
                {
                    return;
                }
                num2 = 5;
                goto Label_0002;

            case 5:
                //this.b.CommandText = "INSERT INTO SurveyExpand (SID,UID,ExpandContent,ExpandType) VALUES(" + TargetSID.ToString() + "," + UID.ToString() + ",'" + str + "',9)";

                reader1 = new SClass().GetTop1DefaultStyleLib();
                if (reader1.Read())
                {
                    str = reader1["StyleContent"].ToString();      //设置默认样式
                }
                new SClass().InsertSurveyExpand(TargetSID.ToString(), UID.ToString(), str, "9");
                num2 = 0;
                goto Label_0002;
            }
Label_0023:
            str = "";
            //this.b.CommandText = "SELECT * FROM StyleLib WHERE ID=" + ID.ToString();
            reader = new SClass().GetAllStyleLib(ID.ToString());
            num2   = 2;
            goto Label_0002;
Label_00F5:
            reader.Dispose();
            //this.b.CommandText = "UPDATE SurveyExpand SET ExpandContent='" + str + "'  WHERE ExpandType=9 AND SID=" + TargetSID.ToString() + " AND UID=" + UID.ToString();
            num  = new SClass().UpdateSurveyExpand(str, "9", TargetSID.ToString(), UID.ToString());
            num2 = 4;
            goto Label_0002;
        }