FrmSetSteelName.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using CoreFS.CA06;
  9. using System.Collections;
  10. namespace Core.LgMes.Client.LgResMgt
  11. {
  12. public partial class FrmSetSteelName : Form
  13. {
  14. public FrmSetSteelName()
  15. {
  16. InitializeComponent();
  17. }
  18. bool aa = true;
  19. private DataTable m_dtSteelType = null, m_dtSteelName = null;
  20. public string m_szSteelName = "", m_szSteelCode = "";
  21. private void button2_Click(object sender, EventArgs e)
  22. {
  23. this.Close();
  24. this.DialogResult = DialogResult.Cancel;
  25. }
  26. private void FrmSetSteelName_Load(object sender, EventArgs e)
  27. {
  28. GetDataSource();
  29. SetSteelData();
  30. }
  31. private void GetDataSource()
  32. {
  33. string szOut = "";
  34. object ds = null;//hengxing Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "QuerySteelInfo", new object[] { }, out szOut);
  35. if (szOut == "")
  36. {
  37. ArrayList ar = ds as ArrayList;
  38. if (ar[0].ToString() != "-1")
  39. m_dtSteelName = ((DataSet)ar[0]).Tables[0]; // 钢种名称
  40. if (ar[1].ToString() != "-1")
  41. m_dtSteelType = ((DataSet)ar[1]).Tables[0]; // 钢种类型
  42. }
  43. }
  44. private void SetSteelData()
  45. {
  46. if (m_dtSteelType != null && m_dtSteelName != null)
  47. {
  48. comboBox1.DataSource = m_dtSteelType.DefaultView;
  49. comboBox1.DisplayMember = "basename";
  50. comboBox1.ValueMember = "basecode";
  51. //comboBox2.DataSource = m_dtSteelName;
  52. //comboBox2.DisplayMember = "basename";
  53. //comboBox2.ValueMember = "sortcode";
  54. //comboBox2.DisplayLayout.Bands[0].Columns["sortcode"].Hidden = true;
  55. ////comboBox2.DisplayLayout.Bands[0].Columns["CATALOGID"].Hidden = true;
  56. //comboBox2.DisplayLayout.Bands[0].Columns["basename"].Band.ColHeadersVisible = false;
  57. //comboBox2.DisplayLayout.Bands[0].Columns["basename"].Width = comboBox2.Width;
  58. aa = false;
  59. BindChange();
  60. }
  61. }
  62. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  63. {
  64. BindChange();
  65. }
  66. private void BindChange()
  67. {
  68. if (comboBox1.Text != "" && !aa)
  69. {
  70. comboBox2.Items.Clear();
  71. string strType = "";
  72. for (int j = 0; j < m_dtSteelType.Rows.Count; j++)
  73. {
  74. if (m_dtSteelType.Rows[j]["basename"].ToString() == comboBox1.Text.Trim())
  75. {
  76. strType = m_dtSteelType.Rows[j]["basecode"].ToString();
  77. j = m_dtSteelType.Rows.Count;
  78. }
  79. }
  80. if (strType != "")
  81. {
  82. for (int i = 0; i < m_dtSteelName.Rows.Count; i++)
  83. {
  84. if (m_dtSteelName.Rows[i]["catalogid"].ToString() == strType)
  85. {
  86. comboBox2.Items.Add(m_dtSteelName.Rows[i]["steel"].ToString());
  87. }
  88. }
  89. }
  90. }
  91. }
  92. private void button1_Click(object sender, EventArgs e)
  93. {
  94. m_szSteelName = comboBox2.Text.Trim();
  95. if (comboBox2.Text.Trim() != "")
  96. {
  97. foreach (DataRow r in m_dtSteelName.Rows)
  98. {
  99. if (r["STEEL"].ToString() == m_szSteelName)
  100. {
  101. m_szSteelCode = r["STEELCODE"].ToString();
  102. }
  103. }
  104. }
  105. this.DialogResult = DialogResult.OK;
  106. }
  107. }
  108. }