예제 #1
0
        private void LoadComboBox(string controlName, ComboBoxFillType comboBoxType, string filterOption)
        {
            DataTable dt = CO2EmissionUtils.GetCO2Emissions();

            if (dt != null)
            {
                Control[] collection = this.Controls.Find(controlName, false);
                if (collection.Length > 0)
                {
                    ComboBox cmbBox = collection[0] as ComboBox;
                    if (comboBoxType == ComboBoxFillType.EnergySource)
                    {
                        cmbBox.DataSource    = dt.DefaultView.ToTable(true, "EnergySource");
                        cmbBox.DisplayMember = "EnergySource";
                    }
                    if (comboBoxType == ComboBoxFillType.FuelType)
                    {
                        DataRow[] dr    = dt.Select("EnergySource='" + filterOption + "'");
                        DataTable newDt = new DataTable();
                        newDt = dt.Clone();
                        dr.CopyToDataTable <DataRow>(newDt, LoadOption.Upsert);
                        cmbBox.DataSource    = newDt;
                        cmbBox.DisplayMember = "FuelType";
                    }
                }
            }
        }
예제 #2
0
        private void FillEmissionFactorTextBox(string txtCtrlName, string energySource, string fuelType, bool isReadOnly)
        {
            DataTable dt = CO2EmissionUtils.GetCO2Emissions();

            if (dt != null)
            {
                Control[] collection = this.Controls.Find(txtCtrlName, false);
                if (collection.Length > 0)
                {
                    TextBox txtBox = collection[0] as TextBox;
                    txtBox.ReadOnly = !isReadOnly;
                    DataRow[] dr = dt.Select("EnergySource='" + energySource + "' AND FuelType='" + fuelType + "'");
                    if (dr.Length > 0)
                    {
                        txtBox.Text = dr[0]["EmissionFactor"].ToString();
                    }
                }
            }
        }