Пример #1
0
        public DataTable select(Model.Score model)
        {
            int    jiaquan_number, endnumber = 0;
            string result = "";

            if (score.huoqu(model) != null)
            {
                result = score.huoqu(model);

                string[] lines = result.Split(';');
                string[] row;
                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i] == "")
                    {
                        break;
                    }
                    row = lines[i].Split(':');
                    string condition = row[0];
                    string quanzhong = row[1];
                    int    number    = Convert.ToInt32(row[2]);

                    jiaquan_number = cala(quanzhong, number);
                    endnumber     += jiaquan_number;
                }
                model.Endresult = endnumber.ToString();
                if (score.add(model) == true)
                {
                    dt = score.select(model);
                }
            }
            return(dt);
        }
        public override string ParseBack(Model.Score score)
        {
            if (score == null)
            {
                throw new ArgumentNullException("Score cannot be null.");
            }

            StringBuilder sb = new StringBuilder();
            IHasDuration  previousElement = null;

            foreach (Staff staff in score.Staves)
            {
                foreach (var element in staff.Elements.Where(el => el is IHasDuration || el is Barline))
                {
                    if (element is Barline && IncludeBarlines)
                    {
                        sb.Append("| ");
                        continue;
                    }
                    IHasDuration durationElement = element as IHasDuration;
                    if (durationElement == null)
                    {
                        continue;
                    }

                    if (previousElement != null)
                    {
                        int    greaterDuration;
                        int    lesserDuration;
                        string sign;
                        if (previousElement.BaseDuration <= durationElement.BaseDuration)
                        {
                            greaterDuration = (int)durationElement.BaseDuration.Denominator;
                            lesserDuration  = (int)previousElement.BaseDuration.Denominator;
                            sign            = "*";
                        }
                        else
                        {
                            lesserDuration  = (int)durationElement.BaseDuration.Denominator;
                            greaterDuration = (int)previousElement.BaseDuration.Denominator;
                            sign            = "/";
                        }
                        sb.Append(sign);
                        sb.Append(greaterDuration / lesserDuration);
                    }
                    for (int i = 0; i < durationElement.NumberOfDots; i++)
                    {
                        sb.Append(".");
                    }
                    if (element is Rest && MarkRests)
                    {
                        sb.Append("r");
                    }
                    previousElement = durationElement;
                    sb.Append(" ");
                }
            }
            return(sb.ToString().Trim());
        }
 public Model.Score ScoreData(string query)
 {
     using (var statement = new SQLite.SQLiteConnection("GGzDB.db"))
     {
         scoreData = statement.Query <Model.Score>
                         (query).FirstOrDefault();
     }
     return(scoreData);
 }
Пример #4
0
        private void button12_Click(object sender, EventArgs e)
        {
            BLL.Score        score     = new BLL.Score();
            Common.Translate translate = new Common.Translate();
            Model.Score      model     = new Model.Score();
            model.UserName = textBox8.Text;

            this.dataGridView2.DataSource = score.select(model);
        }
Пример #5
0
        private void button11_Click(object sender, EventArgs e)
        {
            BLL.Score        score     = new BLL.Score();
            Common.Translate translate = new Common.Translate();
            Model.Score      model     = new Model.Score();
            model.UserName = textBox8.Text;

            string description = score.chaxun(model);

            this.dataGridView2.DataSource = translate.string2datatable(description);
        }
Пример #6
0
 public ScoreController()
 {
     Model.Score score = new Model.Score
     {
         Competition = "Champions League",
         Team1       = "Real Madrid",
         Team2       = "Liverpool"
     };
     this.scoreColection = new List <Model.Score> {
         score
     };
 }
Пример #7
0
        //private int getCount(int TeacherId, int ClassId)
        //{
        //    SqlConnection co = SQLSeverOpen();
        //    SqlCommand cmd = new SqlCommand();
        //    cmd.Connection = co;
        //    List<Model.Score> list = new List<Model.Score>();
        //    cmd.CommandText = "select COUNT(1) from V_QuestionHead_Select where TeacherId = " + TeacherId + " and ClassId = " + ClassId;

        //    return (int)cmd.ExecuteScalar();
        //}
        public List <Model.Score> GetTeacherClassScore(int TeacherId, int ClassId)
        {
            SqlConnection co  = SQLSeverOpen();
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection = co;
            List <Model.Score> list = new List <Model.Score>();

            cmd.CommandText = "select  top 10 * from V_QuestionHead_Select where TeacherId = " + TeacherId + " and ClassId = " + ClassId;
            SqlDataReader         reader       = cmd.ExecuteReader();
            List <Model.Question> questionList = new List <Model.Question>();

            Model.Score score = new Model.Score();

            while (reader.Read())
            {
                try
                {
                    Model.Teacher  teacher   = new Model.Teacher();
                    Model.Class    tempClass = new Model.Class();
                    Model.Question question  = new Model.Question();
                    score.TeacherId  = Convert.ToInt32(reader["TeacherId"]);
                    score.ClassId    = Convert.ToInt32(reader["ClassId"]);
                    score.TotalScore = Convert.ToInt32(reader["TotalScore"]);
                    score.TeacherId  = Convert.ToInt32(reader["TeacherId"]);
                    List <int> scoreList = GetTotalScore(TeacherId, ClassId);
                    score.QScore     = scoreList;
                    question.Content = Convert.ToString(reader["Content"]);
                    questionList.Add(question);
                    ;
                    tempClass.Id        = Convert.ToInt32(reader["ClassId"]);
                    tempClass.ClassName = Convert.ToString(reader["ClassName"]);
                    teacher.Id          = Convert.ToInt32(reader["TeacherId"]);
                    teacher.TeacherName = Convert.ToString(reader["TeacherName"]);
                    score.Teacher       = teacher;
                    score.Class         = tempClass;

                    score.Question = questionList;
                    list.Add(score);
                }
                catch (Exception)
                {
                    continue;
                }
            }

            reader.Close();
            co.Close();
            return(list);
        }
Пример #8
0
 public bool tianjia(Model.Score model, out string mesg)
 {
     mesg = "";
     if (score.tianjia(model) == true)
     {
         mesg = "添加成功";
         return(true);
     }
     else
     {
         mesg = "添加失败";
         return(false);
     }
 }
Пример #9
0
        public DataTable select(Model.Score model)
        {
            string strSql = "select username as '学生姓名',endresult as '最终成绩' from tb_score where username = @UserName";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@UserName", MySqlDbType.VarChar, 200)
            };

            parameters[0].Value = model.UserName;

            DataTable dt = SqlDbHelper.ExecuteDataTable(strSql, CommandType.Text, parameters);

            return(dt);
        }
Пример #10
0
        public List <Model.Score> GetSchoolTeacherScore(int SchoolId)
        {
            SqlConnection co  = SQLSeverOpen();
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection = co;
            List <Model.Score> list = new List <Model.Score>();

            cmd.CommandText = "select TeacherId,ClassId,ClassName,SUM(TotalScore)as TotalScore" +
                              ",TeacherName from V_Write_Questionnaire_Class_School where SchoolId = " +
                              SchoolId + " group by TeacherId,ClassId,ClassName,TeacherName";
            SqlDataReader      reader   = cmd.ExecuteReader();
            List <Model.Score> tempList = new List <Model.Score>();

            while (reader.Read())
            {
                Model.Score   score     = new Model.Score();
                Model.Teacher teacher   = new Model.Teacher();
                Model.Class   tempClass = new Model.Class();
                score.TeacherId     = Convert.ToInt32(reader["TeacherId"]);
                score.ClassId       = Convert.ToInt32(reader["ClassId"]);
                score.TotalScore    = Convert.ToInt32(reader["TotalScore"]);
                score.TeacherId     = Convert.ToInt32(reader["TeacherId"]);
                tempClass.Id        = Convert.ToInt32(reader["ClassId"]);
                tempClass.ClassName = Convert.ToString(reader["ClassName"]);
                teacher.Id          = Convert.ToInt32(reader["TeacherId"]);
                teacher.TeacherName = Convert.ToString(reader["TeacherName"]);
                score.Teacher       = teacher;
                score.Class         = tempClass;
                tempList.Add(score);
            }
            reader.Close();
            co.Close();
            co             = SQLSeverOpen();
            cmd.Connection = co;
            foreach (Model.Score item in tempList)
            {
                cmd.CommandText = "select COUNT(1) from V_Write_Questionnaire_Class_School where teacherId = " + item.TeacherId;
                int count = (int)cmd.ExecuteScalar();
                item.TotalScore = item.TotalScore / count;
                list.Add(item);
            }

            reader.Close();
            co.Close();
            return(list);
        }
Пример #11
0
        // Not properly tested yet
        public void FindChordsAndFixThem(Model.Score score)
        {
            //    TimeSignature currentTimeSignature = null;
            //    Tempo tempo = null;
            //    int recordedStartTime = 0;
            //    List<Note> chord = new List<Note>();

            //    foreach (Staff staff in score.Staves)
            //    {
            //        for (int index = 0; index < staff.Symbols.Count; index++) // Potentially visitor pattern
            //        {
            //            Model.StaffSymbol symbol = staff.Symbols[index];
            //            if (symbol is Model.Note)
            //            {
            //                var currentNote = symbol as Note; // Visitor pattern instead
            //                if (index > 0 && recordedStartTime == currentNote.StartTime)
            //                {
            //                    if(!chord.Contains(staff.Symbols[index - 1]))
            //                    {
            //                        chord.Add(staff.Symbols[index - 1] as Note);
            //                    }
            //                    chord.Add(currentNote);
            //                }
            //                else if (chord.Count > 2)
            //                {
            //                    FixChordSequence(chord, staff, index, tempo, currentTimeSignature);
            //                    chord.Clear();
            //                }
            //            }
            //            else if (symbol is TimeSignature)
            //            {
            //                currentTimeSignature = symbol as TimeSignature;
            //            }
            //            else if (symbol is Tempo)
            //            {
            //                tempo = symbol as Tempo;
            //            }
            //            else if (chord.Count > 2)
            //            {
            //                FixChordSequence(chord, staff, index, tempo, currentTimeSignature);
            //                chord.Clear();
            //            }
            //        }
            //    }
        }
Пример #12
0
        public string huoqu(Model.Score model)
        {
            string result = "";
            string sql    = "select formula from tb_score where username = @username";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username", MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.UserName;
            MySqlDataReader sdr = SqlDbHelper.ExecuteReader(sql, CommandType.Text, parameters);

            if (sdr.Read())
            {
                result = sdr[0].ToString();
            }
            return(result);
        }
Пример #13
0
        public override int[] ParseBack(Model.Score score)
        {
            List <int> intervals = new List <int>();

            foreach (Staff staff in score.Staves)
            {
                Note lastNote = null;
                foreach (Note note in staff.Elements.OfType <Note>().Where(n => !n.IsUpperMemberOfChord).Select(n => staff.Peek <Note>(n, Model.PeekStrategies.PeekType.HighestNoteInChord)))
                {
                    if (lastNote != null)
                    {
                        intervals.Add(note.MidiPitch - lastNote.MidiPitch);
                    }
                    lastNote = note;
                }
            }
            return(intervals.ToArray());
        }
Пример #14
0
        //查询所有信息
        public string chaxun(Model.Score model)
        {
            string description = "";
            string strSql      = "select formula from tb_score where username = @UserName";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@UserName", MySqlDbType.VarChar, 200)
            };

            parameters[0].Value = model.UserName;

            MySqlDataReader sdr = SqlDbHelper.ExecuteReader(strSql, CommandType.Text, parameters);

            if (sdr.Read())
            {
                description = sdr[0].ToString();
            }
            return(description);
        }
Пример #15
0
        private void button10_Click(object sender, EventArgs e)
        {
            custom_condition = new DataTable("condition");
            custom_condition.Columns.Add("号码", Type.GetType("System.String"));
            custom_condition.Columns.Add("项目", Type.GetType("System.String"));
            custom_condition.Columns.Add("分值", Type.GetType("System.Int32"));
            DataRow newRow;

            for (int i = 0; i < chk.Length; i++)
            {
                if (chk[i].Checked)
                {
                    newRow    = custom_condition.NewRow();
                    newRow[0] = "condition_" + i;
                    newRow[1] = names[i].Text;
                    newRow[2] = Convert.ToInt32(ratios[i].Text);
                    custom_condition.Rows.Add(newRow);
                }
            }
            Common.Translate translate = new Common.Translate();
            this.dataGridView2.DataSource = custom_condition;
            string description = translate.datatable2string(custom_condition);

            textBox7.Text = description;

            BLL.Score   score = new BLL.Score();
            Model.Score model = new Model.Score();
            model.UserName = textBox8.Text;
            model.Formula  = description;
            string mesg = "";

            if (score.tianjia(model, out mesg) == true)
            {
                MessageBox.Show("添加成功!");
            }
            else
            {
                MessageBox.Show(mesg);
            }
        }
Пример #16
0
        public bool tianjia(Model.Score model)
        {
            string sql = "update tb_score set formula=@formula where username=@username";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username", MySqlDbType.VarChar, 50),
                new MySqlParameter("@formula",  MySqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.Formula;
            int n = SqlDbHelper.ExecuteNonQuery(sql, CommandType.Text, parameters);

            if (n > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        public bool add(Model.Score model)
        {
            string sql = "update tb_score set endresult=@endresult where username=@username";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@endresult", MySqlDbType.VarChar, 50),
                new MySqlParameter("@username",  MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Endresult;
            parameters[1].Value = model.UserName;
            int n = SqlDbHelper.ExecuteNonQuery(sql, CommandType.Text, parameters);

            if (n > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #18
0
        public List <Model.Score> GetSchoolScore()
        {
            List <Model.Score> list = new List <Model.Score>();
            SqlConnection      co   = SQLSeverOpen();
            SqlCommand         cmd  = new SqlCommand();

            cmd.Connection  = co;
            cmd.CommandText = "select SchoolId,SchoolName,SUM(TotalScore) as TotalScore from V_Write_Questionnaire_Class_School group by SchoolId,SchoolName,SchoolName";
            SqlDataReader      reader   = cmd.ExecuteReader();
            List <Model.Score> tempList = new List <Model.Score>();

            while (reader.Read())
            {
                Model.Score  score  = new Model.Score();
                Model.School school = new Model.School();
                score.SchoolId    = Convert.ToInt32(reader["SchoolId"]);
                score.TotalScore  = Convert.ToInt32(reader["TotalScore"]);
                school.Id         = Convert.ToInt32(reader["SchoolId"]);
                school.SchoolName = Convert.ToString(reader["SchoolName"]);
                score.School      = school;
                tempList.Add(score);
            }
            reader.Close();
            co.Close();
            co             = SQLSeverOpen();
            cmd.Connection = co;
            foreach (Model.Score item in tempList)
            {
                cmd.CommandText = "select COUNT(1) from V_Write_Questionnaire_Class_School where SchoolId = " + item.SchoolId;
                int count = (int)cmd.ExecuteScalar();
                item.TotalScore = item.TotalScore / count;
                list.Add(item);
            }

            reader.Close();
            co.Close();
            return(list);
        }
        public override string ParseBack(Model.Score score)
        {
            if (score == null)
            {
                throw new ArgumentNullException("Score");
            }

            StringBuilder sb = new StringBuilder();

            foreach (Staff staff in score.Staves)
            {
                foreach (var element in staff.Elements.Where(el => el is IHasDuration || el is Barline))
                {
                    if (element is Barline && IncludeBarlines)
                    {
                        sb.Append("| ");
                        continue;
                    }
                    IHasDuration durationElement = element as IHasDuration;
                    if (durationElement == null)
                    {
                        continue;
                    }
                    sb.Append((int)durationElement.BaseDuration.Denominator);
                    for (int i = 0; i < durationElement.NumberOfDots; i++)
                    {
                        sb.Append(".");
                    }
                    if (element is Rest && MarkRests)
                    {
                        sb.Append("r");
                    }
                    sb.Append(" ");
                }
            }
            return(sb.ToString().Trim());
        }
Пример #20
0
 public string chaxun(Model.Score model)
 {
     return(score.chaxun(model));
 }