Ejemplo n.º 1
0
        public static SzpifColumn createSzpifColumn(SzpifType type)
        {
            switch (type.Subtype)
            {
            case "Default":
                return(new DefaultSzpifColumn());

            case "Link":
                return(new LinkColumn());

            case "CheckedListBox":
                return(new CheckedListBoxColumn());

            case "SqlDateTime":
                return(new DateTimeColumn());

            case "Project State":
                return(new StateColumn());

            case "Task State":
                return(new StateColumn());

            default:
                return(new DefaultSzpifColumn());
            }
        }
Ejemplo n.º 2
0
 public StateControl(string columnName, SzpifType type) : base(columnName)
 {
     this.type = type;
     InitializeComponent();
     this.Name = columnName;
     this.ColumnNameLabel.Text = columnName;
     this.columnValue.Items.Add(getDefaultValue());
     this.columnValue.SelectedItem = this.columnValue.Items[0];
 }
Ejemplo n.º 3
0
 public StateControl(string columnName, SzpifType type) : base(columnName)
  {
      this.type = type;
      InitializeComponent();
      this.Name = columnName;
      this.ColumnNameLabel.Text = columnName;
      this.columnValue.Items.Add(getDefaultValue());
      this.columnValue.SelectedItem = this.columnValue.Items[0];
  }
Ejemplo n.º 4
0
 public LinkControl(string columnName, SzpifType type) : base(columnName)
 {
     InitializeComponent();
     this.Name                  = columnName;
     this.linkType              = type;
     this.searchViewName        = type.Additional;
     this.ColumnNameLabel.Text  = columnName;
     this.ColumnValue.ReadOnly  = true;
     this.ColumnValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
 }
Ejemplo n.º 5
0
 public LinkControl(string columnName, SzpifType type) : base(columnName)
 {
     InitializeComponent();
     this.Name = columnName;
     this.linkType = type;
     this.searchViewName = type.Additional;
     this.ColumnNameLabel.Text = columnName;
     this.ColumnValue.ReadOnly = true;
     this.ColumnValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
 }
Ejemplo n.º 6
0
 public static SzpifControl createSzpifControl(string className, string columnName, SzpifType szpifType)
 {
     switch (className)
     {
         case "Default":
             return new DefaultSzpifControl(columnName);
         case "State":
             return new StateControl(columnName, szpifType);
         case "LinkControl":
             return new LinkControl(columnName,szpifType);
         case "CheckedListBoxControl":
             return new CheckedListBoxControl(columnName, szpifType);
         case "DateTimeControl":
             return new DateTimeControl(columnName);
         default:
             return new DefaultSzpifControl(columnName);
     }
 }
Ejemplo n.º 7
0
 private void getTypeInformation(SzpifType column)
 {
     string ctext = "exec getTypeSchema '" + viewName + "', '" + column.Name + "'";
     SqlCommand com = new SqlCommand(ctext, (SqlConnection)selectCommand.Connection);
     SqlDataAdapter adapter = new SqlDataAdapter(com);
     DataTable table = new DataTable();
     adapter.Fill(table);
     if(table.Rows.Count > 0)
     {
         column.Subtype = table.Rows[0]["Name"].ToString();
         column.Schema = table.Rows[0]["TypeSchema"].ToString();
         column.Additional = table.Rows[0]["Additional"].ToString();
     }
     else
     {
         column.Subtype = column.Type;
         column.Schema = "";
     }
 }
Ejemplo n.º 8
0
 public static SzpifColumn createSzpifColumn(SzpifType type)
 {
     switch (type.Subtype)
     {
         case "Default":
             return new DefaultSzpifColumn();
         case "Link":
             return new LinkColumn();
         case "CheckedListBox":
             return new CheckedListBoxColumn();
         case "SqlDateTime":
             return new DateTimeColumn();
         case "Project State":
             return new StateColumn();
         case "Task State":
             return new StateColumn();
         default:
             return new DefaultSzpifColumn();
     }
 }
Ejemplo n.º 9
0
        private void getTypeInformation(SzpifType column)
        {
            string         ctext   = "exec getTypeSchema '" + viewName + "', '" + column.Name + "'";
            SqlCommand     com     = new SqlCommand(ctext, (SqlConnection)selectCommand.Connection);
            SqlDataAdapter adapter = new SqlDataAdapter(com);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            if (table.Rows.Count > 0)
            {
                column.Subtype    = table.Rows[0]["Name"].ToString();
                column.Schema     = table.Rows[0]["TypeSchema"].ToString();
                column.Additional = table.Rows[0]["Additional"].ToString();
            }
            else
            {
                column.Subtype = column.Type;
                column.Schema  = "";
            }
        }
Ejemplo n.º 10
0
        public CheckedListBoxControl(string columnName, SzpifType type) : base(columnName)
        {
            InitializeComponent();
            this.Name = columnName;
            this.columnValue.CheckOnClick = true;
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(new StringReader(type.Schema));
            XElement xml = XElement.Load(new StringReader(type.Schema));

            var query = from x in xml.Elements("Item")
                        select x;

            columnValue.Height = 10;
            foreach (var record in query)
            {
                columnValue.Items.Add(record.Attribute("Name").Value);
                columnValue.Height += 15;
            }
            this.Height = columnValue.Height + 3;
            this.ColumnNameLabel.Text = columnName;
        }
Ejemplo n.º 11
0
        public CheckedListBoxControl(string columnName, SzpifType type) : base(columnName)
        {
            InitializeComponent();
            this.Name = columnName;
            this.columnValue.CheckOnClick = true;
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(new StringReader(type.Schema));
            XElement xml = XElement.Load(new StringReader(type.Schema));

            var query = from x in xml.Elements("Item")
                        select x;

            columnValue.Height = 10;
            foreach (var record in query)
            {
                columnValue.Items.Add(record.Attribute("Name").Value);
                columnValue.Height += 15;
            }
            this.Height = columnValue.Height + 3;
            this.ColumnNameLabel.Text = columnName;
        }
Ejemplo n.º 12
0
        protected override void execute()
        {
            DataTable help = new DataTable();
            SqlDataAdapter oDA = new SqlDataAdapter(selectCommand.CommandText, (SqlConnection)selectCommand.Connection);
            oDA.ReturnProviderSpecificTypes = true;  
            oDA.FillSchema(help, SchemaType.Mapped);

            SqlCommandBuilder.DeriveParameters(updateCommand);
            SqlCommandBuilder.DeriveParameters(insertCommand);
            SqlCommandBuilder.DeriveParameters(deleteCommand);

            oDA.ReturnProviderSpecificTypes = false;
            foreach (DataColumn column in help.Columns)
            {
                SzpifType c = new SzpifType();
                c.Type = column.DataType.Name;
                c.Name = column.ColumnName;
                getTypeInformation(c);
                SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                szpifColumn.CanView = true;
                szpifColumn.Name = c.Name;
                szpifColumn.Type = c;
                view.Columns.Add(column.ColumnName, szpifColumn);
            }

            foreach (SqlParameter column in updateCommand.Parameters)
            {
                string name = column.ParameterName.Substring(1);
                if (!view.Columns.ContainsKey(name))
                {
                    SzpifType c = new SzpifType();
                    c.Type = column.SqlDbType.ToString();
                    c.Name = name;
                    if (column.SqlDbType.ToString() == "Xml")
                        getTypeInformation(c);
                    else
                    {
                        c.Subtype = c.Type;
                        c.Schema = "";
                    }
                    SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                    szpifColumn.Name = c.Name;
                    szpifColumn.Type = c;
                    view.Columns.Add(name, szpifColumn);
                }
                if(name != "Id")view.Columns[name].CanUpdate = true;

            }


            foreach (SqlParameter column in insertCommand.Parameters)
            {
                string name = column.ParameterName.Substring(1);
                if (!view.Columns.ContainsKey(name))
                {
                    SzpifType c = new SzpifType();
                    c.Type = column.SqlDbType.ToString();
                    c.Name = name;
                    if (column.SqlDbType.ToString() == "Xml")
                        getTypeInformation(c);
                    else
                    {
                        c.Subtype = c.Type;
                        c.Schema = "";
                    }
                    SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                    szpifColumn.Name = c.Name;
                    szpifColumn.Type = c;
                    view.Columns.Add(name, szpifColumn);
                }
                view.Columns[name].CanInsert = true;
            }
            view.Columns.Remove("RETURN_VALUE");
            view.Updateable = false;
            view.Insertable = false;
            view.Deletable = false;
            foreach (SzpifColumn column in view.Columns.Values)
            {
                if (column.CanInsert) view.Insertable = true;
                if (column.CanUpdate) view.Updateable = true;
            }
            if (deleteCommand.Parameters.Count > 1) view.Deletable = true;

            oDA.Fill(view.Table); 
        }
Ejemplo n.º 13
0
        protected override void execute()
        {
            DataTable      help = new DataTable();
            SqlDataAdapter oDA  = new SqlDataAdapter(selectCommand.CommandText, (SqlConnection)selectCommand.Connection);

            oDA.ReturnProviderSpecificTypes = true;
            oDA.FillSchema(help, SchemaType.Mapped);

            SqlCommandBuilder.DeriveParameters(updateCommand);
            SqlCommandBuilder.DeriveParameters(insertCommand);
            SqlCommandBuilder.DeriveParameters(deleteCommand);

            oDA.ReturnProviderSpecificTypes = false;
            foreach (DataColumn column in help.Columns)
            {
                SzpifType c = new SzpifType();
                c.Type = column.DataType.Name;
                c.Name = column.ColumnName;
                getTypeInformation(c);
                SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                szpifColumn.CanView = true;
                szpifColumn.Name    = c.Name;
                szpifColumn.Type    = c;
                view.Columns.Add(column.ColumnName, szpifColumn);
            }

            foreach (SqlParameter column in updateCommand.Parameters)
            {
                string name = column.ParameterName.Substring(1);
                if (!view.Columns.ContainsKey(name))
                {
                    SzpifType c = new SzpifType();
                    c.Type = column.SqlDbType.ToString();
                    c.Name = name;
                    if (column.SqlDbType.ToString() == "Xml")
                    {
                        getTypeInformation(c);
                    }
                    else
                    {
                        c.Subtype = c.Type;
                        c.Schema  = "";
                    }
                    SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                    szpifColumn.Name = c.Name;
                    szpifColumn.Type = c;
                    view.Columns.Add(name, szpifColumn);
                }
                if (name != "Id")
                {
                    view.Columns[name].CanUpdate = true;
                }
            }


            foreach (SqlParameter column in insertCommand.Parameters)
            {
                string name = column.ParameterName.Substring(1);
                if (!view.Columns.ContainsKey(name))
                {
                    SzpifType c = new SzpifType();
                    c.Type = column.SqlDbType.ToString();
                    c.Name = name;
                    if (column.SqlDbType.ToString() == "Xml")
                    {
                        getTypeInformation(c);
                    }
                    else
                    {
                        c.Subtype = c.Type;
                        c.Schema  = "";
                    }
                    SzpifColumn szpifColumn = ColumnFactory.createSzpifColumn(c);
                    szpifColumn.Name = c.Name;
                    szpifColumn.Type = c;
                    view.Columns.Add(name, szpifColumn);
                }
                view.Columns[name].CanInsert = true;
            }
            view.Columns.Remove("RETURN_VALUE");
            view.Updateable = false;
            view.Insertable = false;
            view.Deletable  = false;
            foreach (SzpifColumn column in view.Columns.Values)
            {
                if (column.CanInsert)
                {
                    view.Insertable = true;
                }
                if (column.CanUpdate)
                {
                    view.Updateable = true;
                }
            }
            if (deleteCommand.Parameters.Count > 1)
            {
                view.Deletable = true;
            }

            oDA.Fill(view.Table);
        }
Ejemplo n.º 14
0
        public static SzpifControl createSzpifControl(string className, string columnName, SzpifType szpifType)
        {
            switch (className)
            {
            case "Default":
                return(new DefaultSzpifControl(columnName));

            case "State":
                return(new StateControl(columnName, szpifType));

            case "LinkControl":
                return(new LinkControl(columnName, szpifType));

            case "CheckedListBoxControl":
                return(new CheckedListBoxControl(columnName, szpifType));

            case "DateTimeControl":
                return(new DateTimeControl(columnName));

            default:
                return(new DefaultSzpifControl(columnName));
            }
        }