Esempio n. 1
0
        private void treeView2_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Parent == null)
            {
                return;
            }

            string name = e.Node.Text.Trim();
            string ID   = null;

            dt = BookAdmin.GetBook();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][1].ToString() == name)
                {
                    tb4_3.Text = dt.Rows[i][1].ToString();
                    tb4_4.Text = dt.Rows[i][3].ToString();
                    tb4_5.Text = dt.Rows[i][4].ToString();
                    tb4_6.Text = dt.Rows[i][5].ToString();
                    cb4_2.Text = dt.Rows[i][7].ToString();
                    ID         = dt.Rows[i][2].ToString();
                }
            }

            dt = BookTypeAdmin.GetBookType();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][0].ToString() == ID)
                {
                    cb4_1.Text = dt.Rows[i][1].ToString();
                }
            }
        }
Esempio n. 2
0
        private bool SetTextToBookType()
        {
            new_booktype.Name = tb4_1.Text;
            new_booktype.Day  = Convert.ToInt32(tb4_2.Text.Trim());

            if (listBox2.SelectedIndex < 0)
            {
                return(true);
            }

            string name = listBox2.Items[listBox2.SelectedIndex].ToString();

            name = name.Trim();

            dt = BookTypeAdmin.GetBookType();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][1].ToString() == name)
                {
                    new_booktype.ID = Convert.ToInt32(dt.Rows[i][0].ToString());
                }
            }

            return(true);
        }
Esempio n. 3
0
 private void 添加图书类型_4_Click(object sender, EventArgs e)
 {
     if (tb4_1.Text == "" || tb4_2.Text == "")
     {
         MessageBox.Show("请输入完整信息");
         return;
     }
     if (SetTextToBookType())
     {
         dt = BookTypeAdmin.GetBookType();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             if (dt.Rows[i][1].ToString() == new_booktype.Name)
             {
                 MessageBox.Show("该类型已有");
                 return;
             }
         }
         booktypeBLL.Insert(new_booktype);
         MessageBox.Show("状态:添加成功!");
         Clear_44();
     }
     BookTypeUpdate();
     BookCatalogUpdate(treeView2);
 }
Esempio n. 4
0
        private void BookCatalogUpdate(TreeView treeView)
        {
            treeView.Nodes.Clear();

            dt = BookTypeAdmin.GetBookType();
            TreeNode[] tn = new TreeNode[dt.Rows.Count];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tn[i]      = new TreeNode();
                tn[i].Text = dt.Rows[i][1].ToString();
                treeView.Nodes.Add(tn[i]);
            }

            DataTable dt2 = BookAdmin.GetBook();

            TreeNode[] tn_book = new TreeNode[dt2.Rows.Count];

            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    if (Convert.ToInt32(dt.Rows[j][0]) == Convert.ToInt32(dt2.Rows[i][2]))
                    {
                        tn_book[i]      = new TreeNode();
                        tn_book[i].Text = dt2.Rows[i][1].ToString();
                        tn[j].Nodes.Add(tn_book[i]);
                        break;
                    }
                }
            }
        }
Esempio n. 5
0
 private void BookTypeUpdate()
 {
     listBox2.Items.Clear();
     cb4_1.Items.Clear();
     dt = BookTypeAdmin.GetBookType();
     TreeNode[] tn = new TreeNode[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         listBox2.Items.Add(dt.Rows[i][1]);
         cb4_1.Items.Add(dt.Rows[i][1]);
         tn[i]      = new TreeNode();
         tn[i].Text = dt.Rows[i][1].ToString();
     }
 }
Esempio n. 6
0
        private void listBox2_Click(object sender, EventArgs e)
        {
            if (listBox2.SelectedIndex < 0)
            {
                return;
            }

            string name = listBox2.Items[listBox2.SelectedIndex].ToString();

            name = name.Trim();

            dt = BookTypeAdmin.GetBookType();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][1].ToString() == name)
                {
                    tb4_1.Text = dt.Rows[i][1].ToString();
                    tb4_2.Text = dt.Rows[i][2].ToString();
                }
            }
        }
Esempio n. 7
0
        private bool SetTextToBook()
        {
            if (tb4_3.Text == "" || tb4_4.Text == "" || tb4_5.Text == "" || tb4_6.Text == "" || cb4_1.Text == "" || cb4_2.Text == "")
            {
                MessageBox.Show("请输入完整信息");
                return(false);
            }
            new_book.Name      = tb4_3.Text;
            new_book.Concern   = tb4_4.Text;
            new_book.Author    = tb4_5.Text;
            new_book.Price     = float.Parse(tb4_6.Text);
            new_book.Condition = cb4_2.Text;

            dt = BookTypeAdmin.GetBookType();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (cb4_1.Text == dt.Rows[i][1].ToString())
                {
                    new_book.Type = Convert.ToInt32(dt.Rows[i][0]);
                }
            }

            if (treeView2.SelectedNode != null)
            {
                string name = treeView2.SelectedNode.Text.Trim();

                dt = BookAdmin.GetBook();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i][1].ToString() == name)
                    {
                        new_book.ID = Convert.ToInt32(dt.Rows[i][0].ToString());
                    }
                }
            }
            return(true);
        }