private void frmInstructionEditor_Load(object sender, EventArgs e) { SANWA.Utility.Controlling controlling; SANWA.Utility.ContainerSet container; DataView dvTemp; try { controlling = new SANWA.Utility.Controlling(); container = new SANWA.Utility.ContainerSet(); strsEquipmentType = Properties.Settings.Default.EquipmentType.Cast <string>().ToArray(); strsCommandType = Properties.Settings.Default.CommandType.Cast <string>().ToArray(); strsEquipment_Supplier = Properties.Settings.Default.Equipment_Supplier.Cast <string>().ToArray(); strsCommand_Parameter_Columns = Properties.Settings.Default.Command_Parameter_Columns.Cast <string>().ToArray(); //controlling.ListBox_ItemChange(ref lsbCreateCommandType, strsCommandType); //controlling.ListBox_ItemChange(ref lsbCreateEqpSupplier, strsEquipment_Supplier); //controlling.ListBox_ItemChange(ref lsbCreateEqpType, strsEquipmentType); if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml")) { container.TableFormatting(ref dtParameterList, System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml"); } else { container.TableFormatting(ref dtParameterList, "Table", strsCommand_Parameter_Columns); } if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml")) { container.TableFormatting(ref dtCode, System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml"); } if (dtCode.Rows.Count > 0) { dvTemp = new DataView(dtCode); dvTemp.RowFilter = "Category_ID = 'System'"; controlling.ListBox_ItemChange(ref lsbCreateEqpType, dvTemp.ToTable().Copy().Select("Code_Type = 'EquipmentType'"), "Code_ID", "Code_ID"); lsbCreateEqpType.SelectedIndex = -1; controlling.ListBox_ItemChange(ref lsbCreateEqpSupplier, dvTemp.ToTable().Copy().Select("Code_Type = 'EquipmentSupplier'"), "Code_ID", "Code_ID"); lsbCreateEqpSupplier.SelectedIndex = -1; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); } finally { controlling = null; container = null; } }
private void frmCodeManager_Load(object sender, EventArgs e) { SANWA.Utility.Controlling controlling; SANWA.Utility.ContainerSet containerSet; try { controlling = new SANWA.Utility.Controlling(); containerSet = new SANWA.Utility.ContainerSet(); dtCode = new DataTable(); dtCategory = new DataTable(); strColumsn = Properties.Settings.Default.Code_Columns.Cast <string>().ToArray(); strCategory = Properties.Settings.Default.Category.Cast <string>().ToArray(); if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml")) { containerSet.TableFormatting(ref dtCode, System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml"); } else { containerSet.TableFormatting(ref dtCode, "Table", strCategory); } containerSet.TableFormatting(ref dtCategory, "Table", new string[] { "ID", "NAME" }); foreach (string item in strCategory) { if (string.IsNullOrEmpty(item.Trim())) { continue; } dtCategory.Rows.Add(item.Split(',')); } controlling.ListBox_ItemChange(ref lsbQueryCondition, dtCategory.Select(), "ID", "NAME"); controlling.ListBox_ItemChange(ref lsbEditorCategoryID, dtCategory.Select(), "ID", "NAME"); lsbQueryCondition.SelectedIndex = -1; lsbEditorCategoryID.SelectedIndex = -1; txbEditorCategoryName.Text = string.Empty; txbQueryCategoryName.Text = string.Empty; dgvCode.DataSource = dtCode; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); } finally { controlling = null; containerSet = null; } }
private void lsbCreateCommand_Click(object sender, EventArgs e) { SANWA.Utility.Controlling controlling; try { lsbCreateCommandParameter.DataSource = null; if (dtParameterList.Rows.Count == 0) { nudParameterOrder.Value = 1; return; } controlling = new SANWA.Utility.Controlling(); var query = (from a in dtParameterList.AsEnumerable() where a.Field <string>("Equipment_Type") == lsbCreateEqpType.Text && a.Field <string>("Equipment_Supplier") == lsbCreateEqpSupplier.Text && a.Field <string>("Command_Type") == lsbCreateCommandType.Text && a.Field <string>("Command_ID") == lsbCreateCommand.Text select a).ToList(); if (query.Count > 0) { controlling.ListBox_ItemChange(ref lsbCreateCommandParameter, query.CopyToDataTable().Select(), "Parameter_ID", "Parameter_ID"); nudParameterOrder.Value = Convert.ToInt32(query.CopyToDataTable().Rows[query.CopyToDataTable().Rows.Count - 1]["Parameter_Order"].ToString()) + 1; lsbCreateCommandParameter.SelectedIndex = -1; } else { nudParameterOrder.Value = 1; } txbParameterID.Text = string.Empty; txbParameterDescription.Text = string.Empty; txbEditorParameterData.Text = string.Empty; nudMAXValue.Value = 0; nudMINValue.Value = 0; nudValueLength.Value = 0; nudDefaultValue.Value = 0; chbIsFill.Checked = false; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); } }
private void lsbQueryCondition_Click(object sender, EventArgs e) { SANWA.Utility.Controlling controlling; DataView dvTemp; DataRow[] drsTemp; ArrayList alTemp; try { if (((ListBox)sender).SelectedIndex >= 0) { switch (((ListBox)sender).Name) { case "lsbQueryCondition": txbQueryCategoryName.Text = ((ListBox)sender).SelectedValue.ToString(); if (dgvCode.DataSource != null) { dvTemp = new DataView(dtCode); dvTemp.RowFilter = "Category_ID = '" + ((ListBox)sender).Text + "'"; dgvCode.DataSource = dvTemp.ToTable(); } break; case "lsbEditorCategoryID": txbEditorCategoryName.Text = ((ListBox)sender).SelectedValue.ToString(); controlling = new SANWA.Utility.Controlling(); // * Code Type Add alTemp = new ArrayList(); drsTemp = dtCode.DefaultView.ToTable(true, new string[] { "Category_ID", "Code_Type" }).Select("Category_ID = '" + ((ListBox)sender).Text + "'"); foreach (DataRow dr in drsTemp) { alTemp.Add(dr["Code_Type"].ToString()); } controlling.ComboBox_ItemChange(ref cmdEditorCodeType, (string[])alTemp.ToArray(typeof(string))); controlling.ListBox_ItemChange(ref lsbEditorCodeType, (string[])alTemp.ToArray(typeof(string))); lsbEditorCodeList.DataSource = null; txbEditorCodeListName.Text = string.Empty; break; case "lsbEditorCodeType": // * Code List Add controlling = new SANWA.Utility.Controlling(); drsTemp = dtCode.DefaultView.ToTable(true, new string[] { "Category_ID", "Code_Type", "Code_ID", "Code_Name" }).Select("Category_ID = '" + lsbEditorCategoryID.Text + "' AND Code_Type = '" + lsbEditorCodeType.Text + "'"); controlling.ListBox_ItemChange(ref lsbEditorCodeList, drsTemp, "Code_ID", "Code_Name"); lsbEditorCodeList.SelectedIndex = -1; txbEditorCodeListName.Text = string.Empty; break; case "lsbEditorCodeList": txbEditorCodeListName.Text = ((ListBox)sender).SelectedValue.ToString(); break; } } else { txbQueryCategoryName.Text = string.Empty; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); } finally { controlling = null; } }
private void lsbCreateEqpType_Click(object sender, EventArgs e) { if (lsbCreateEqpType.SelectedIndex < 0) { lsbCreateCommandType.DataSource = null; return; } if (lsbCreateEqpSupplier.SelectedIndex < 0) { lsbCreateCommandType.DataSource = null; return; } SANWA.Utility.Controlling controlling; DataRow[] drsTemp; DataRow[] drsCode; DataView dvTemp; try { controlling = new SANWA.Utility.Controlling(); if (strEqpAssembly.Equals("")) { dvTemp = new DataView(dtCode); dvTemp.RowFilter = "Category_ID = '" + lsbCreateEqpSupplier.SelectedValue + "." + lsbCreateEqpType.SelectedValue + "'"; controlling.ListBox_ItemChange(ref lsbCreateCommandType, dvTemp.ToTable(true, new string[] { "Code_Type" }).Copy().Select(""), "Code_Type", "Code_Type"); lsbCreateCommandType.SelectedIndex = -1; strEqpAssembly = lsbCreateEqpSupplier.SelectedValue + "." + lsbCreateEqpType.SelectedValue; lsbCreateCommand.DataSource = null; return; } else if (strEqpAssembly != lsbCreateEqpSupplier.SelectedValue + "." + lsbCreateEqpType.SelectedValue) { dvTemp = new DataView(dtCode); dvTemp.RowFilter = "Category_ID = '" + lsbCreateEqpSupplier.SelectedValue + "." + lsbCreateEqpType.SelectedValue + "'"; controlling.ListBox_ItemChange(ref lsbCreateCommandType, dvTemp.ToTable(true, new string[] { "Code_Type" }).Copy().Select(""), "Code_Type", "Code_Type"); lsbCreateCommandType.SelectedIndex = -1; strEqpAssembly = lsbCreateEqpSupplier.SelectedValue + "." + lsbCreateEqpType.SelectedValue; lsbCreateCommand.DataSource = null; return; } if (lsbCreateCommandType.SelectedIndex < 0) { return; } if (lsbCreateCommandType.DataSource != null && lsbCreateCommandType.SelectedIndex >= 0) { if (dtCode.Rows.Count > 0) { drsTemp = dtCode.DefaultView.ToTable(true, new string[] { "Category_ID", "Code_Type", "Code_ID", "Code_Name" }).Select("Category_ID = '" + lsbCreateEqpSupplier.Text + "." + lsbCreateEqpType.Text + "' AND Code_Type = '" + lsbCreateCommandType.Text + "'"); controlling.ListBox_ItemChange(ref lsbCreateCommand, drsTemp, "Code_ID", "Code_Name"); lsbCreateCommand.SelectedIndex = -1; lsbCreateCommandParameter.DataSource = null; drsCode = dtCode.DefaultView.ToTable(true, new string[] { "Category_ID", "Code_Type", "Code_ID", "Code_Name" }).Select("Category_ID = 'System' AND Code_Type = '" + string.Format("{0}.Command.Format", lsbCreateEqpSupplier.Text) + "'"); if (drsCode.Length > 0) { strCommandFormat = drsCode[0]["Code_ID"].ToString(); } } else { if (((DataTable)lsbCreateCommand.DataSource) != null) { ((DataTable)lsbCreateCommand.DataSource).Clear(); ((DataTable)lsbCreateCommandParameter.DataSource).Clear(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); } }