Beispiel #1
0
        public Valueset(int myvaluesetid)
        {
            valitems        = new List <Valuesetitem>();
            fieldvaluesetid = myvaluesetid;

            SQL_utils sql = new SQL_utils("data");

            DataTable dt = sql.DataTable_from_SQLstring(String.Format("select * from datFieldValueSetItem where fieldvaluesetid = {0}", fieldvaluesetid));

            foreach (DataRow row in dt.Rows)
            {
                int          val   = Convert.ToInt32(row["FieldValue"]);
                string       label = row["FieldValueLabel"].ToString();
                Valuesetitem itm   = new Valuesetitem(val, label);

                valitems.Add(itm);
            }
            sql.Close();
        }
Beispiel #2
0
        public Valueset(string raw_vallabels)
        {
            string[]      delimiter    = new string[] { " | " };
            List <string> raw_vallabel = raw_vallabels.Split(delimiter, StringSplitOptions.RemoveEmptyEntries).ToList();

            if (raw_vallabel.Count > 0)
            {
                valitems = new List <Valuesetitem>();

                foreach (string raw_vl in raw_vallabel)
                {
                    List <string> val_and_label = raw_vl.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    Valuesetitem vi = new Valuesetitem(Convert.ToInt32(val_and_label[0]), val_and_label[1]);
                    if (vi != null)
                    {
                        valitems.Add(vi);
                    }
                }
            }
        }
Beispiel #3
0
        public Valueset(string tblname, string fldname)
        {
            valitems = new List <Valuesetitem>();

            SQL_utils sql = new SQL_utils("data");

            DataTable dt = sql.DataTable_from_SQLstring(String.Format("select * from datFieldValueSetItem where fieldvaluesetid = " +
                                                                      " (select fieldvaluesetid from def.fld where tblpk={0} and fldname='{1}')", tblname, fldname));

            fieldvaluesetid = dt.AsEnumerable().Select(f => f.Field <int>("fieldvaluesetid")).Min();

            foreach (DataRow row in dt.Rows)
            {
                int          val   = Convert.ToInt32(row["FieldValue"]);
                string       label = row["FieldValueLabel"].ToString();
                Valuesetitem itm   = new Valuesetitem(val, label);

                valitems.Add(itm);
            }
            sql.Close();
        }
Beispiel #4
0
        public Variable(SpssLib.SpssDataset.Variable spssvar)
        {
            varname  = spssvar.Name;
            varlabel = spssvar.Label;
            //if (spssvar.IsDate()) datatype = "date";
            //else if (spssvar.Type == SpssLib.SpssDataset.DataType.Numeric) datatype = "float";
            //else if (spssvar.Type == SpssLib.SpssDataset.DataType.Text) datatype = "varchar";

            if (spssvar.IsDate())
            {
                datatype = new Datatype(SqlDatatype.Date);
            }
            else if (spssvar.Type == SpssLib.SpssDataset.DataType.Numeric)
            {
                datatype = new Datatype(SqlDatatype.Float);
            }
            else if (spssvar.Type == SpssLib.SpssDataset.DataType.Text)
            {
                datatype = new Datatype(SqlDatatype.Varchar);
            }



            if (spssvar.ValueLabels != null)
            {
                if (spssvar.ValueLabels.Count > 0)
                {
                    Valueset valset = new Valueset();

                    foreach (KeyValuePair <double, string> label in spssvar.ValueLabels)
                    {
                        Valuesetitem itm = new Valuesetitem(label);
                        valset.valitems.Add(itm);
                    }

                    valueset = valset;
                }
            }
        }