예제 #1
0
        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;
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        private void btnInstructionSave_Click(object sender, EventArgs e)
        {
            if (lsbCreateEqpType.SelectedIndex < 0 ||
                lsbCreateEqpSupplier.SelectedIndex < 0 ||
                lsbCreateCommandType.SelectedIndex < 0 ||
                lsbCreateCommand.SelectedIndex < 0
                )
            {
                MessageBox.Show(@"Missing condition ""Equipment Type"" ""Supplier"" ""Command Type"" ""Command"".", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }

            if (txbParameterID.Text.Trim().Equals(string.Empty))
            {
                //MessageBox.Show("Missing Parameter ID.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                //return;
                txbParameterID.Text = "Null";
            }

            if (!rdbEditorParameterData.Checked)
            {
                if (!(txbParameterID.Text.Trim().Equals("Null")) && (nudMAXValue.Value == nudMINValue.Value))
                {
                    MessageBox.Show("Max value = Min value.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    return;
                }
            }

            if (!(txbParameterID.Text.Trim().Equals("Null")) && ((nudDefaultValue.Value > nudMAXValue.Value) || (nudDefaultValue.Value < nudMINValue.Value)))
            {
                MessageBox.Show("Default value > Max value or Default value < Min value.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }

            if (strCommandFormat.Equals(string.Empty))
            {
                MessageBox.Show("Command format error.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }

            DataRow drTemp;

            DataRow[] drsTemp;
            DataTable dtTemp;
            Int32     itCommandParameterCount = 0;
            Int32     itCommandCount          = 0;

            SANWA.Utility.ContainerSet containerSet;
            DataView dvTemp;

            try
            {
                containerSet = new SANWA.Utility.ContainerSet();

                drsTemp = dtParameterList.Select("Equipment_Type = '" + lsbCreateEqpType.Text + "' AND " +
                                                 "Equipment_Supplier = '" + lsbCreateEqpSupplier.Text + "' AND " +
                                                 "Command_Type = '" + lsbCreateCommandType.Text + "' AND " +
                                                 "Command_ID = '" + lsbCreateCommand.Text + "' AND " +
                                                 "Parameter_ID = '" + txbParameterID.Text + "'"
                                                 );

                if (drsTemp.Length > 0)
                {
                    MessageBox.Show("Repeat Parameter.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    return;
                }

                drsTemp = dtParameterList.Select("Equipment_Type = '" + lsbCreateEqpType.Text + "' AND " +
                                                 "Equipment_Supplier = '" + lsbCreateEqpSupplier.Text + "' AND " +
                                                 "Command_Type = '" + lsbCreateCommandType.Text + "' AND " +
                                                 "Command_ID = '" + lsbCreateCommand.Text + "' AND " +
                                                 "Parameter_Order = '" + nudParameterOrder.Value.ToString() + "' AND " +
                                                 "Parameter_ID = '" + txbParameterID.Text + "'"
                                                 );

                if (drsTemp.Length > 0)
                {
                    drsTemp[0]["Parameter_Description"] = txbParameterDescription.Text.Trim();

                    if (rdbEditorParameterData.Checked || txbParameterID.Text.Equals("Null"))
                    {
                        drsTemp[0]["Data_Value"]    = txbEditorParameterData.Text.Trim();
                        drsTemp[0]["Min_Value"]     = string.Empty;
                        drsTemp[0]["Max_Value"]     = string.Empty;
                        drsTemp[0]["Default_Value"] = string.Empty;
                        drsTemp[0]["Values_length"] = string.Empty;
                        drsTemp[0]["Is_Fill"]       = string.Empty;
                    }
                    else if (rdbEditorParameterValue.Checked)
                    {
                        drsTemp[0]["Data_Value"]    = string.Empty;
                        drsTemp[0]["Min_Value"]     = nudMINValue.Value.ToString();
                        drsTemp[0]["Max_Value"]     = nudMAXValue.Value.ToString();
                        drsTemp[0]["Default_Value"] = nudDefaultValue.Value.ToString();
                        drsTemp[0]["Values_length"] = nudValueLength.Value.ToString();
                        drsTemp[0]["Is_Fill"]       = chbIsFill.Checked ? "Y" : "N";
                    }
                }
                else
                {
                    itCommandParameterCount = dtParameterList.Select("Equipment_Type = '" + lsbCreateEqpType.Text + "' AND " +
                                                                     "Equipment_Supplier = '" + lsbCreateEqpSupplier.Text + "' AND " +
                                                                     "Command_Type = '" + lsbCreateCommandType.Text + "' AND " +
                                                                     "Command_ID = '" + lsbCreateCommand.Text + "'"
                                                                     ).Length;

                    dvTemp           = new DataView(dtParameterList);
                    dvTemp.RowFilter = "Equipment_Type = '" + lsbCreateEqpType.Text + "' AND " +
                                       "Equipment_Supplier = '" + lsbCreateEqpSupplier.Text + "' AND " +
                                       "Command_Type = '" + lsbCreateCommandType.Text + "'";
                    dtTemp = dvTemp.ToTable(true, new string[] { "Equipment_Type", "Equipment_Supplier", "Command_Type", "Command_ID", "Command_Order" });


                    if (dtTemp.Rows.Count == 0 || Convert.ToInt32(dtTemp.Compute("max(Command_Order)", string.Empty)) == 0)
                    {
                        itCommandCount = 1;
                    }
                    else if (dtTemp.Select("Command_ID = '" + lsbCreateCommand.Text + "'").Length == 0)
                    {
                        itCommandCount = Convert.ToInt32(dtTemp.Compute("max(Command_Order)", string.Empty)) + 1;
                    }
                    else
                    {
                        itCommandCount = Convert.ToInt32(dtTemp.Compute("max(Command_Order)", string.Empty));
                    }


                    drTemp = dtParameterList.NewRow();
                    drTemp["Equipment_Type"]     = lsbCreateEqpType.Text;
                    drTemp["Equipment_Supplier"] = lsbCreateEqpSupplier.Text;
                    drTemp["Command_Type"]       = lsbCreateCommandType.Text;
                    drTemp["Command_ID"]         = lsbCreateCommand.Text;

                    switch (lsbCreateEqpSupplier.Text.ToUpper())
                    {
                    case "SANWA":
                        drTemp["Command_Format"] = string.Format(strCommandFormat, "{0}", "{1}", lsbCreateCommandType.Text, lsbCreateCommand.Text);
                        break;

                    case "KAWASAKI":
                        drTemp["Command_Format"] = string.Format(strCommandFormat, lsbCreateCommand.Text + "{0}", "{1}");
                        break;

                    case "TDK":
                        drTemp["Command_Format"] = string.Format(strCommandFormat, lsbCreateCommandType.Text, lsbCreateCommand.Text);
                        break;
                    }

                    drTemp["Command_Name"]      = lsbCreateCommand.SelectedValue;
                    drTemp["Command_Order"]     = itCommandCount.ToString("D2");
                    drTemp["Parameters_Amount"] = (itCommandParameterCount + 1).ToString("D2");
                    drTemp["Parameter_Order"]   = Convert.ToInt32(nudParameterOrder.Value).ToString("D2");

                    drTemp["Parameter_ID"]          = txbParameterID.Text.Trim();
                    drTemp["Parameter_Description"] = txbParameterDescription.Text.Trim();

                    if (rdbEditorParameterData.Checked || txbParameterID.Text.Equals("Null"))
                    {
                        drTemp["Data_Value"]    = txbEditorParameterData.Text.Trim();
                        drTemp["Min_Value"]     = string.Empty;
                        drTemp["Max_Value"]     = string.Empty;
                        drTemp["Default_Value"] = string.Empty;
                        drTemp["Values_length"] = string.Empty;
                        drTemp["Is_Fill"]       = string.Empty;
                    }
                    else if (rdbEditorParameterValue.Checked)
                    {
                        drTemp["Data_Value"]    = string.Empty;
                        drTemp["Min_Value"]     = nudMINValue.Value.ToString();
                        drTemp["Max_Value"]     = nudMAXValue.Value.ToString();
                        drTemp["Default_Value"] = nudDefaultValue.Value.ToString();
                        drTemp["Values_length"] = nudValueLength.Value.ToString();
                        drTemp["Is_Fill"]       = chbIsFill.Checked ? "Y" : "N";
                    }
                    else
                    {
                        drTemp["Data_Value"]    = string.Empty;
                        drTemp["Min_Value"]     = string.Empty;
                        drTemp["Max_Value"]     = string.Empty;
                        drTemp["Default_Value"] = string.Empty;
                        drTemp["Values_length"] = string.Empty;
                        drTemp["Is_Fill"]       = string.Empty;
                    }

                    drTemp["Action_Function"] = cmbCommandAction.Text;
                    dtParameterList.Rows.Add(drTemp);
                }

                dtParameterList.WriteXml(System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml");
                containerSet.TableFormatting(ref dtParameterList, System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml");

                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;

                MessageBox.Show("Save Done.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

                lsbCreateEqpType_Click(this, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
            }
        }