Ejemplo n.º 1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Oreki.ShowInput("条码扫描", "请扫描用户条码");
            if (Oreki.OkCancel == 0)
            {
                return;
            }
            ChkCon();
            var commandText = $"select user_name from teamz_users where user_barcode='{Oreki.Temp}'";
            var command     = new MySqlCommand(commandText, Connection);
            var name        = new object();
            var reader      = command.ExecuteReader();

            name = new object();
            while (reader.Read())
            {
                name = reader[0];
            }
            reader.Close();
            if (Oreki.Temp == "0")
            {
                MessageBox.Show("用户不存在");
                return;
            }
            try
            {
                var xxx = (string)name;
            }
            catch (Exception)
            {
                MessageBox.Show("用户不存在");
                return;
            }
            try
            {
                label1.Text = $"当前用户:{(string)name}";
            }
            catch (Exception)
            {
                return;
            }
            tabControl1.Enabled = true;
            TabRefresh();
        }
Ejemplo n.º 2
0
        private void Button3_Click(object sender, EventArgs e)
        {
            ChkCon();
            string          commandText = $"select book_owner from teamz_books where book_barcode='{Oreki.Bookbarcode}'";
            MySqlCommand    command     = new MySqlCommand(commandText, connection);
            object          owner       = new object();
            MySqlDataReader reader      = command.ExecuteReader();

            while (reader.Read())
            {
                owner = reader[0];
            }
            reader.Close();
            if ((string)owner != "0")
            {
                MessageBox.Show("图书未归还");
                return;
            }
            Oreki.ShowInput("删除图书", "扫描条码以确认删除");
            if (Oreki.OkCancel == 0)
            {
                return;
            }
            if (Oreki.Temp == Oreki.Bookbarcode)
            {
                string       commandText2 = $"delete from teamz_books where book_barcode='{Oreki.Bookbarcode}'";
                MySqlCommand command2     = new MySqlCommand(commandText2, connection);
                command2.ExecuteNonQuery();
                MessageBox.Show("图书删除成功");
                BookSearch();
            }
            else
            {
                MessageBox.Show("输入的内容与图书条码不匹配");
            }
        }