Exemplo n.º 1
0
        public IntegratedView bindToView(DataGridView dataGrid)
        {
            DataManager    dm       = new DataManager(database);
            string         viewName = dataGrid.Name;
            IntegratedView view     = database.getView(viewName);

            dataGrid.AutoGenerateColumns = false;
            dataGrid.DataSource          = view.Table;

            foreach (SzpifColumn column in view.Columns.Values)
            {
                dataGrid.Columns.Add(column.createDataGridViewColumn());
            }
//            dataGrid.Columns[dataGrid.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            foreach (SzpifColumn column in view.Columns.Values)
            {
                if (column.CanUpdate && view.Table.Columns.Contains(column.Name) == false)
                {
                    view.Table.Columns.Add(new DataColumn(column.Name));
                }
            }

            if (views.ContainsKey(viewName))
            {
                views.Remove(viewName);
            }
            views.Add(viewName, view);
            return(view);
        }
Exemplo n.º 2
0
        public GetViewTransaction(string viewName)
        {
            this.view = new IntegratedView();
            this.view.Table = new DataTable();
            this.columnNames = new List<string>();
            this.viewName = viewName;
            string selectCommandString = "exec get" + viewName + ";";
            selectCommand = SzpifDatabase.Factory.CreateCommand();
            selectCommand.CommandText = selectCommandString;
            selectCommand.Connection = SzpifDatabase.Connection;

            updateCommand = new SqlCommand();
            updateCommand.Connection = (SqlConnection)SzpifDatabase.Connection;
            updateCommand.CommandType = CommandType.StoredProcedure;
            updateCommand.CommandText = "update" + viewName;

            insertCommand = new SqlCommand();
            insertCommand.Connection = (SqlConnection)SzpifDatabase.Connection;
            insertCommand.CommandType = CommandType.StoredProcedure;
            insertCommand.CommandText = "insert" + viewName;

            deleteCommand = new SqlCommand();
            deleteCommand.Connection = (SqlConnection)SzpifDatabase.Connection;
            deleteCommand.CommandType = CommandType.StoredProcedure;
            deleteCommand.CommandText = "delete" + viewName;//"delete from Employees where Id = @original_id";//"delete" + viewName;
        }
Exemplo n.º 3
0
 public void setDataInGrid(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row)
 {
     foreach (SzpifControl c in valueBoxes)
     {
         gridView.Rows[row].Cells[c.Name].Value = c.getData();
     }
 }
Exemplo n.º 4
0
        public GetViewTransaction(string viewName)
        {
            this.view        = new IntegratedView();
            this.view.Table  = new DataTable();
            this.columnNames = new List <string>();
            this.viewName    = viewName;
            string selectCommandString = "exec get" + viewName + ";";

            selectCommand             = SzpifDatabase.Factory.CreateCommand();
            selectCommand.CommandText = selectCommandString;
            selectCommand.Connection  = SzpifDatabase.Connection;

            updateCommand             = new SqlCommand();
            updateCommand.Connection  = (SqlConnection)SzpifDatabase.Connection;
            updateCommand.CommandType = CommandType.StoredProcedure;
            updateCommand.CommandText = "update" + viewName;

            insertCommand             = new SqlCommand();
            insertCommand.Connection  = (SqlConnection)SzpifDatabase.Connection;
            insertCommand.CommandType = CommandType.StoredProcedure;
            insertCommand.CommandText = "insert" + viewName;

            deleteCommand             = new SqlCommand();
            deleteCommand.Connection  = (SqlConnection)SzpifDatabase.Connection;
            deleteCommand.CommandType = CommandType.StoredProcedure;
            deleteCommand.CommandText = "delete" + viewName;//"delete from Employees where Id = @original_id";//"delete" + viewName;
        }
Exemplo n.º 5
0
        public void addRowToView(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view)
        {
            DataTable dt = (DataTable)gridView.DataSource;
            DataRow dr = dt.NewRow();
            foreach (SzpifControl c in valueBoxes)
            {
                    dr[c.Name] = c.getData();
            }

            Int32 last = 0;
            if(dt.Rows.Count > 0)last = (Int32)dt.Rows[dt.Rows.Count - 1]["Id"] + 1;
            dr["Id"] = last;
            dt.Rows.Add(dr);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Generates the content for insert Form.
 /// </summary>
 /// <param name="InsertForm">The insert form.</param>
 /// <param name="grid">Grid, którego kolumny będziemy podpinać.</param>
 /// <param name="schema">Schemat widoku, który jest podpięty do datagridu.</param>
 public List<SzpifControl> generateContent(Control parent, DataGridView gridView, IntegratedView view)
 {
     List<SzpifControl> valueBoxes = new List<SzpifControl>();
     int aktY = 10;
     foreach(SzpifColumn column in view.Columns.Values)
         if (column.CanUpdate)
         {
             SzpifControl control = column.createControl();
             control.Location = new Point(control.Location.X, aktY);
             aktY += control.Size.Height;
             valueBoxes.Add(control);
             parent.Controls.Add(control);
         }
     return valueBoxes;        
 }
Exemplo n.º 7
0
        public UserSettingsPage(string text) : base(text)
        {
            contManager = Program.Context.ContentManager;
            bindManager = Program.Context.ViewToGridManager;

            InitializeComponent();

            // initializing dataGridView
            employeesForUser = new DataGridView();
            employeesForUser.Name = "EmployeesForUser";
            employeesForUser.Visible = false;
            this.Controls.Add(employeesForUser);
            
            // binding
            view = bindManager.bindToView(employeesForUser);
            valueBoxes = contManager.generateContent(this, employeesForUser, view);
        }
Exemplo n.º 8
0
        public UserSettingsPage(string text) : base(text)
        {
            contManager = Program.Context.ContentManager;
            bindManager = Program.Context.ViewToGridManager;

            InitializeComponent();

            // initializing dataGridView
            employeesForUser         = new DataGridView();
            employeesForUser.Name    = "EmployeesForUser";
            employeesForUser.Visible = false;
            this.Controls.Add(employeesForUser);

            // binding
            view       = bindManager.bindToView(employeesForUser);
            valueBoxes = contManager.generateContent(this, employeesForUser, view);
        }
Exemplo n.º 9
0
        public ICollection <string> getCurrentUserRoles()
        {
            ICollection <string> roles = new List <string>();
            IntegratedView       view  = database.getView("EmployeesForUser");
            string help = view.Table.Rows[0]["Roles"].ToString();

            //string help = gridView.Rows[row].Cells[valueBox.Name].Value.ToString();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(new StringReader(help));
            XElement xml = XElement.Load(new StringReader(help));

            var query = from x in xml.Elements("Item")
                        where (int)x.Attribute("Value") == 1
                        select x;

            foreach (var record in query)
            {
                roles.Add(record.Attribute("Name").Value);
            }
            return(roles);
            //return DataManager.getValues(view.Table, columnName);
        }
Exemplo n.º 10
0
        public IntegratedView reconnect(DataGridView dataGrid)
        {
            //  DataManager dm = new DataManager(database);
            string         viewName = dataGrid.Name;
            IntegratedView view     = database.getView(viewName);

            dataGrid.AutoGenerateColumns = false;
            dataGrid.DataSource          = view.Table;
            if (views.ContainsKey(viewName))
            {
                views.Remove(viewName);
            }
            views.Add(viewName, view);

            foreach (SzpifColumn column in view.Columns.Values)
            {
                if (column.CanUpdate && view.Table.Columns.Contains(column.Name) == false)
                {
                    view.Table.Columns.Add(new DataColumn(column.Name));
                }
            }
            return(view);
        }
Exemplo n.º 11
0
        public ICollection <string> getColumnValuesFromView(string viewName, string columnName)
        {
            IntegratedView view = database.getView(viewName);

            return(DataManager.getValues(view.Table, columnName));
        }
Exemplo n.º 12
0
 public void getDataFromGrid(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row)
 {
     foreach (SzpifControl c in valueBoxes)
     {
         if (gridView.Columns.Contains(c.Name) && gridView.Columns[c.Name].Visible == true)
         {
             c.fill(gridView.Rows[row].Cells[c.Name].Value.ToString());
         }
     }
 }
Exemplo n.º 13
0
 public void setDataInGrid(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row)
 {
     foreach (SzpifControl c in valueBoxes)
     {
         gridView.Rows[row].Cells[c.Name].Value = c.getData();
     }
 }
Exemplo n.º 14
0
        public void addRowToView(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view)
        {
            DataTable dt = (DataTable)gridView.DataSource;
            DataRow   dr = dt.NewRow();

            foreach (SzpifControl c in valueBoxes)
            {
                dr[c.Name] = c.getData();
            }

            Int32 last = 0;

            if (dt.Rows.Count > 0)
            {
                last = (Int32)dt.Rows[dt.Rows.Count - 1]["Id"] + 1;
            }
            dr["Id"] = last;
            dt.Rows.Add(dr);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Generates the content for insert Form.
        /// </summary>
        /// <param name="InsertForm">The insert form.</param>
        /// <param name="grid">Grid, którego kolumny będziemy podpinać.</param>
        /// <param name="schema">Schemat widoku, który jest podpięty do datagridu.</param>
        public List <SzpifControl> generateContent(Control parent, DataGridView gridView, IntegratedView view)
        {
            List <SzpifControl> valueBoxes = new List <SzpifControl>();
            int aktY = 10;

            foreach (SzpifColumn column in view.Columns.Values)
            {
                if (column.CanUpdate)
                {
                    SzpifControl control = column.createControl();
                    control.Location = new Point(control.Location.X, aktY);
                    aktY            += control.Size.Height;
                    valueBoxes.Add(control);
                    parent.Controls.Add(control);
                }
            }
            return(valueBoxes);
        }
Exemplo n.º 16
0
 public void getDataFromGrid(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row)
 {
     foreach (SzpifControl c in valueBoxes)
         if (gridView.Columns.Contains(c.Name) && gridView.Columns[c.Name].Visible == true)
             c.fill(gridView.Rows[row].Cells[c.Name].Value.ToString());
 }