Example #1
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     this.Visible      = false;
     this.DialogResult = DialogResult.Cancel;
     _instance         = null;
     this.Dispose();
 }
Example #2
0
        private void bookDetail_Load(object sender, EventArgs e)
        {
            Book temp = bookDetailControler.GetBookbybkID(bookSearch.bkID);

            if (temp == null)
            {
                temp = bookDetailControler.GetBookbybkID(bookSearch_reader.bkID);
                readonlymode();
            }
            if (temp == null)
            {
                MessageBox.Show("连接数据库失败,请检查您的网络连接!", "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _instance = null;
                this.Dispose();
                return;
            }

            textBox_bkID.Text                 = temp.bkID.ToString();
            textBox_bkCode.Text               = temp.bkCode;
            textBox_bkName.Text               = temp.bkName;
            textBox_bkAuthor.Text             = temp.bkAuthor;
            textBox_bkPress.Text              = temp.bkPress;
            dTP_bkDatePress.Value             = temp.bkDatePress;
            textBox_bkISBN.Text               = temp.bkISBN;
            comboBox_bkCatalog.SelectedIndex  = Int32.Parse(temp.bkCatalog);
            comboBox_bkLanguage.SelectedIndex = temp.bkLanguage;
            textBox_bkPages.Text              = temp.bkPages.ToString();
            textBox_bkPrice.Text              = temp.bkPrice.ToString();
            dTP_bkDateIn.Value                = temp.bkDateIn;
            textBox_bkBrief.Text              = temp.bkBrief;
            pic_bkCover.Image                 = bookDetailControler.ByteToImage(temp.bkCover);
            comboBox_Status.SelectedItem      = temp.bkStatus;
        }
Example #3
0
 private static bookDetail _instance = null; // 单例模式
 public static bookDetail CreateInstance()
 {
     if (_instance == null)
     {
         _instance = new bookDetail();
     }
     return(_instance);
 }
Example #4
0
 private void bookDetail_FormClosing(object sender, FormClosingEventArgs e)
 {
     _instance = null;
     this.Dispose();
 }
Example #5
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (textBox_bkCode.Text == "")
     {
         MessageBox.Show("图书编号不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     if (textBox_bkName.Text == "")
     {
         MessageBox.Show("图书名称不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     if (textBox_bkAuthor.Text == "")
     {
         MessageBox.Show("图书作者不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     if (textBox_bkPress.Text == "")
     {
         MessageBox.Show("出版社名不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     if (textBox_bkISBN.Text == "")
     {
         MessageBox.Show("ISBN不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     try
     {
         if (Int32.Parse(textBox_bkPages.Text) <= 0)
         {
             MessageBox.Show("图书页数必须大于0!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("请输入正确的图书页数!", "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         if (decimal.Parse(textBox_bkPrice.Text) <= 0)
         {
             MessageBox.Show("图书价格必须大于0!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("请输入正确的价格!", "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (textBox_bkBrief.Text == "")
     {
         MessageBox.Show("内容简介不能为空!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     setBookInfo();
     // 如果该图书还存在未提交的修改图书操作,报错!
     foreach (UserAction action in main.ActionList)
     {
         if (action.actionSource == "Book" && action.actionType == "Update")
         {
             Book tmp = (Book)action.actionModel;
             if (tmp.bkID == GlobalObject.bookSource.bkID)
             {
                 MessageBox.Show("对当前图书的修改操作已存在于操作队列!", "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
     }
     main.addAction(GlobalObject.actionSource);
     this.Visible      = false;
     this.DialogResult = DialogResult.OK;
     _instance         = null;
     this.Dispose();
 }