示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //UserLogIn.UserName = "******";
            SqlConnection conn = new SqlConnection();
            SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);

            if (com != null)
            {
                com.CommandText = "select Title from DocView where Name=@Name";
                com.Parameters.Clear();
                com.Parameters.AddWithValue("Name", UserLogIn.UserName);
                SqlDataReader dr = com.ExecuteReader();
                docHistory.Items.Clear();
                while (dr.Read())
                {
                    string titleName = dr.GetString(0);
                    docHistory.Items.Add(titleName);
                }
                DisposeClose.Disposeclose(dr);
                DisposeClose.Disposeclose(conn);
                YouDaoTranslateTool("a");
            }
            else
            {
                this.Close();
            }
        }
示例#2
0
 private void okBtn_Click(object sender, RoutedEventArgs e)
 {
     if (datePicker.Text != "")
     {
         if (hour.Text == "" || minute.Text == "")
         {
             MessageBox.Show("请选择完整的比赛结束时间");
         }
         else
         {
             int year  = datePicker.SelectedDate.Value.Year;
             int month = datePicker.SelectedDate.Value.Month;
             int day   = datePicker.SelectedDate.Value.Day;
             int h     = int.Parse(hour.Text);
             int m     = int.Parse(minute.Text);
             dt = new DateTime(year, month, day, h, m, 0, 0);
             SqlConnection conn = new SqlConnection();
             SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);
             com.CommandText = "update TimeTable set OverTime=@OverTime where TimeID=1";
             com.Parameters.Clear();
             com.Parameters.AddWithValue("OverTime", dt);
             com.ExecuteNonQuery();
             DisposeClose.Disposeclose(com);
             DisposeClose.Disposeclose(conn);
             isChanged = true;
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("请选择比赛结束日期!");
     }
 }
示例#3
0
        private void LoadTime()
        {
            SqlConnection conn = new SqlConnection();
            SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);

            com.CommandText = "select OverTime from TimeTable  where TimeID=1";
            SqlDataReader dr = com.ExecuteReader();

            dr.Read();
            overtime = (DateTime)dr[0];
            DisposeClose.Disposeclose(dr);
            DisposeClose.Disposeclose(com);
            DisposeClose.Disposeclose(conn);
        }
示例#4
0
        private void treeView_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);

            com.CommandText = "select DocID from DocView where Title=@Title and Name=@Name";
            com.Parameters.Clear();
            com.Parameters.AddWithValue("Title", SaveTitle.TitleName);
            com.Parameters.AddWithValue("Name", UserLogIn.UserName);
            SqlDataReader dr = com.ExecuteReader();

            dr.Read();
            int docID = dr.GetInt32(0);

            DisposeClose.Disposeclose(dr);
            //判断是否为叶子节点
            if (treeView.SelectedNode.Nodes.Count == 0)
            {
                IsEditing.ElementName = treeView.SelectedNode.Name;
                IsEditing.DOCID       = docID;
                if (treeView.SelectedNode.Name == "title")
                {
                    //do nothing
                }
                else if (treeView.SelectedNode.Name == "scontent")
                {
                    com.CommandText = "select Summary from DocTable where DocID=@DocID";
                    com.Parameters.AddWithValue("DocID", docID);
                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr[0].ToString() != "")
                        {
                            chineseTxt.Document = new FlowDocument(new Paragraph(new Run(dr[0].ToString())));
                        }
                        else
                        {
                            chineseTxt.Document.Blocks.Clear();
                        }
                    }
                    else
                    {
                        chineseTxt.Document.Blocks.Clear();
                    }
                }
                else if (treeView.SelectedNode.Name == "keyword")
                {
                    com.CommandText = "select Keyword from DocTable where DocID=@DocID";
                    com.Parameters.AddWithValue("DocID", docID);
                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr[0].ToString() != "")
                        {
                            chineseTxt.Document = new FlowDocument(new Paragraph(new Run(dr[0].ToString())));
                        }
                        else
                        {
                            chineseTxt.Document.Blocks.Clear();
                        }
                    }
                    else
                    {
                        chineseTxt.Document.Blocks.Clear();
                    }
                }
                else if (treeView.SelectedNode.Name == "bibliography")
                {
                    com.CommandText = "select Bibliography from DocTable where DocID=@DocID";
                    com.Parameters.AddWithValue("DocID", docID);
                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr[0].ToString() != "")
                        {
                            chineseTxt.Document = new FlowDocument(new Paragraph(new Run(dr[0].ToString())));
                        }
                        else
                        {
                            chineseTxt.Document.Blocks.Clear();
                        }
                    }
                    else
                    {
                        chineseTxt.Document.Blocks.Clear();
                    }
                }
                else
                {
                    com.CommandText = "select Content from LeafTitleView where DocID=@DocID and LeafTitleNum=@LeafTitleNum";
                    com.Parameters.AddWithValue("DocID", docID);
                    com.Parameters.AddWithValue("LeafTitleNum", treeView.SelectedNode.Name);
                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr[0].ToString() != "")
                        {
                            chineseTxt.Document = new FlowDocument(new Paragraph(new Run(dr[0].ToString())));
                        }
                        else
                        {
                            chineseTxt.Document.Blocks.Clear();
                        }
                    }
                    else
                    {
                        chineseTxt.Document.Blocks.Clear();
                    }
                }
                DisposeClose.Disposeclose(dr);


                if (treeView.SelectedNode.Name == "title")
                {
                    status.Content = "当前编辑区:";
                }
                else
                {
                    status.Content = "当前编辑区:" + treeView.SelectedNode.FullPath;
                }
            }
            else
            {
                status.Content        = "当前编辑区:";
                IsEditing.ElementName = "";
            }
            DisposeClose.Disposeclose(com);
            DisposeClose.Disposeclose(conn);
        }
示例#5
0
        private void LoadTree()
        {
            InitTree();
            SqlConnection conn = new SqlConnection();
            SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);

            com.CommandText = "select DocID  from DocView where Title=@Title and Name=@Name";
            com.Parameters.Clear();
            com.Parameters.AddWithValue("Title", docHistory.Text);
            com.Parameters.AddWithValue("Name", UserLogIn.UserName);
            SqlDataReader dr = com.ExecuteReader();
            int           docID;

            if (dr.Read())
            {
                docID = dr.GetInt32(0);
            }
            else
            {
                docID = -1;
            }
            DisposeClose.Disposeclose(dr);
            SaveTitle.TitleName         = docHistory.Text;
            treeView.Nodes["root"].Text = SaveTitle.TitleName;
            TreeNode tNode = new TreeNode();

            tNode.Name = "title";
            tNode.Text = SaveTitle.TitleName;
            treeView.Nodes["root"].Nodes.Add(tNode);

            TreeNode tNode1 = new TreeNode();

            tNode1.Name = "summary";
            tNode1.Text = "摘要";
            treeView.Nodes["root"].Nodes.Add(tNode1);

            TreeNode tNode2 = new TreeNode();

            tNode2.Name = "scontent";
            tNode2.Text = "摘要内容";
            tNode1.Nodes.Add(tNode2);

            TreeNode tNode3 = new TreeNode();

            tNode3.Name = "keyword";
            tNode3.Text = "关键词";
            tNode1.Nodes.Add(tNode3);

            TreeNode tNode4 = new TreeNode();

            tNode4.Name = "bibliography";
            tNode4.Text = "参考文献";
            treeView.Nodes["root"].Nodes.Add(tNode4);

            SqlDataAdapter da = new SqlDataAdapter(com);

            da.SelectCommand.CommandText = "select TitleNum,TitleName from TitleView where Title=@Title and DocID=@DocID order by TitleNum";
            da.SelectCommand.Parameters.Clear();
            da.SelectCommand.Parameters.AddWithValue("Title", SaveTitle.TitleName);
            da.SelectCommand.Parameters.AddWithValue("DocID", docID);
            DataSet ds = new DataSet();

            da.Fill(ds);

            DataTable dtable = ds.Tables[0];

            int rowNum = dtable.Rows.Count;

            for (int i = 0; i < rowNum; i++)
            {
                string   titlenum   = dtable.Rows[i][0].ToString();
                string   titletxt   = dtable.Rows[i][1].ToString();
                string[] splittitle = titlenum.Split('|');
                if (splittitle.Length == 1)
                {
                    int      num = treeView.Nodes["root"].Nodes.Count;
                    TreeNode tn  = new TreeNode();
                    tn.Name = titlenum;
                    tn.Text = titletxt;
                    treeView.Nodes["root"].Nodes.Insert(num - 1, tn);
                }
                else
                {
                    string[] newsplittile = new string[splittitle.Length - 1];
                    for (int j = 0; j < splittitle.Length - 1; j++)
                    {
                        newsplittile[j] = splittitle[j];
                    }
                    string   newtitlenum = String.Join("|", newsplittile);
                    TreeNode tn          = new TreeNode();
                    tn.Name = titlenum;
                    tn.Text = titletxt;
                    TreeNode ptn = new TreeNode();
                    GetNode(treeView.Nodes, newtitlenum, ref ptn);
                    ptn.Nodes.Add(tn);
                }
            }
            //treeView.Visible = true;
            treeView.ExpandAll();
            DisposeClose.Disposeclose(com);
            DisposeClose.Disposeclose(conn);
            IsEditing.DOCID = docID;
        }
示例#6
0
        private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            SqlCommand    com  = DatabaseClass.ConnectionToCommad(conn, conStr);

            if (com != null)
            {
                SqlDataReader dr;
                TreeViewItem  tvi = (TreeViewItem)treeView.SelectedItem;
                if (tvi.Header.ToString() != "算法" && tvi.Header.ToString() != "算法介绍")
                {
                    if (tvi.Header.ToString() == "Dijkstra")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='Dijkstra'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "Floyd")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='Floyd'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "概率算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='概率算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "灰色预测")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='灰色预测'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "模拟退火算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='模拟退火算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "搜索算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='搜索算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "贪心算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='贪心算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "遗传算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='遗传算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                    else if (tvi.Header.ToString() == "免疫算法")
                    {
                        com.CommandText = "select AIntroduce from AlgorithmTable where AName='免疫算法'";
                        dr = com.ExecuteReader();
                        if (dr.Read())
                        {
                            string content = dr[0].ToString();
                            contentTextBox.Text = content;
                            label.Content       = "当前算法:" + content;
                        }
                        DisposeClose.Disposeclose(dr);
                    }
                }
            }
        }