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

📄 loginform.h

📁 有关办公管理的系统
💻 H
字号:
//文件名:LoginForm.h
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

using namespace System::Data::SqlClient;


namespace 办公事务管理系统 {

	/// <summary>
	/// LoginForm 摘要
	///
	/// 警告: 如果更改此类的名称,则需要更改
	///          与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
	///          “资源文件名”属性。否则,
	///          设计器将不能与此窗体的关联
	///          本地化资源正确交互。
	/// </summary>
	public ref class LoginForm : public System::Windows::Forms::Form
	{
	public:
		LoginForm(void)
		{
			InitializeComponent();
			//
			//TODO: 在此处添加构造函数代码
			//
		}

	protected:
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		~LoginForm()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  退出系统Button;
	protected: 
	private: System::Windows::Forms::Button^  登录系统Button;
	private: System::Windows::Forms::TextBox^  用户密码TextBox;
	private: System::Windows::Forms::Label^  label2;
	public: System::Windows::Forms::TextBox^  用户名称TextBox;
	private: 
	private: System::Windows::Forms::Label^  label1;
	public: 

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(LoginForm::typeid));
			this->退出系统Button = (gcnew System::Windows::Forms::Button());
			this->登录系统Button = (gcnew System::Windows::Forms::Button());
			this->用户密码TextBox = (gcnew System::Windows::Forms::TextBox());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->用户名称TextBox = (gcnew System::Windows::Forms::TextBox());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->SuspendLayout();
			// 
			// 退出系统Button
			// 
			this->退出系统Button->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"退出系统Button.Image")));
			this->退出系统Button->ImageAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->退出系统Button->Location = System::Drawing::Point(179, 101);
			this->退出系统Button->Name = L"退出系统Button";
			this->退出系统Button->Size = System::Drawing::Size(100, 25);
			this->退出系统Button->TabIndex = 41;
			this->退出系统Button->Text = L"退出系统";
			this->退出系统Button->TextImageRelation = System::Windows::Forms::TextImageRelation::ImageBeforeText;
			this->退出系统Button->UseVisualStyleBackColor = true;
			this->退出系统Button->Click += gcnew System::EventHandler(this, &LoginForm::退出系统Button_Click);
			// 
			// 登录系统Button
			// 
			this->登录系统Button->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"登录系统Button.Image")));
			this->登录系统Button->Location = System::Drawing::Point(71, 101);
			this->登录系统Button->Name = L"登录系统Button";
			this->登录系统Button->Size = System::Drawing::Size(100, 25);
			this->登录系统Button->TabIndex = 40;
			this->登录系统Button->Text = L"登录系统";
			this->登录系统Button->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->登录系统Button->TextImageRelation = System::Windows::Forms::TextImageRelation::ImageBeforeText;
			this->登录系统Button->UseVisualStyleBackColor = true;
			this->登录系统Button->Click += gcnew System::EventHandler(this, &LoginForm::登录系统Button_Click);
			// 
			// 用户密码TextBox
			// 
			this->用户密码TextBox->Location = System::Drawing::Point(123, 67);
			this->用户密码TextBox->Name = L"用户密码TextBox";
			this->用户密码TextBox->PasswordChar = '*';
			this->用户密码TextBox->Size = System::Drawing::Size(174, 21);
			this->用户密码TextBox->TabIndex = 39;
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(52, 70);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(65, 12);
			this->label2->TabIndex = 38;
			this->label2->Text = L"用户密码:";
			// 
			// 用户名称TextBox
			// 
			this->用户名称TextBox->Location = System::Drawing::Point(123, 36);
			this->用户名称TextBox->Name = L"用户名称TextBox";
			this->用户名称TextBox->Size = System::Drawing::Size(174, 21);
			this->用户名称TextBox->TabIndex = 37;
			this->用户名称TextBox->Text = L"罗斌";
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(52, 39);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(65, 12);
			this->label1->TabIndex = 36;
			this->label1->Text = L"用户名称:";
			// 
			// LoginForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(342, 166);
			this->ControlBox = false;
			this->Controls->Add(this->退出系统Button);
			this->Controls->Add(this->登录系统Button);
			this->Controls->Add(this->用户密码TextBox);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->用户名称TextBox);
			this->Controls->Add(this->label1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->Name = L"LoginForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"欢迎使用办公事务管理系统";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	//记录用户登录次数
	private: static int MyTryCount = 0;
	private: static String^ MyOfficeConnectionString= L"Data Source=.;Initial Catalog=MyOffice;Integrated Security=True;Pooling=False";
	private: System::Void 登录系统Button_Click(System::Object^  sender, System::EventArgs^  e) {
		 String^ MySQLConnectionString = MyOfficeConnectionString;
	     String^ MySQL = "Select COUNT(*) From 操作权限设置 Where 用户名称=@用户名称 AND 用户密码=@用户密码";
         SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
         MyConnection->Open();
         SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
         MyCommand->Parameters->Clear();
         SqlParameter^ MySqlNameParameter = gcnew SqlParameter();
         MySqlNameParameter->ParameterName = "@用户名称";
         MySqlNameParameter->Value = this->用户名称TextBox->Text;
         MyCommand->Parameters->Add(MySqlNameParameter);
         SqlParameter^ MySqlPWParameter = gcnew SqlParameter();
         MySqlPWParameter->ParameterName = "@用户密码";
         MySqlPWParameter->Value = this->用户密码TextBox->Text;
         MyCommand->Parameters->Add(MySqlPWParameter);
         int MyCount = (int)MyCommand->ExecuteScalar();
         if (MyCount == 1)
         {
           this->Close();
         }
         else
         {
           this->MyTryCount += 1;
           if (this->MyTryCount != 3)
           {
             int MyDoCount = 3 - this->MyTryCount;
	 		 MessageBox::Show("用户密码或用户名称有错,还有" + MyDoCount + "次机会!", "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
             this->用户密码TextBox->Text = "";
             this->用户名称TextBox->Text = "";                    
           }
           else
           {
             退出系统Button_Click(nullptr, nullptr);
           }
          }
		  if (MyConnection->State == ConnectionState::Open)
          {
             MyConnection->Close();
          }
		}
		private: System::Void 退出系统Button_Click(System::Object^  sender, System::EventArgs^  e) {
			this->Owner->Close(); 
 		}
	};
}

⌨️ 快捷键说明

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