예제 #1
0
        //Trigger event when selecting a drop-down box
        private void cboBookTypeOne_SelectedValueChanged(object sender, EventArgs e)
        {
            //Determine if the options in the correct selection
            if (cboBookTypeOne.SelectedValue == null)
            {
                return;
            }
            else if (!ValidateInput.IsInteger(cboBookTypeOne.SelectedValue.ToString()))
            {
                return;
            }
            else
            {
                //Determine if there are no level two options, if any, enable, load data in the database, no, remain disabled
                if (objBookTypeServices.IsExistSubType(Convert.ToInt32(cboBookTypeOne.SelectedValue.ToString())))
                {
                    //Enable subclass drop-down box
                    cboBookTypeTwo.Enabled = true;
                    //Load
                    LoadSubTypeInfo(Convert.ToInt32(cboBookTypeOne.SelectedValue.ToString()));
                }
                else
                {
                    //Disable Subclass drop-down box
                    cboBookTypeTwo.Enabled = false;
                    cboBookTypeTwo.Text    = "No secondary class";
                }

                //Generate numbers
                lblBookId.Text = objBookServices.BuildNewBookId(Convert.ToInt32(cboBookTypeOne.SelectedValue.ToString()));
            }
        }
예제 #2
0
        //=============================User-defined methods===============================

        /// <summary>
        /// Determine the user's input
        /// </summary>
        /// <returns></returns>
        private bool CheckUserInput()
        {
            //Whether the login account is empty, 4 digits
            if (string.IsNullOrWhiteSpace(txtLoginId.Text))
            {
                lblLoginInfo.Text = "The login account cannot be empty!";
                txtLoginId.Focus();
                return(false);
            }

            //Number Four
            if (!ValidateInput.IsInteger(txtLoginId.Text.Trim()) || txtLoginId.Text.Trim().Length != 4)
            {
                lblLoginInfo.Text = "Login account must be 4 digits!";
                txtLoginId.Focus();
                return(false);
            }


            //Not allowed to be empty, must be 6-bit
            if (txtLoginPwd.Text.Length < 6)
            {
                lblLoginInfo.Text = "Password must be greater than or equal to 6 bits!";
                txtLoginPwd.Focus();
                return(false);
            }

            return(true);
        }
예제 #3
0
 private void cboBookTypeTwo_SelectedValueChanged(object sender, EventArgs e)
 {
     //Determine if the options in the correct selection
     if (cboBookTypeTwo.SelectedValue == null)
     {
         return;
     }
     else if (!ValidateInput.IsInteger(cboBookTypeTwo.SelectedValue.ToString()))
     {
         return;
     }
     else
     {
         //Generate numbers!
         lblBookId.Text = objBookServices.BuildNewBookId(Convert.ToInt32(cboBookTypeTwo.SelectedValue.ToString()));
     }
 }
예제 #4
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCommit_Click(object sender, EventArgs e)
        {
            //输入验证
            //图书类别验证
            if (cboBookTypeOne.SelectedItem == null)
            {
                MessageBox.Show("请选择图书一级类别");
                return;
            }
            if (cboBookTypeTwo.SelectedItem == null)
            {
                MessageBox.Show("请选择图书二级类别");
                return;
            }
            //isban长度必须是纯数字且13位
            if (!ValidateInput.IsInteger(txtBookISBN.Text.Trim()))
            {
                MessageBox.Show("图书的ISBN编号必须是纯数字");
                return;
            }
            if (txtBookISBN.Text.Trim().Length != 13)
            {
                MessageBox.Show("图书的ISBN编号长度必须是13位");
                return;
            }
            //名称和作者不能为空
            if (string.IsNullOrWhiteSpace(txtBookAuthor.Text.Trim()))
            {
                MessageBox.Show("图书作者不能为空");
                return;
            }
            BookModel bkmodel = new BookModel();

            bkmodel.BookId          = txtBookId.Text.Trim();
            bkmodel.BookName        = txtBookName.Text.Trim();
            bkmodel.BookType        = Convert.ToInt32(cboBookTypeTwo.SelectedValue);
            bkmodel.BookAuthor      = txtBookAuthor.Text.Trim();
            bkmodel.BookPrice       = Convert.ToDecimal(txtBookPrice.Text.Trim());
            bkmodel.ISBN            = txtBookISBN.Text.Trim();
            bkmodel.BookPress       = Convert.ToInt32(cboBookPress.SelectedValue);
            bkmodel.BookPublishDate = dtpPublishDate.Value;
            bkmodel.StorageInNum    = Convert.ToInt32(txtStorageInNum.Value);
            bkmodel.StorageInDate   = lblStorageInDate.Value;
            bkmodel.InventoryNum    = Convert.ToInt32(lblInventoryNum.Value);
            bkmodel.BorrowedNum     = Convert.ToInt32(lblBorrowedNum.Value);
            if (pbCurrentImage.Image != null)
            {
                bkmodel.BookImage = SerializeObjectToString.SerializeObject(pbCurrentImage.Image);
            }
            switch (actionflag)
            {
            case 1:
                int result2 = bkbll.InsertBook(bkmodel);
                if (result2 == 1)
                {
                    MessageBox.Show("图书添加成功");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                break;

            case 2:
                int result = bkbll.UpdateBook(bkmodel);
                if (result == 1)
                {
                    MessageBox.Show("图书修改成功");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("图书修改失败");
                    return;
                }
                break;
            }
        }
예제 #5
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     //1、数据有效性验证
     #region 验证账号
     if (txtLoginId.Text.Length == 0)
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "账号不能为空!";
         this.txtLoginId.Focus();
         //开始闪烁
         fang();
         return;
     }
     if (!ValidateInput.IsInteger(txtLoginId.Text.Trim()))
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "账号必须是正整数!";
         this.txtLoginId.Focus();
         //开始闪烁
         if (th == null || !th.IsAlive)
         {
             th = new Thread(run);
             th.IsBackground = true;
             th.Start();
         }
         return;
     }
     #endregion
     #region 验证密码
     if (txtLoginPwd.Text.Length == 0)
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "密码不能为空!";
         this.txtLoginPwd.Focus();
         //开始闪烁
         fang();
         return;
     }
     #endregion
     #region 验证验证码
     if (txtCode.Text.Length == 0)
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "验证码不能为空";
         this.txtCode.Focus();
         //开始闪烁
         fang();
         return;
     }
     //验证验证码
     if (lblCode.Text != txtCode.Text.Trim())
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "验证码不正确";
         this.txtCode.Focus();
         CreateValidation();
         txtCode.Text = "";
         //开始闪烁
         fang();
         return;
     }
     #endregion
     //2、提交数据库验证
     //构建登陆对象
     SysAdminsModel loginModel = new SysAdminsModel();
     loginModel.LoginId  = Convert.ToInt32(txtLoginId.Text.Trim());
     loginModel.LoginPwd = EncryptHelper.EncryptByMd5(txtLoginPwd.Text.Trim());
     SysAdminsManager bll       = new SysAdminsManager();
     SysAdminsModel   loginInfo = bll.QueryLoginAccount(loginModel);
     //3.根据结果来判断(账号禁用,账号密码错误,账号密码不存在)
     if (loginInfo == null)
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "账号密码错误!";
         this.txtLoginId.Focus();
         //开始闪烁
         fang();
         return;
     }
     else if (loginInfo.IsDisable == true)
     {
         lblInfo.Visible = true;
         lblInfo.Text    = "账号被禁用,请与管理员联系!";
         this.txtLoginId.Focus();
         //开始闪烁
         fang();
         return;
     }
     else//账号是正常的
     {
         //1.处理后面的逻辑(1=更新登录时间)
         int rst = bll.UpdateLoginTime(loginInfo.LoginId);
         if (rst != 1)
         {
             MessageBox.Show("更新登录时间失败");
         }
         //2.写入登录日志
         LoginLogsManager logbll   = new LoginLogsManager();
         LoginLogsModel   logmodel = new LoginLogsModel()
         {
             LoginId       = loginInfo.LoginId,
             UserName      = loginInfo.UserName,
             LoginComputer = Dns.GetHostName(),
             LoginTime     = logbll.GetServerTime()
         };
         int result = logbll.WriteLoginLogs(logmodel);
         if (result != 1)
         {
             MessageBox.Show("写入登录日志失败");
             return;
         }
         //3.写入全局变量
         Program.currentLogin = loginInfo;
         //4.设置窗体的状态值为ok
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }