Beispiel #1
0
 private void confirm_Click(object sender, EventArgs e)
 {
     if (Check())
     {
         uint       sum    = Convert.ToUInt32(NUMtxt.Text);
         Book       book   = new Book(bknametxt.Text, isbntxt.Text, presstxt.Text, authortxt.Text, (BookType)bkTypebox.SelectedIndex);
         BookMaster master = new BookMaster(sum, book);
         if (FileDate.Exist <BookMaster>(master))
         {
             DialogResult dr = MessageBox.Show("此书已经存在,要直接添加吗(将会增加总数量)?", "重要提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (dr == DialogResult.Yes)
             {
                 master.Total_num += sum;
                 FileDate.AlterInfo <BookMaster>(master);
             }
             else
             {
                 return;
             }
         }
         else
         {
             FileDate.WriteInfo(master);
             MessageBox.Show("书籍添加成功!", "通知");
         }
     }
 }
 private void confirmbtn_Click(object sender, EventArgs e)
 {
     if (found)
     {
         Book book = master.Info;
         if (nameAlter.Checked)
         {
             book.Name = alteredInfotxt.Text;
         }
         else if (authAlter.Checked)
         {
             book.Author = alteredInfotxt.Text;
         }
         else if (isbnAlter.Checked)
         {
             book.ISBN = alteredInfotxt.Text;
         }
         else if (pressAlter.Checked)
         {
             book.Press = alteredInfotxt.Text;
         }
         else
         {
             tipslb.Text = "请选择要修改哪一项";
             return;
         }
         master = new BookMaster(master.Total_num, book);
         MessageBox.Show("修改成功", "通知", MessageBoxButtons.OK, MessageBoxIcon.Information);
         FileDate.AlterInfo <BookMaster>(master);
     }
 }
        private void searchbtn_Click(object sender, EventArgs e)
        {
            string isbn = isbntxt.Text;

            //重复点击直接跳过
            if (master.Info.ISBN == isbn || "" == isbn)
            {
                if (isbn != "")
                {
                    display();
                }
                else
                {
                    tipslb.Text = "ISBN不能为空";
                }
                return;
            }
            List <BookMaster> list = FileDate.SearchByISBN(isbn);

            if (list.Count > 0)
            {
                master = list[0];
                found  = true;
                display();
            }
            else
            {
                showInfotxt.Text = "未找到相关信息,确认ISBN输入是否正确";
            }
        }
Beispiel #4
0
        private List <BookMaster> SearchByKeyword(Book book)
        {
            List <BookMaster> bklist = new List <BookMaster>();
            BookMaster        master = new BookMaster();
            uint size = FileDate.CountOf <BookMaster>();

            for (int i = 0; i < size; i++)
            {
                master = FileDate.ReadOne <BookMaster>(i);
                if (master.SimiliarTo(book))
                {
                    bklist.Add(master);
                }
            }
            return(bklist);
        }
 private void delbtn_Click(object sender, EventArgs e)
 {
     if (found)
     {
         DialogResult dr = MessageBox.Show("确定要删除这类书吗?", "重要提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             FileDate.Delete <BookMaster>(master);
             master           = new BookMaster();
             showInfotxt.Text = "";
         }
     }
     else
     {
         tipslb.Text = "请先确认书籍信息再进行操作";
     }
 }
Beispiel #6
0
        //通过ISBN来找到书籍(书籍ISBN是唯一的,可以当做一个标识)
        public static List <BookMaster> SearchByISBN(string isbn)
        {
            BookMaster        master = new BookMaster();
            uint              count  = FileDate.CountOf <BookMaster>();
            List <BookMaster> bklist = new List <BookMaster>(1);

            for (int i = 0; i < count; i++)
            {
                master = FileDate.ReadOne <BookMaster>(i);
                if (master.Info.ISBN.Contains(isbn))
                {
                    bklist.Add(master);
                    break;
                }
            }
            if (bklist.Count == 0)
            {
                MessageBox.Show("未找到该ISBN编号的书", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(bklist);
        }
Beispiel #7
0
        public Main()
        {
            InitializeComponent();
            if (File.Exists("Lib_Mana_Sys.User.dat"))
            {
                File.Delete("Lib_Mana_Sys.User.dat");
            }
            if (File.Exists("Lib_Mana_Sys.BookMaster.dat"))
            {
                File.Delete("Lib_Mana_Sys.BookMaster.dat");
            }
            if (File.Exists("Lib_Mana_Sys.Record.dat"))
            {
                File.Delete("Lib_Mana_Sys.Record.dat");
            }
            User       u1     = new User(true, Privilege.学生, "16020031111", "OUCer", "123456");
            User       u2     = new User(false, Privilege.职工, "16020031231", "玉良红", "987452");
            User       u3     = new User(true, Privilege.学生, "16020031561", "梁园", "654123");
            User       u4     = new User(true, Privilege.管理员, "123456", "Master", "123456");
            Book       b1     = new Book("Java从入门到放弃", "123456", "人民教育出版社", "Master", BookType.数理科学与化学);
            BookMaster master = new BookMaster(10, b1);

            FileDate.WriteInfo(master);
            Book b2 = new Book("C Plus从入门到入土", "1156416454652", "仁爱教育出版社", "Oh Yes", BookType.哲学宗教);

            for (uint i = 100; i < 200; i++)
            {
                string     ment = i.ToString();
                Book       b    = new Book("英雄联盟" + ment, ment, "大魔王出版社", "Faker" + ment, BookType.综合性图书);
                BookMaster m    = new BookMaster(2, b);
                FileDate.WriteInfo(m);
            }
            master = new BookMaster(6, b2);
            FileDate.WriteInfo(master);
            FileDate.WriteInfo(u2);
            FileDate.WriteInfo(u3);
            FileDate.WriteInfo(u4);
            FileDate.WriteInfo(u1);
            login = new Login(this);
        }
 public BookAlter()
 {
     InitializeComponent();
     master = new BookMaster();
     found  = false;
 }