⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 librarysystem.cs

📁 一个基于.NETFramework架构的图书管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    tb.Text = "";
                }
            }
            rbFemaleB.Checked = false;
            rbMaleB.Checked = false;
            lblAlertMessageB.Visible = false ;
            
        }

        private void btnReborrow_Click(object sender, EventArgs e)
        {
            borbook = txtBookIDC.Text.Trim();
            if (borbook == "")
            {
                MessageBox.Show("图书编号不能为空");
                return;
            }
            lblAlertMessageC.Visible = false;
            try
            {
                if (btnReborrow.Text == "检索")
                {
                    DataSet ds=logic.GetBorrowInfoByBookNO(borbook);
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        lblAlertMessageC.Visible = true;
                        return;
                    }
                    DataRow userRow = ds.Tables[0].Rows[0];
                    if (Convert.ToBoolean(userRow["isreturned"]))
                    {
                        MessageBox.Show("该书已归还");
                        return;
                    }                    
                    btnReborrow.Text = "续借";
                    txtBookIDC.Enabled = false;
                    txtISBNC.Text = userRow["ISBN"].ToString();
                    txtBookNameC.Text = userRow["BookName"].ToString();
                    txtPublisherC.Text = userRow["Publisher"].ToString();
                    txtAuthorC.Text = userRow["Author"].ToString();
                    txtNameC.Text = userRow["UserName"].ToString();
                    txtClassC.Text = userRow["class"].ToString();
                    if ((bool)userRow["sex"])
                    {
                        rbFemaleC.Select();
                    }
                    else
                    {
                        rbMaleC.Select();
                    }
                    borrower = userRow["UserNO"].ToString();
                    dgBorrowInfoC.DataSource = logic.GetBorrowInfoByUserNO(borrower).Tables[0];
                }
                else
                {

                    logic.ReBorrow(borbook);
                    MessageBox.Show("续借成功!");
                    dgBorrowInfoC.DataSource = logic.GetBorrowInfoByUserNO(borrower).Tables[0];
                    btnCancelC_Click(sender, e);

                }
            }

            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }

        private void btnCancelC_Click(object sender, EventArgs e)
        {

            foreach (Control co1 in groupBox6.Controls)
            {
                System.Windows.Forms.TextBox tb = co1 as System.Windows.Forms.TextBox;
                if (tb != null)
                {
                    tb.Text = "";

                }
                rbFemaleC.Checked = false;
                rbMaleC.Checked = false;

            }
            foreach (Control co1 in groupBox7.Controls)
            {
                System.Windows.Forms.TextBox tb = co1 as System.Windows.Forms.TextBox;
                if (tb != null)
                {
                    tb.Text = "";

                }

            }
            foreach (Control co1 in groupBox8.Controls)
            {
                System.Windows.Forms.TextBox tb = co1 as System.Windows.Forms.TextBox;
                if (tb != null)
                {
                    tb.Text = "";

                }

            }
            lblAlertMessageC.Visible = false;
            btnReborrow.Text = "检索";
            txtBookIDC.Enabled =true ;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
           showtime.Text =DateTime.Today.ToLongDateString() + "  " + DateTime.Now.ToLongTimeString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (Control co1 in gbInsertBook.Controls)
                {
                    System.Windows.Forms.TextBox tb = co1 as System.Windows.Forms.TextBox;
                    if (tb != null && tb.Text.Trim() == "")
                    {
                        MessageBox.Show("请输入所有值!");
                        return;
                    }
                }
                string bookno = this.txtBookIDD.Text.Trim();
                string bookname = this.txtBookNameD.Text.Trim();
                DateTime publishdate = Convert.ToDateTime(this.txtPublishDateD.Text.Trim());
                string isbn = this.txtISBND.Text.Trim();
                string author = this.txtAuthorD.Text.Trim();
                string publisher = this.txtPublisherD.Text.Trim();
                int wordcount = Convert.ToInt32(this.txtWordCountD.Text.Trim());
                int pagecount = Convert.ToInt32(this.txtPageCountD.Text.Trim());
                string version = this.txtBookVersionD.Text.Trim();
                string booktypeno = Convert.ToString(this.cbBookTypeD1.SelectedValue);
                if (rbNewBook.Checked)
                {
                    if(logic.InsertNewBook(bookno, isbn, bookname, author, publishdate, version,
                    wordcount, pagecount, publisher, booktypeno))
                    {
                        MessageBox.Show("新书入库成功!");
                    }
                    else
                    {
                        MessageBox.Show("新书入库失败!");
                    }
                }
                else
                {
                    if (logic.UpdateBookInfo(bookno, isbn, bookname, author, publishdate, version,
                    wordcount, pagecount, publisher, booktypeno))
                    {
                        MessageBox.Show("修改成功!");
                        string bookname2 = txtBookNameD2.Text.Trim();
                        string booktypeno2 = Convert.ToString(cbBookTypeD2.SelectedValue);
                        dataGridView1.DataSource = logic.GetBookInfo(bookname2, booktypeno2).Tables[0];
                    }
                }
            }
            catch
            {
                MessageBox.Show("请按指定格式输入日期及数字");
            }
        }

        private void txtBookVersionD_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnSearchD_Click(object sender, EventArgs e)
        {
            string bookname2 = txtBookNameD2.Text.Trim();
            string booktypeno2 = Convert.ToString(cbBookTypeD2.SelectedValue);
            dataGridView1.DataSource = logic.GetBookInfo(bookname2, booktypeno2).Tables [0];
            if (logic.GetBookInfo(bookname2, booktypeno2).Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("没有您查找的书!");
            }
            
        }

        private void btnDelD_Click(object sender, EventArgs e)
        {
            DialogResult result=MessageBox.Show("确实要删除吗?", "确认删除", MessageBoxButtons.YesNo,MessageBoxIcon.Question );
            if (result == DialogResult.Yes)
            {
                try
                {
                    if (logic.DeleteBook(deletebook))
                    {
                        MessageBox.Show("删除成功!");
                        string bookname = txtBookNameD2.Text.Trim();
                        string booktypeno = Convert.ToString(cbBookTypeD2.SelectedValue);
                        dataGridView1.DataSource = logic.GetBookInfo(bookname, booktypeno).Tables[0];
                    }
                    else
                    {
                        MessageBox.Show("删除失败!");
                    }

                    
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message); 
                }
            }
            

        }



        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.CurrentRow.Selected = true;
            deletebook = dataGridView1.CurrentRow.Cells["bookno"].Value.ToString();
            txtBookIDD.Text = deletebook; 
            txtBookNameD.Text = dataGridView1.CurrentRow.Cells["bookname"].Value.ToString();
            txtPublishDateD.Text = dataGridView1.CurrentRow.Cells["publishdate"].Value.ToString();
            txtISBND.Text = dataGridView1.CurrentRow.Cells["isbn"].Value.ToString();
            txtAuthorD.Text = dataGridView1.CurrentRow.Cells["author"].Value.ToString();
            txtPublisherD.Text = dataGridView1.CurrentRow.Cells["publisher"].Value.ToString();
            txtWordCountD.Text = dataGridView1.CurrentRow.Cells["wordcount"].Value.ToString();
            txtPageCountD.Text = dataGridView1.CurrentRow.Cells["pagecount"].Value.ToString();
            txtBookVersionD.Text = dataGridView1.CurrentRow.Cells["bookversion"].Value.ToString();
            cbBookTypeD1.SelectedValue = dataGridView1.CurrentRow.Cells["booktypeno"].Value.ToString();
            rbModify.Checked = true;

        }

        private void rbModify_CheckedChanged(object sender, EventArgs e)
        {
            txtBookIDD.Enabled = false;
        }

        private void rbNewBook_CheckedChanged(object sender, EventArgs e)
        {
            txtBookIDD.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (Control co1 in gbInsertBook.Controls)
            {
                System.Windows.Forms.TextBox tb = co1 as System.Windows.Forms.TextBox;
                if (tb != null)
                {
                    tb.Text = "";
                }
            }
            rbNewBook.Checked = true;
        }

        private void btnSearchE_Click(object sender, EventArgs e)
        {

        }

        private void btnConfirmF_Click(object sender, EventArgs e)
        {
            string originalpwd = txtOriginalPWD.Text.Trim();
            string newpwd = txtNewPWD.Text.Trim();
            string confirmpwd = txtConfirmPWD.Text.Trim();
            if (originalpwd == "" || newpwd == "" || confirmpwd == "")
            {
                MessageBox.Show("密码不能为空!"); 
                return;
            }
            if (newpwd != confirmpwd)
            {
                MessageBox.Show("两次密码输入不正确!");
                return ;
            }
            if (!logic.Login(adminno, originalpwd))
            {
                MessageBox.Show("原始密码不正确!");
                return;
            }
            if (logic.ChangePassword(adminno, newpwd))
            {
                MessageBox.Show("密码修改成功!");
            }
            else
            {
                MessageBox.Show("密码修改失败!");
            }



          
        }

        private void showtime_Click(object sender, EventArgs e)
        {

        }

      
      


      
        
       

        
       
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -