Ejemplo n.º 1
0
        /// <summary>
        /// Add derivation param
        /// </summary>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ParamSearchDialog param = new ParamSearchDialog();

            if (DialogResult.OK == param.ShowDialog())
            {
                if (null == gcDerivaParam.DataSource)
                {
                    FormatDerivaParamData();
                }

                DataTable paramTable = (DataTable)gcDerivaParam.DataSource;

                for (int i = 0; i < paramTable.Rows.Count; i++)
                {
                    if (param.ParamKey == paramTable.Rows[i][BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY].ToString())
                    {
                        return;
                    }
                }

                paramTable.Rows.Add();
                paramTable.Rows[paramTable.Rows.Count - 1][BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY]  = param.ParamKey;
                paramTable.Rows[paramTable.Rows.Count - 1][BASE_PARAMETER_FIELDS.FIELD_PARAM_NAME] = param.ParamName;
                paramTable.AcceptChanges();

                for (int i = 0; i < derivaParamTable.Rows.Count; i++)
                {
                    if (param.ParamKey == derivaParamTable.Rows[i][BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY].ToString())
                    {
                        if (Convert.ToInt32(OperationAction.New) ==
                            Convert.ToInt32(derivaParamTable.Rows[i][COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION]))
                        {
                            return;
                        }
                        else
                        {
                            derivaParamTable.Rows.Remove(derivaParamTable.Rows[i]);
                            return;
                        }
                    }
                }

                Dictionary <string, string> rowData = new Dictionary <string, string>()
                {
                    { COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION, Convert.ToString((int)OperationAction.New) },
                    { BASE_PARAMETER_DERIVTION_FIELDS.FIELD_ROW_KEY, CommonUtils.GenerateNewKey(0) },
                    { BASE_PARAMETER_DERIVTION_FIELDS.FIELD_DERIVATION_KEY, _param.ParamKey },
                    { BASE_PARAMETER_DERIVTION_FIELDS.FIELD_PARAM_KEY, param.ParamKey },
                    { BASE_PARAMETER_DERIVTION_FIELDS.FIELD_PARAM_NAME, param.ParamName },
                    { COMMON_FIELDS.FIELD_COMMON_EDITOR, PropertyService.Get(PROPERTY_FIELDS.USER_NAME) }
                };

                FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref derivaParamTable, rowData);
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ParamSearchDialog param = new ParamSearchDialog();

            if (DialogResult.OK == param.ShowDialog())
            {
                if (null == gcMainParam.DataSource)
                {
                    FormatParamData();
                }

                DataTable paramTable = (DataTable)gcMainParam.DataSource;

                for (int i = 0; i < paramTable.Rows.Count; i++)
                {
                    if (param.ParamKey == paramTable.Rows[i][BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY].ToString())
                    {
                        return;
                    }
                }

                paramTable.Rows.Add(new object[] { param.ParamKey, param.ParamName });
                paramTable.AcceptChanges();

                for (int i = 0; i < mainParamTable.Rows.Count; i++)
                {
                    if (param.ParamKey == mainParamTable.Rows[i][BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY].ToString())
                    {
                        if (Convert.ToInt32(OperationAction.New) == Convert.ToInt32(mainParamTable.Rows[i][COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION]))
                        {
                            return;
                        }
                        else
                        {
                            mainParamTable.Rows.Remove(mainParamTable.Rows[i]);
                            return;
                        }
                    }
                }

                Dictionary <string, string> rowData = new Dictionary <string, string>()
                {
                    { COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION,
                      Convert.ToString((int)OperationAction.New) },
                    { EDC_MAIN_PARAM_FIELDS.FIELD_EDC_KEY, _edc.EdcKey },
                    { EDC_MAIN_PARAM_FIELDS.FIELD_PARAM_KEY, param.ParamKey }
                };

                FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref mainParamTable, rowData);
            }
        }