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

📄 orgsettings.cs

📁 C#2.0宝典源码,C#经典书籍,很多例子
💻 CS
📖 第 1 页 / 共 5 页
字号:
      // 
      // txtCollegeName
      // 
      this.txtCollegeName.Location = new System.Drawing.Point(72, 49);
      this.txtCollegeName.Name = "txtCollegeName";
      this.txtCollegeName.Size = new System.Drawing.Size(104, 21);
      this.txtCollegeName.TabIndex = 7;
      this.txtCollegeName.Text = "";
      // 
      // label8
      // 
      this.label8.Location = new System.Drawing.Point(8, 24);
      this.label8.Name = "label8";
      this.label8.Size = new System.Drawing.Size(72, 16);
      this.label8.TabIndex = 8;
      this.label8.Text = "学院编号:";
      // 
      // label9
      // 
      this.label9.Location = new System.Drawing.Point(8, 53);
      this.label9.Name = "label9";
      this.label9.Size = new System.Drawing.Size(72, 16);
      this.label9.TabIndex = 9;
      this.label9.Text = "学院名称:";
      // 
      // gridCollege
      // 
      this.gridCollege.AllowSorting = false;
      this.gridCollege.CaptionVisible = false;
      this.gridCollege.DataMember = "colleges";
      this.gridCollege.DataSource = this.dataSetOrgs;
      this.gridCollege.HeaderForeColor = System.Drawing.SystemColors.ControlText;
      this.gridCollege.Location = new System.Drawing.Point(15, 15);
      this.gridCollege.Name = "gridCollege";
      this.gridCollege.ReadOnly = true;
      this.gridCollege.Size = new System.Drawing.Size(320, 289);
      this.gridCollege.TabIndex = 0;
      this.gridCollege.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
                                                                                            this.dgTableStyleCollege});
      this.gridCollege.Click += new System.EventHandler(this.gridCollege_Click);
      // 
      // dgTableStyleCollege
      // 
      this.dgTableStyleCollege.AllowSorting = false;
      this.dgTableStyleCollege.DataGrid = this.gridCollege;
      this.dgTableStyleCollege.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
                                                                                                          this.dataGridTextBoxColumn9,
                                                                                                          this.dataGridTextBoxColumn10});
      this.dgTableStyleCollege.HeaderForeColor = System.Drawing.SystemColors.ControlText;
      this.dgTableStyleCollege.MappingName = "colleges";
      // 
      // dataGridTextBoxColumn9
      // 
      this.dataGridTextBoxColumn9.Format = "";
      this.dataGridTextBoxColumn9.FormatInfo = null;
      this.dataGridTextBoxColumn9.HeaderText = "学院编号";
      this.dataGridTextBoxColumn9.MappingName = "college_ID";
      this.dataGridTextBoxColumn9.Width = 75;
      // 
      // dataGridTextBoxColumn10
      // 
      this.dataGridTextBoxColumn10.Format = "";
      this.dataGridTextBoxColumn10.FormatInfo = null;
      this.dataGridTextBoxColumn10.HeaderText = "学院名称";
      this.dataGridTextBoxColumn10.MappingName = "college_name";
      this.dataGridTextBoxColumn10.Width = 120;
      // 
      // btnCancel
      // 
      this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
      this.btnCancel.Location = new System.Drawing.Point(484, 360);
      this.btnCancel.Name = "btnCancel";
      this.btnCancel.Size = new System.Drawing.Size(75, 24);
      this.btnCancel.TabIndex = 2;
      this.btnCancel.Text = "关闭";
      this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
      // 
      // linkAddClass
      // 
      this.linkAddClass.BackColor = System.Drawing.Color.Transparent;
      this.linkAddClass.Location = new System.Drawing.Point(9, 181);
      this.linkAddClass.Name = "linkAddClass";
      this.linkAddClass.TabIndex = 16;
      this.linkAddClass.TabStop = true;
      this.linkAddClass.Text = "新建班级";
      this.linkAddClass.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkAddClass_LinkClicked);
      // 
      // linkAddSpeciality
      // 
      this.linkAddSpeciality.BackColor = System.Drawing.Color.Transparent;
      this.linkAddSpeciality.Location = new System.Drawing.Point(8, 144);
      this.linkAddSpeciality.Name = "linkAddSpeciality";
      this.linkAddSpeciality.Size = new System.Drawing.Size(100, 16);
      this.linkAddSpeciality.TabIndex = 14;
      this.linkAddSpeciality.TabStop = true;
      this.linkAddSpeciality.Text = "新建专业";
      this.linkAddSpeciality.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkAddSpeciality_LinkClicked);
      // 
      // linkAddCollege
      // 
      this.linkAddCollege.BackColor = System.Drawing.Color.Transparent;
      this.linkAddCollege.Location = new System.Drawing.Point(8, 112);
      this.linkAddCollege.Name = "linkAddCollege";
      this.linkAddCollege.Size = new System.Drawing.Size(72, 24);
      this.linkAddCollege.TabIndex = 13;
      this.linkAddCollege.TabStop = true;
      this.linkAddCollege.Text = "新建学院";
      this.linkAddCollege.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkAddCollege_LinkClicked);
      // 
      // OrgSettings
      // 
      this.AcceptButton = this.btnCancel;
      this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
      this.ClientSize = new System.Drawing.Size(570, 400);
      this.Controls.Add(this.btnCancel);
      this.Controls.Add(this.tabControl1);
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
      this.HelpButton = true;
      this.MaximizeBox = false;
      this.MinimizeBox = false;
      this.Name = "OrgSettings";
      this.ShowInTaskbar = false;
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
      this.Text = "组织机构设置";
      this.tabControl1.ResumeLayout(false);
      this.tabPage1.ResumeLayout(false);
      this.groupBox1.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.dataSetOrgs)).EndInit();
      this.groupBox2.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.gridClass)).EndInit();
      this.tabPage2.ResumeLayout(false);
      this.groupBox4.ResumeLayout(false);
      this.groupBox3.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.gridSpeciality)).EndInit();
      this.tabPage3.ResumeLayout(false);
      this.groupBox6.ResumeLayout(false);
      this.groupBox5.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.gridCollege)).EndInit();
      this.ResumeLayout(false);

    }
		#endregion

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

    private void btnSerchClass_Click(object sender, System.EventArgs e)
    {
      if(txtSearchValueClass.Text.Trim() == "")
      {
        MessageBox.Show("请先输入要查找的值!");
        txtSearchValueClass.Focus();
        return;
      }
      else if(cmbSearchTypeClass.Text.Trim() == "按照编号")
      {
        DataGrid_SearchKey(gridClass,dataSetOrgs.classes,"class_ID",txtSearchValueClass.Text.Trim());
      }
      else if(cmbSearchTypeClass.Text.Trim() == "按照名称")
      {
        DataGrid_SearchKey(gridClass,dataSetOrgs.classes,"class_name",txtSearchValueClass.Text.Trim());
      }
      BindClassInfo();
    }

    private void btnSearchSpeciality_Click(object sender, System.EventArgs e)
    {
      if(txtSearchSpeciality.Text.Trim() == "")
      {
        MessageBox.Show("请先输入要查找的值!");
        txtSearchSpeciality.Focus();
        return;
      }
      else if(cmbSearchSpeciality.Text.Trim() == "按照编号")
      {
        DataGrid_SearchKey(gridSpeciality,dataSetOrgs.speciality,"speciality_ID",txtSearchSpeciality.Text.Trim());
      }
      else if(cmbSearchSpeciality.Text.Trim() == "按照名称")
      {
        DataGrid_SearchKey(gridSpeciality,dataSetOrgs.speciality,"speciality_name",txtSearchSpeciality.Text.Trim());
      }
      BindSpecialityInfo();
    }

    private void btnSearchCollege_Click(object sender, System.EventArgs e)
    {
      if(txtSearchCollege.Text.Trim() == "")
      {
        MessageBox.Show("请先输入要查找的值!");
        txtSearchCollege.Focus();
        return;
      }
      else if(cmbSearchCollege.Text.Trim() == "按照编号")
      {
        DataGrid_SearchKey(gridCollege,dataSetOrgs.colleges,"college_ID",txtSearchCollege.Text.Trim());
      }
      else if(cmbSearchCollege.Text.Trim() == "按照名称")
      {
        DataGrid_SearchKey(gridCollege,dataSetOrgs.colleges,"college_name",txtSearchCollege.Text.Trim());
      }
      BindCollegeInfo();
    }
    


    /// <summary>
    /// 一个方法,用于查找并选择DataGrid中的某项,并选中此项。
    /// </summary>
    /// <param name="dg">被操作的DataGrid</param>
    /// <param name="dt">dg的数据表DataTable</param>
    /// <param name="ColumnName">列名,将在此列中查找</param>
    /// <param name="Value">要在列中查找的值</param>
    private void DataGrid_SearchKey(DataGrid dg, DataTable dt, string ColumnName, string Value)
    {
      for(int i=0;i<dt.Rows.Count;i++)
      {
        if(dt.Rows[i][ColumnName].ToString() == Value)
        {
          DataGrid_UnselectAll(dg,dt);
          dg.CurrentRowIndex = i;
          dg.Select(i);
          return;
        }
      }
      MessageBox.Show("索引已到数组的末尾,没有查找到符合要求的内容。");
    }

    /// <summary>
    /// 一个方法,用于取消DataGrid中所有已选择的项。
    /// </summary>
    /// <param name="dg">取消操作的对象</param>
    /// <param name="dt">dg的数据源DataTable</param>
    private void DataGrid_UnselectAll(DataGrid dg,DataTable dt)
    {
      for(int i=0;i<dt.Rows.Count;i++)
      {
        dg.UnSelect(i);
      }
    }

    private void btnInsertCollege_Click(object sender, System.EventArgs e)
    {
      if(this.CollegeInfoValidated)
      {
        try
        {
          switch(managerCol.Insert(txtCollegeID.Text.Trim(),txtCollegeName.Text.Trim()))
          {
            case 0 : MessageBox.Show("此学院编号已经有纪录存在,不能重复。");break;
            case 1 : MessageBox.Show("此学院名称已经有纪录存在,不能重复。");break;
            case 2 : Bind_gridCollege();break;
          }
        }
        catch(Exception e1)
        {
          MessageBox.Show(e1.Message);
        }
      }
    }

    private void btnUpdateCollege_Click(object sender, System.EventArgs e)
    {
      if(this.CollegeInfoValidated)
      {
        try
        {
          if(managerCol.Update(txtCollegeID.Text.Trim(),txtCollegeName.Text.Trim())==0)
            MessageBox.Show("此学院名称已经有纪录存在,不能重复。");
          else
            Bind_gridCollege();
        }
        catch(Exception e1)
        {
          MessageBox.Show(e1.Message);
        }
      }
    }

    private void btnDeleteCollege_Click(object sender, System.EventArgs e)
    {
      if(this.CollegeInfoValidated)
      {
        DialogResult result = MessageBox.Show("确定要删除此行纪录吗?","删除确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
        if(result == DialogResult.OK)

⌨️ 快捷键说明

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