using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using CoreFS.CA06; using System.Windows.Forms; namespace Core.LgMes.Client.LgJobMgt { public partial class frmClassSelect : Form { public frmClassSelect(string szCLH, string DutyID) { InitializeComponent(); //this._szGDH = szGDH; this._szJRCLH = szCLH; this._dutyID = DutyID; SetComboBoxDataSource(); SetComboBoxValue(DutyID); SetComoboVisible(); } #region " Variable" private string _szJRCLH = ""; public string _dutyID = ""; public bool _changeFlag = false; #endregion #region private void SetComboBoxDataSource() { this.comboBox1.DataSource = BuildClassTable(); this.comboBox1.DisplayMember = "name"; this.comboBox1.ValueMember = "id"; this.comboBox2.DataSource = BuildGroupTable(); this.comboBox2.DisplayMember = "name"; this.comboBox2.ValueMember = "id"; } private DataTable BuildClassTable() { DataTable dt = new DataTable(); DataColumn dc = new DataColumn("id", typeof(System.String)); dt.Columns.Add(dc); dc = new DataColumn("name", typeof(System.String)); dt.Columns.Add(dc); DataRow dr = dt.NewRow(); dr[0] = "0"; dr[1] = ""; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "2"; dr[1] = "早"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "3"; dr[1] = "中"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "1"; dr[1] = "晚"; dt.Rows.Add(dr); dt.AcceptChanges(); return dt; } private DataTable BuildGroupTable() { DataTable dt = new DataTable(); DataColumn dc = new DataColumn("id", typeof(System.String)); dt.Columns.Add(dc); dc = new DataColumn("name", typeof(System.String)); dt.Columns.Add(dc); DataRow dr = dt.NewRow(); dr[0] = "0"; dr[1] = ""; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "1"; dr[1] = "甲"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "2"; dr[1] = "乙"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "3"; dr[1] = "丙"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "4"; dr[1] = "丁"; dt.Rows.Add(dr); dt.AcceptChanges(); return dt; } #endregion private void SetComboBoxValue(string strDutyID) { if (strDutyID.Length == 2) { string str1 = strDutyID.Substring(0, 1); string str2 = strDutyID.Substring(1, 1); this.comboBox1.Value = str1; this.comboBox2.Value = str2; } } private void SetComoboVisible() { this.comboBox1.DisplayLayout.Bands[0].Columns["id"].Hidden = true; this.comboBox2.DisplayLayout.Bands[0].Columns["id"].Hidden = true; this.comboBox1.DisplayLayout.Bands[0].Columns["id"].Band.ColHeadersVisible = false; this.comboBox2.DisplayLayout.Bands[0].Columns["id"].Band.ColHeadersVisible = false; this.comboBox1.DisplayLayout.Bands[0].Columns["name"].Width = this.comboBox1.Width; this.comboBox2.DisplayLayout.Bands[0].Columns["name"].Width = this.comboBox2.Width; } private void button1_Click(object sender, System.EventArgs e) { if (this.comboBox1.Value == null || this.comboBox2.Value == null) { this.Close(); return; } string str = this.comboBox1.Value.ToString() + this.comboBox2.Value.ToString(); if (str == "") { this.Close(); return; } if (str == _dutyID) { _changeFlag = false; } else { _changeFlag = true; } _dutyID = str; this.Close(); } } }