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

📄 userinfomanage.h

📁 MFC程序开发参考大全 【明日科技】宋坤 刘锐宁 李伟明 【丛 书 名】 软件工程师典藏 【出 版 社】 人民邮电出版社 本书详细介绍了MFC框架中所有常用类及控件的应用
💻 H
📖 第 1 页 / 共 2 页
字号:
#pragma once

#include "CDataManage.h"
#include "CLogin.h"

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


namespace BOOKMANAGE {


	/// <summary>
	/// UserInfoManage 摘要
	///
	/// 警告: 如果更改此类的名称,则需要更改
	///          与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
	///          “资源文件名”属性。否则,
	///          设计器将不能与此窗体的关联
	///          本地化资源正确交互。
	/// </summary>
	public ref class UserInfoManage : public System::Windows::Forms::Form
	{
	public:
		UserInfoManage(void)
		{
			CurRow = -1;
			InitializeComponent();
			//
			//TODO: 在此处添加构造函数代码
			//
		}
		int CurRow; //记录表格当前行索引
	protected:
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		~UserInfoManage()
		{
			if (components)
			{
				delete components;
			}
		}
		CDataManage DataManage;
	public:
		//判断用户信息是否为空
		bool UserInfoIsNull()
		{	
			 for (int i = 0; i< groupBox2->Controls->Count; i++)
			 {
				 if (groupBox2->Controls[i]->GetType()->Name=="TextBox")
					 if (groupBox2->Controls[i]->Text->Trim()=="")
					 {
						 return true;
					 }
			 }
			 return false;
		}

		//刷新数据
		void RefreshUserInfo()
		{

			
				 DataManage.Command->CommandText = "select * from UserInfo";
				 DataManage.DataReader = DataManage.Command->ExecuteReader();
			 
				 int colnum = DataManage.DataReader->FieldCount;
				 int currow = 0;

				 UserList->Items->Clear(); //删除所有行
				 //添加数据
				 while (DataManage.DataReader->Read())
				 {
					UserList->Items->Add(DataManage.DataReader->GetString(0)); //添加行

					for (int i = 1; i<colnum;i++)
					{
						UserList->Items[currow]->SubItems->Add(DataManage.DataReader->GetString(i));
					}
					currow+=1;	 
				 }		
				 DataManage.DataReader->Close();
				 CurRow= -1;
		}

		//清空编辑框文本数据
		void ClearText()
		{
			for (int i=0; i<groupBox2->Controls->Count;i++)
			{
				if (groupBox2->Controls[i]->GetType()->Name=="TextBox")

					groupBox2->Controls[i]->Text = "";
			
			}
		
		}
		//判断员工信息是否存在
		bool UserIsExist(String^ username)
		{
			String ^ sql = String::Format("select * from UserInfo where username = '{0}'",username);
			DataManage.Command->CommandText = sql;
			DataManage.DataReader = DataManage.Command->ExecuteReader();
			if (DataManage.DataReader->HasRows)
			{
				DataManage.DataReader->Close();
				return true;
			}
			else
			{
				DataManage.DataReader->Close();
				return false;
			}

		
		}


	private: System::Windows::Forms::GroupBox^  groupBox1;
	protected: 

	private: System::Windows::Forms::ListView^  UserList;
	private: System::Windows::Forms::GroupBox^  groupBox2;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TextBox^  UserName;
	private: System::Windows::Forms::TextBox^  UserLevel;


	private: System::Windows::Forms::TextBox^  UserPass;
	private: System::Windows::Forms::Button^  ButtonAdd;
	private: System::Windows::Forms::Button^  ButtonDelete;
	private: System::Windows::Forms::Button^  ButtonUpdate;


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

#pragma region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->UserList = (gcnew System::Windows::Forms::ListView());
			this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
			this->ButtonDelete = (gcnew System::Windows::Forms::Button());
			this->ButtonUpdate = (gcnew System::Windows::Forms::Button());
			this->ButtonAdd = (gcnew System::Windows::Forms::Button());
			this->UserLevel = (gcnew System::Windows::Forms::TextBox());
			this->UserPass = (gcnew System::Windows::Forms::TextBox());
			this->UserName = (gcnew System::Windows::Forms::TextBox());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->groupBox1->SuspendLayout();
			this->groupBox2->SuspendLayout();
			this->SuspendLayout();
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->UserList);
			this->groupBox1->Location = System::Drawing::Point(12, 159);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(413, 218);
			this->groupBox1->TabIndex = 0;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"用户列表";
			// 
			// UserList
			// 
			this->UserList->Font = (gcnew System::Drawing::Font(L"宋体", 10.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(134)));
			this->UserList->FullRowSelect = true;
			this->UserList->GridLines = true;
			this->UserList->Location = System::Drawing::Point(21, 20);
			this->UserList->Name = L"UserList";
			this->UserList->Size = System::Drawing::Size(370, 176);
			this->UserList->TabIndex = 0;
			this->UserList->UseCompatibleStateImageBehavior = false;
			this->UserList->View = System::Windows::Forms::View::Details;
			this->UserList->DoubleClick += gcnew System::EventHandler(this, &UserInfoManage::UserList_DoubleClick);
			this->UserList->Click += gcnew System::EventHandler(this, &UserInfoManage::UserList_Click);
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->ButtonDelete);
			this->groupBox2->Controls->Add(this->ButtonUpdate);
			this->groupBox2->Controls->Add(this->ButtonAdd);
			this->groupBox2->Controls->Add(this->UserLevel);
			this->groupBox2->Controls->Add(this->UserPass);
			this->groupBox2->Controls->Add(this->UserName);
			this->groupBox2->Controls->Add(this->label3);
			this->groupBox2->Controls->Add(this->label2);
			this->groupBox2->Controls->Add(this->label1);
			this->groupBox2->Location = System::Drawing::Point(12, 12);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(413, 135);
			this->groupBox2->TabIndex = 0;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"用户信息";
			// 
			// ButtonDelete
			// 
			this->ButtonDelete->Location = System::Drawing::Point(316, 89);
			this->ButtonDelete->Name = L"ButtonDelete";
			this->ButtonDelete->Size = System::Drawing::Size(75, 23);
			this->ButtonDelete->TabIndex = 8;
			this->ButtonDelete->Text = L"删除";
			this->ButtonDelete->UseVisualStyleBackColor = true;
			this->ButtonDelete->Click += gcnew System::EventHandler(this, &UserInfoManage::ButtonDelete_Click);
			// 
			// ButtonUpdate
			// 
			this->ButtonUpdate->Location = System::Drawing::Point(316, 56);
			this->ButtonUpdate->Name = L"ButtonUpdate";
			this->ButtonUpdate->Size = System::Drawing::Size(75, 23);
			this->ButtonUpdate->TabIndex = 7;
			this->ButtonUpdate->Text = L"修改";
			this->ButtonUpdate->UseVisualStyleBackColor = true;
			this->ButtonUpdate->Click += gcnew System::EventHandler(this, &UserInfoManage::ButtonUpdate_Click);
			// 
			// ButtonAdd
			// 
			this->ButtonAdd->Location = System::Drawing::Point(316, 25);
			this->ButtonAdd->Name = L"ButtonAdd";
			this->ButtonAdd->Size = System::Drawing::Size(75, 23);
			this->ButtonAdd->TabIndex = 6;
			this->ButtonAdd->Text = L"添加";

⌨️ 快捷键说明

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