Exemple #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------//

        private void Admin_Tables_Insert()
        {
            using (alfaDS ent = new alfaDS())
            {
                // Create Object
                Object objEntity = null;

                // Get Item
                alfaItem p_Item = (alfaItem)listAdminTables.SelectedItem;

                // Assign Object
                switch (p_Item.Name)
                {
                case "TableUser": objEntity = new SAM_USER(); break;

                case "TableGroup": objEntity = new SAM_GROUP(); break;

                case "TableParams": objEntity = new SAM_PRMS(); break;

                case "TableConfig": objEntity = new SAM_CONFIG(); break;
                }

                // Create Form
                FrmRecord frm = new FrmRecord(p_Item.ToString(), objEntity);

                // Confirmation
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                // Add Record
                switch (p_Item.Name)
                {
                case "TableUser": ent.Context.SAM_USER.Add(objEntity as SAM_USER); break;

                case "TableGroup": ent.Context.SAM_GROUP.Add(objEntity as SAM_GROUP); break;

                case "TableParams": ent.Context.SAM_PRMS.Add(objEntity as SAM_PRMS); break;

                case "TableConfig": ent.Context.SAM_CONFIG.Add(objEntity as SAM_CONFIG); break;
                }

                // SaveChanges
                ent.Context.SaveChanges();
            }

            // DataSource
            this.Admin_Tables_Refresh();

            // Select Row
            alfaGrid.SelectRow(grdAdminView, grdAdminView.RowCount - 1);
        }
Exemple #2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------//

        private void Admin_Tables_Update()
        {
            using (alfaDS DS = new alfaDS())
            {
                // Object
                Object objEntity = null;

                // Check
                if (grdAdminView.FocusedRowHandle < 0)
                {
                    return;
                }

                // Get ID
                var p_ID = (decimal)grdAdminView.GetRowCellValue(grdAdminView.FocusedRowHandle, "ID");

                // Get Item
                alfaItem p_Item = (alfaItem)listAdminTables.SelectedItem;

                // Assign Object
                switch (p_Item.Name)
                {
                case "TableUser": objEntity = DS.Context.SAM_USER.First(tt => tt.ID == p_ID); break;

                case "TableGroup": objEntity = DS.Context.SAM_GROUP.First(tt => tt.ID == p_ID); break;

                case "TableParams": objEntity = DS.Context.SAM_PRMS.First(tt => tt.ID == p_ID); break;

                case "TableConfig": objEntity = DS.Context.SAM_CONFIG.First(tt => tt.ID == p_ID); break;
                }

                // Create Form
                FrmRecord frm = new FrmRecord(p_Item.ToString(), objEntity);

                // Confirmation
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    // SaveChanges
                    DS.Context.SaveChanges();

                    // Refresh
                    this.Admin_Tables_Refresh();

                    // Get Row
                    int p_RowHandle = grdAdminView.LocateByValue("ID", p_ID, null);

                    // Select Row
                    alfaGrid.SelectRow(grdAdminView, p_RowHandle);
                }
            }
        }