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

📄 副本 addupdateform.cs

📁 《数据库原理及应用》-刘玉宝主编-源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(72, 23);
			this.label12.TabIndex = 31;
			this.label12.Text = "立项日期:";
			this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label13
			// 
			this.label13.Location = new System.Drawing.Point(624, 272);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(72, 23);
			this.label13.TabIndex = 32;
			this.label13.Text = "结项日期:";
			this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label14
			// 
			this.label14.Location = new System.Drawing.Point(624, 312);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(72, 23);
			this.label14.TabIndex = 33;
			this.label14.Text = "经费标准:";
			this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label15
			// 
			this.label15.Location = new System.Drawing.Point(624, 344);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(72, 23);
			this.label15.TabIndex = 34;
			this.label15.Text = "已拨经费:";
			this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label16
			// 
			this.label16.Location = new System.Drawing.Point(624, 376);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(72, 23);
			this.label16.TabIndex = 35;
			this.label16.Text = "剩余经费:";
			this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label17
			// 
			this.label17.Location = new System.Drawing.Point(16, 56);
			this.label17.Name = "label17";
			this.label17.Size = new System.Drawing.Size(72, 23);
			this.label17.TabIndex = 36;
			this.label17.Text = "所属院系:";
			this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label26
			// 
			this.label26.Location = new System.Drawing.Point(16, 96);
			this.label26.Name = "label26";
			this.label26.Size = new System.Drawing.Size(72, 23);
			this.label26.TabIndex = 37;
			this.label26.Text = "联系电话:";
			this.label26.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label27
			// 
			this.label27.Location = new System.Drawing.Point(16, 136);
			this.label27.Name = "label27";
			this.label27.Size = new System.Drawing.Size(72, 23);
			this.label27.TabIndex = 38;
			this.label27.Text = " E-Mail :";
			this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label28
			// 
			this.label28.Location = new System.Drawing.Point(248, 56);
			this.label28.Name = "label28";
			this.label28.Size = new System.Drawing.Size(56, 23);
			this.label28.TabIndex = 39;
			this.label28.Text = "备  注:";
			this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// tbStart
			// 
			this.tbStart.Location = new System.Drawing.Point(696, 208);
			this.tbStart.Name = "tbStart";
			this.tbStart.Size = new System.Drawing.Size(128, 21);
			this.tbStart.TabIndex = 9;
			this.tbStart.Text = "";
			// 
			// tbPlan
			// 
			this.tbPlan.Location = new System.Drawing.Point(696, 240);
			this.tbPlan.Name = "tbPlan";
			this.tbPlan.Size = new System.Drawing.Size(128, 21);
			this.tbPlan.TabIndex = 10;
			this.tbPlan.Text = "";
			// 
			// tbEnd
			// 
			this.tbEnd.Location = new System.Drawing.Point(696, 272);
			this.tbEnd.Name = "tbEnd";
			this.tbEnd.Size = new System.Drawing.Size(128, 21);
			this.tbEnd.TabIndex = 11;
			this.tbEnd.Text = "";
			// 
			// AddUpdateForm
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(840, 469);
			this.Controls.Add(this.tbEnd);
			this.Controls.Add(this.tbPlan);
			this.Controls.Add(this.tbStart);
			this.Controls.Add(this.tbRemark);
			this.Controls.Add(this.label28);
			this.Controls.Add(this.label27);
			this.Controls.Add(this.label26);
			this.Controls.Add(this.label17);
			this.Controls.Add(this.label16);
			this.Controls.Add(this.label15);
			this.Controls.Add(this.label14);
			this.Controls.Add(this.label13);
			this.Controls.Add(this.label12);
			this.Controls.Add(this.cmbCollege);
			this.Controls.Add(this.tbEmail);
			this.Controls.Add(this.tbTel);
			this.Controls.Add(this.nudSurplus);
			this.Controls.Add(this.nudAlready);
			this.Controls.Add(this.nudStandard);
			this.Controls.Add(this.lbLevelCo);
			this.Controls.Add(this.lbSortCo);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.grbMember);
			this.Controls.Add(this.tbTaskName);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.dtpYear);
			this.Controls.Add(this.cmbLevelNa);
			this.Controls.Add(this.cmbSortNa);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.grbTaskCo);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "AddUpdateForm";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "AddUpdateForm";
			this.Load += new System.EventHandler(this.AddUpdateForm_Load);
			this.grbMember.ResumeLayout(false);
			this.panelMember.ResumeLayout(false);
			this.grbTaskCo.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.nudStandard)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nudAlready)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nudSurplus)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void AddUpdateForm_Load(object sender, System.EventArgs e)
		{
            this.ReadSort();
			this.ReadLevel();
			this.ReadCollege();
			this.AddParameters();

			this.DataShow();
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if(this.cmbSortNa.SelectedIndex < 1)
			{
				MessageBox.Show("请选择分类!", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			
			if(this.cmbLevelNa.SelectedIndex < 1)
			{
				MessageBox.Show("请选择级别!", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			
			if(this.cmbCollege.SelectedIndex < 1)
			{
				MessageBox.Show("请选择所属院系!", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			
			this.tbTaskName.Text = this.tbTaskName.Text.Trim();
			if(this.tbTaskName.Text == "")
			{
				MessageBox.Show("请输入课题名称!", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}

			this.UpdateTask();
		}

		private void UpdateTask()
		{
			try
			{
				this.sqlConnection.Open();

				this.SetParametersValue();
				this.storedProcedure.ExecuteNonQuery();

				this.newTaskArrayList.Add(this.storedProcedure.Parameters["@TaskID"].Value);

				MessageBox.Show(this.Text + "成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

				if(this.btnOK.Text == "修    改")
				{
					this.dataRow.Delete();
					this.Close();
				}
				else
				{
					this.ResetDataBind();
				}
			}
			catch(Exception caught)
			{
				MessageBox.Show(caught.Message);
			}
			finally
			{
				this.sqlConnection.Close();
			}
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		#region /* 从数据库表中读取“分类信息”、“级别信息”、“院系信息”、“成员信息” */
		/// <summary>
		/// 读取分类信息。
		/// </summary>
		private void ReadSort()
		{
			string selectStr = "select SortCo, SortNa from Sort order by SortNa";

			this.ResetLC(this.lbSortCo, this.cmbSortNa, "请选择分类", "…… 新增分类 ……");
			this.ReadLC(this.lbSortCo, this.cmbSortNa, selectStr);
		}

		/// <summary>
		/// 读取级别信息。
		/// </summary>
		private void ReadLevel()
		{
			string selectStr = "select LevelCo, LevelNa from Level order by LevelNa";

			this.ResetLC(this.lbLevelCo, this.cmbLevelNa, "请选择级别", "…… 新增级别 ……");
			this.ReadLC(this.lbLevelCo, this.cmbLevelNa, selectStr);
		}

		/// <summary>
		/// 读取院系信息。
		/// </summary>
		private void ReadCollege()
		{
			string selectStr = "select CollegeCo, CollegeNa from College order by CollegeNa";

			this.ResetLC(this.lbCollegeCo, this.cmbCollegeNa, "请选择院系", "…… 新增院系 ……");
			this.ReadLC(this.lbCollegeCo, this.cmbCollegeNa, selectStr);

			this.cmbCollege.Items.Clear();
			for(int i = 0; i < this.cmbCollegeNa.Items.Count; i++)
			{
				this.cmbCollege.Items.Add(this.cmbCollegeNa.Items[i]);
			}
			this.cmbCollege.SelectedIndex = 0;
		}

		/// <summary>
		/// 读取成员信息。
		/// </summary>
		private void ReadMember()
		{
			int collegeCo = Convert.ToInt32(this.lbCollegeCo.Items[this.cmbCollegeNa.SelectedIndex]);
			string selectStr = "select MemberCo, MemberNa from Member where CollegeCo = " + collegeCo + " order by MemberNa";

			this.ResetLC(this.lbMemberCo, this.cmbMemberNa, "请选择成员", "… 新增成员 …");
			this.ReadLC(this.lbMemberCo, this.cmbMemberNa, selectStr);
		}

		private void cmbSortNa_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			if(this.cmbSortNa.SelectedIndex == (this.cmbSortNa.Items.Count - 1))	//选择“新增分类”
			{
				ArrayList array = null;
				//调用新增分类窗体f
				addSort addSortForm = new addSort();
				addSortForm.Connection = this.sqlConnection;
				addSortForm.ShowDialog();
				//array = f.GetArrayList();
				array = addSortForm.GetArrayList();
				if(array != null)
				{
					this.lbSortCo.Items.Insert(1, array[0]);
					this.cmbSortNa.Items.Insert(1, array[1]);

					this.cmbSortNa.SelectedIndex = 1;
				}
				else
				{
					int sortCo = Convert.ToInt32(this.cmbSortNa.Tag);
					this.cmbSortNa.SelectedIndex = this.lbSortCo.Items.IndexOf(sortCo);

					return;
				}
			}

			this.cmbSortNa.Tag = this.lbSortCo.Items[this.cmbSortNa.SelectedIndex];
		}

		private void cmbLevelNa_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			if(this.cmbLevelNa.SelectedIndex == (this.cmbLevelNa.Items.Count - 1))	//选择“新增级别”
			{
				ArrayList array = null;
				//调用新增级别窗体f
				AddLevel addLevelForm = new AddLevel();
				addLevelForm.Connection = this.sqlConnection;
				addLevelForm.ShowDialog();
				//array = f.GetArrayList();
				array = addLevelForm.GetArrayList();
				if(array != null)
				{
					this.lbLevelCo.Items.Insert(1, array[0]);
					this.cmbLevelNa.Items.Insert(1, array[1]);

					this.cmbLevelNa.SelectedIndex = 1;
				}
				else
				{
					int levelCo = Convert.ToInt32(this.cmbLevelNa.Tag);
					this.cmbLevelNa.SelectedIndex = this.lbLevelCo.Items.IndexOf(levelCo);

					return;
				}
			}

			this.cmbLevelNa.Tag = this.lbLevelCo.Items[this.cmbLevelNa.SelectedIndex];
		}

⌨️ 快捷键说明

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