Exemplo n.º 1
0
        public void DisplayRefData(DataGridView dataGridExt)
        {
            ReadReferenceData();
            dataGridExt.Rows.Clear();
            foreach (string categoryName in linkedParameters.Keys)
            {
                LinkedParameter lp = linkedParameters[categoryName];

                if (null == lp.ControlField || null == lp.ControlParameter || null == lp.TableName || null == lp.DBPath)
                {
                    continue;
                }
                else if ("NULL" == lp.ControlField || "NULL" == lp.ControlParameter || "NULL" == lp.TableName || "NULL" == lp.DBPath)
                {
                    continue;
                }
                else
                {
                    string strUpdateParams = "";
                    foreach (string updateParam in lp.UpdateParameterField.Keys)
                    {
                        strUpdateParams += updateParam + ", ";
                    }
                    int rowIndex = dataGridExt.Rows.Add(lp.CategoryName, lp.ControlParameter, strUpdateParams, lp.DBPath);
                    dataGridExt.Rows[rowIndex].Tag = lp;
                }
            }
        }
Exemplo n.º 2
0
        private void ReadReferenceData()
        {
            try
            {
                string    tableName = "UI_ExternalReference";
                Recordset recordset;
                recordset = daoDB.OpenTable(tableName);

                while (!recordset.EOF)
                {
                    string controlParam = recordset.Fields["ControlParam"].Value;
                    string controlField = recordset.Fields["ControlField"].Value;
                    string categoryName = recordset.Fields["CategoryName"].Value;

                    if (!linkedParameters.ContainsKey(categoryName))
                    {
                        LinkedParameter lp = new LinkedParameter(controlParam, controlField);
                        lp.CategoryName = categoryName;
                        lp.TableName    = recordset.Fields["TableName"].Value;
                        lp.DBPath       = recordset.Fields["DBPath"].Value;

                        Dictionary <string, string> updateParams = new Dictionary <string, string>();
                        for (int i = 1; i < 6; i++)
                        {
                            var updateParam = recordset.Fields["UpdateParam" + i].Value;
                            var updateField = recordset.Fields["UpdateField" + i].Value;
                            if (!Convert.IsDBNull(updateParam) && !updateParams.ContainsKey(updateParam))
                            {
                                updateParams.Add(updateParam, updateField);
                            }
                        }
                        lp.UpdateParameterField = updateParams;

                        linkedParameters.Add(lp.CategoryName, lp);
                    }
                    recordset.MoveNext();
                }
                recordset.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to Read Data from UI_ExternalReference table: \n" + ex.Message);
                CloseDatabase();
            }
        }