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

📄 commissaryform.h

📁 实现了很好的客户关系管理功能
💻 H
📖 第 1 页 / 共 3 页
字号:
			// 
			this->家庭地址TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->客户代表BindingSource, L"家庭地址", true)));
			this->家庭地址TextBox->Location = System::Drawing::Point(68, 217);
			this->家庭地址TextBox->Name = L"家庭地址TextBox";
			this->家庭地址TextBox->Size = System::Drawing::Size(200, 21);
			this->家庭地址TextBox->TabIndex = 47;
			// 
			// 出生日期DateTimePicker
			// 
			this->出生日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->客户代表BindingSource, L"出生日期", 
				true)));
			this->出生日期DateTimePicker->Location = System::Drawing::Point(68, 239);
			this->出生日期DateTimePicker->Name = L"出生日期DateTimePicker";
			this->出生日期DateTimePicker->Size = System::Drawing::Size(200, 21);
			this->出生日期DateTimePicker->TabIndex = 49;
			// 
			// 个人描述TextBox
			// 
			this->个人描述TextBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->个人描述TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->客户代表BindingSource, L"个人描述", true)));
			this->个人描述TextBox->Location = System::Drawing::Point(334, 23);
			this->个人描述TextBox->Multiline = true;
			this->个人描述TextBox->Name = L"个人描述TextBox";
			this->个人描述TextBox->Size = System::Drawing::Size(204, 237);
			this->个人描述TextBox->TabIndex = 51;
			// 
			// bindingNavigatorDeleteItem
			// 
			this->bindingNavigatorDeleteItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"bindingNavigatorDeleteItem.Image")));
			this->bindingNavigatorDeleteItem->Name = L"bindingNavigatorDeleteItem";
			this->bindingNavigatorDeleteItem->RightToLeftAutoMirrorImage = true;
			this->bindingNavigatorDeleteItem->Size = System::Drawing::Size(49, 22);
			this->bindingNavigatorDeleteItem->Text = L"删除";
			// 
			// bindingNavigatorAddNewItem
			// 
			this->bindingNavigatorAddNewItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"bindingNavigatorAddNewItem.Image")));
			this->bindingNavigatorAddNewItem->Name = L"bindingNavigatorAddNewItem";
			this->bindingNavigatorAddNewItem->RightToLeftAutoMirrorImage = true;
			this->bindingNavigatorAddNewItem->Size = System::Drawing::Size(49, 22);
			this->bindingNavigatorAddNewItem->Text = L"新增";
			this->bindingNavigatorAddNewItem->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &CommissaryForm::bindingNavigatorAddNewItem_MouseUp);
			// 
			// toolStripLabel1
			// 
			this->toolStripLabel1->Name = L"toolStripLabel1";
			this->toolStripLabel1->Size = System::Drawing::Size(59, 22);
			this->toolStripLabel1->Text = L"客户名称:";
			// 
			// 查询ToolStripButton
			// 
			this->查询ToolStripButton->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"查询ToolStripButton.Image")));
			this->查询ToolStripButton->Name = L"查询ToolStripButton";
			this->查询ToolStripButton->Size = System::Drawing::Size(49, 22);
			this->查询ToolStripButton->Text = L"查询";
			this->查询ToolStripButton->Click += gcnew System::EventHandler(this, &CommissaryForm::查询ToolStripButton_Click);
			// 
			// 客户名称ToolStripComboBox
			// 
			this->客户名称ToolStripComboBox->Name = L"客户名称ToolStripComboBox";
			this->客户名称ToolStripComboBox->Size = System::Drawing::Size(160, 25);
			this->客户名称ToolStripComboBox->Text = L"%%";
			// 
			// 客户代表DataGridView
			// 
			this->客户代表DataGridView->AllowUserToAddRows = false;
			this->客户代表DataGridView->AllowUserToDeleteRows = false;
			this->客户代表DataGridView->AllowUserToResizeRows = false;
			this->客户代表DataGridView->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->客户代表DataGridView->AutoGenerateColumns = false;
			this->客户代表DataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(12) {this->dataGridViewTextBoxColumn1, 
				this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5, 
				this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7, this->dataGridViewTextBoxColumn8, this->dataGridViewTextBoxColumn9, 
				this->dataGridViewTextBoxColumn10, this->dataGridViewTextBoxColumn11, this->dataGridViewTextBoxColumn12});
			this->客户代表DataGridView->DataSource = this->客户代表BindingSource;
			this->客户代表DataGridView->Location = System::Drawing::Point(5, 262);
			this->客户代表DataGridView->MultiSelect = false;
			this->客户代表DataGridView->Name = L"客户代表DataGridView";
			this->客户代表DataGridView->ReadOnly = true;
			this->客户代表DataGridView->RowHeadersVisible = false;
			this->客户代表DataGridView->RowTemplate->Height = 23;
			this->客户代表DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
			this->客户代表DataGridView->Size = System::Drawing::Size(533, 150);
			this->客户代表DataGridView->TabIndex = 27;
			// 
			// 客户代表BindingNavigator
			// 
			this->客户代表BindingNavigator->AddNewItem = this->bindingNavigatorAddNewItem;
			this->客户代表BindingNavigator->BindingSource = this->客户代表BindingSource;
			this->客户代表BindingNavigator->CountItem = nullptr;
			this->客户代表BindingNavigator->DeleteItem = this->bindingNavigatorDeleteItem;
			this->客户代表BindingNavigator->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(12) {this->toolStripLabel1, 
				this->客户名称ToolStripComboBox, this->查询ToolStripButton, this->bindingNavigatorMoveFirstItem, this->bindingNavigatorMovePreviousItem, 
				this->bindingNavigatorSeparator, this->bindingNavigatorMoveNextItem, this->bindingNavigatorMoveLastItem, this->bindingNavigatorSeparator2, 
				this->bindingNavigatorAddNewItem, this->bindingNavigatorDeleteItem, this->客户代表BindingNavigatorSaveItem});
			this->客户代表BindingNavigator->Location = System::Drawing::Point(0, 0);
			this->客户代表BindingNavigator->MoveFirstItem = this->bindingNavigatorMoveFirstItem;
			this->客户代表BindingNavigator->MoveLastItem = this->bindingNavigatorMoveLastItem;
			this->客户代表BindingNavigator->MoveNextItem = this->bindingNavigatorMoveNextItem;
			this->客户代表BindingNavigator->MovePreviousItem = this->bindingNavigatorMovePreviousItem;
			this->客户代表BindingNavigator->Name = L"客户代表BindingNavigator";
			this->客户代表BindingNavigator->PositionItem = nullptr;
			this->客户代表BindingNavigator->Size = System::Drawing::Size(542, 25);
			this->客户代表BindingNavigator->TabIndex = 26;
			this->客户代表BindingNavigator->Text = L"bindingNavigator1";
			// 
			// CommissaryForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(542, 416);
			this->Controls->Add(自编号Label);
			this->Controls->Add(this->自编号TextBox);
			this->Controls->Add(客户名称Label);
			this->Controls->Add(this->客户名称ComboBox);
			this->Controls->Add(代表姓名Label);
			this->Controls->Add(this->代表姓名TextBox);
			this->Controls->Add(this->所在部门TextBox);
			this->Controls->Add(this->主要职务TextBox);
			this->Controls->Add(this->办公电话TextBox);
			this->Controls->Add(this->移动电话TextBox);
			this->Controls->Add(this->家庭电话TextBox);
			this->Controls->Add(this->电子信箱TextBox);
			this->Controls->Add(this->家庭地址TextBox);
			this->Controls->Add(this->出生日期DateTimePicker);
			this->Controls->Add(this->个人描述TextBox);
			this->Controls->Add(所在部门Label);
			this->Controls->Add(主要职务Label);
			this->Controls->Add(办公电话Label);
			this->Controls->Add(移动电话Label);
			this->Controls->Add(家庭电话Label);
			this->Controls->Add(电子信箱Label);
			this->Controls->Add(家庭地址Label);
			this->Controls->Add(出生日期Label);
			this->Controls->Add(个人描述Label);
			this->Controls->Add(this->客户代表DataGridView);
			this->Controls->Add(this->客户代表BindingNavigator);
			this->Name = L"CommissaryForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"客户代表管理";
			this->Load += gcnew System::EventHandler(this, &CommissaryForm::CommissaryForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyCRMDataSet))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->客户代表BindingSource))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->客户代表DataGridView))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->客户代表BindingNavigator))->EndInit();
			this->客户代表BindingNavigator->ResumeLayout(false);
			this->客户代表BindingNavigator->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
		public: static String^ My客户名称 = "";
		private: static String^ MyCRMConnectionString= L"Data Source=.;Initial Catalog=MyCRM;Integrated Security=True;Pooling=False";
		private: System::Void 客户代表BindingNavigatorSaveItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 this->Validate();
			 this->客户代表BindingSource->EndEdit();
			 this->客户代表TableAdapter->Update(this->MyCRMDataSet->客户代表);
		 }
		private: System::Void CommissaryForm_Load(System::Object^  sender, System::EventArgs^  e) {
			 // TODO: 这行代码将数据加载到表“MyCRMDataSet.客户代表”中。您可以根据需要移动或移除它。
			 //this->客户代表TableAdapter->Fill(this->MyCRMDataSet->客户代表);
			String^ MySQLConnectionString = MyCRMConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            System::Data::DataTable^ MyQueryTable = gcnew System::Data::DataTable();
            String^ MySQL = "SELECT 客户名称 FROM 客户资料";
            SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyQueryTable);
            this->客户名称ComboBox->DataSource = MyQueryTable;
            this->客户名称ComboBox->DisplayMember = "客户名称";
            this->客户名称ComboBox->ValueMember = "客户名称";
            System::Data::DataTable^ MyClientTable = gcnew System::Data::DataTable();
            MySQL = "SELECT 客户名称 FROM 客户资料";
            MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyClientTable);
            for each (DataRow^ MyRow in MyClientTable->Rows)
            {
                this->客户名称ToolStripComboBox->Items->Add(MyRow[0]->ToString());
            }
            this->客户名称ToolStripComboBox->Items->Add("%%");
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            if (this->My客户名称->Length > 1)
            {
                this->客户代表TableAdapter->FillBy(this->MyCRMDataSet->客户代表, this->My客户名称);
            }
		 }
		private: System::Void 查询ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			try
            {
                this->客户代表TableAdapter->FillBy(this->MyCRMDataSet->客户代表, 客户名称ToolStripComboBox->Text);
            }
			catch (System::Exception^ ex)
            {
				System::Windows::Forms::MessageBox::Show(ex->Message);
            }
		 }
		private: System::Void bindingNavigatorAddNewItem_MouseUp(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
           //自动计算自编号
            String^ MySQLConnectionString = MyCRMConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            SqlCommand^ MyCommand = MyConnection->CreateCommand();
            MyCommand->CommandText = "Select max(自编号) 最大编号 From 客户代表";
			System::Object^ MyResult = MyCommand->ExecuteScalar();
			System::Int64 MyID = 1;
			if (MyResult != System::DBNull::Value)
            {
                String^ MyMaxID = MyResult->ToString()->Trim();
                MyMaxID = MyMaxID->Substring(2, MyMaxID->Length - 2);
				MyID = Convert::ToInt64(MyMaxID) + 1;
            }
            int MyLength = MyID.ToString()->Length;
            String^ MyNewID = "";
            switch (MyLength)
            {
                case 1:
                    MyNewID = "DB0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "DB000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "DB00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "DB0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "DB000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "DB00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "DB0" + MyID.ToString();
                    break;
            }
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            this->自编号TextBox->Text = MyNewID;
		 }
	};
}

⌨️ 快捷键说明

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