Beispiel #1
0
        /// <summary>
        /// Adds the child table's data entry input fields for the child table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BuildRptrChildDataEntry(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                // get child table and data
                string childTableName = childTableName = e.Item.DataItem.ToString();
                IEnumerable <IBusinessObject> childRecords = _children[childTableName];
                // locate data entry control
                var childDataEntry = GetChildDataEntry(e.Item);
                // get child input fields
                var childInputFields = GetInputControls(childTableName);
                // build interface
                bool childIsGrid = pdec.IsGridView(childTableName);
                // grid interface
                if (childIsGrid)
                {
                    // add data entry fields interface
                    // important, at least 1 child bizo
                    var childGridRecords = childRecords;
                    // shouldn't ever hit here, blank data populated ??? - ac
                    if (childRecords.Count() == 0)
                    {
                        childRecords = new List <IBusinessObject>()
                        {
                            BusinessObjectFactory.BuildBusinessObject(childTableName)
                        };
                    }
                    CaisisGridView grid = CICHelper.AddGridViewByTableName(childDataEntry, childRecords, childTableName);
                    bool           childRecordsExist = childRecords.Where(c => c.PrimaryKeyHasValue).Count() > 0;
                    grid.VisibleBlankRows = childRecordsExist ? 0 : 1;
                }
                // standard data entry interface
                else
                {
                    var childDataEntryControl = BuildChildDataEntryInterface(childInputFields);
                    // add data entry fields interface
                    childDataEntry.Controls.Add(childDataEntryControl);

                    // set values on inital load
                    if (childRecords.Count() > 0 && !Page.IsPostBack)
                    {
                        IEnumerable <ICaisisInputControl> inputFields = PageUtil.GetControls <ICaisisInputControl>(e.Item);
                        SetFieldValues(childRecords.First(), inputFields);
                    }
                }
            }
        }
        /// <summary>
        /// Updates/Saves a row in the Grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void HandleRowUpdating(object sender, GridViewUpdateEventArgs args)
        {
            // Occurs when no real data/rows present in Grid
            // NOTE: Footer control is null in this case, as grid has no real data
            if (args.RowIndex < 0 && SpecimenEventsGridView.FooterRow == null)
            {
                CaisisGridView.ExtractCaisisInputValuesFromContainer(SpecimenEventsGridView, args.NewValues);
            }
            // Occurs when adding a record to a grid with data, values are in footer row
            else if (args.RowIndex < 0 && SpecimenEventsGridView.FooterRow != null)
            {
                CaisisGridView.ExtractCaisisInputValuesFromContainer(SpecimenEventsGridView.FooterRow, args.NewValues);
            }
            // Occurs when a row of real data is updating
            else
            {
                CaisisGridView.ExtractCaisisInputValuesFromContainer(SpecimenEventsGridView.Rows[args.RowIndex], args.NewValues);
            }

            // Create Biz Object
            SpecimenEvents biz = new SpecimenEvents();

            // If record exits (row of data/not footer)
            if (args.NewValues.Contains(SpecimenEvents.SpecimenEventId))
            {
                int priKey = int.Parse(args.NewValues[SpecimenEvents.SpecimenEventId].ToString());
                biz.Get(priKey);
            }
            // Footer Row, insert specimenid
            else
            {
                biz[SpecimenEvents.SpecimenId] = CurrentSpecimen[Specimen.SpecimenId];
            }
            // Set biz values
            foreach (string field in args.NewValues.Keys)
            {
                biz[field] = args.NewValues[field];
            }
            // Save/Update
            biz.Save();
            // Rebind grid to show saved data
            BindSpecimenEventsGrid();
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }
Beispiel #3
0
        /// <summary>
        /// When control value changes during post, add to list of "dirty" fields by row
        /// </summary>
        /// <param name="cic"></param>
        /// <param name="e"></param>
        protected void MarkRowDirty(ICaisisInputControl cic, EventArgs e)
        {
            Control     con = cic as Control;
            GridViewRow row = CaisisGridView.GetGridViewRowByControl(con); //con.NamingContainer as GridViewRow;

            if (row != null)
            {
                List <ICaisisInputControl> kvp;
                if (dirtyRows.ContainsKey(row))
                {
                    kvp = dirtyRows[row];
                }
                else
                {
                    kvp = new List <ICaisisInputControl>();
                    dirtyRows.Add(row, kvp);
                }
                if (!kvp.Contains(cic))
                {
                    kvp.Add(cic);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Update lookup code record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void HandleLookupUpdate(object sender, GridViewUpdateEventArgs e)
        {
            GridView    lkpCodeGrid = sender as GridView;
            GridViewRow updateRow   = lkpCodeGrid.Rows[e.RowIndex];

            // Fill dictionary from row controls
            CaisisGridView.ExtractCaisisInputValuesFromContainer(updateRow, e.NewValues);

            // Create a new biz for updating/inserting
            LookupCode biz = new LookupCode();
            // Determine if a lookupcodeid exists
            object lkpCodeIdKey = lkpCodeGrid.DataKeys[e.RowIndex][LookupCode.LookupCodeId];

            if (lkpCodeIdKey != null && !string.IsNullOrEmpty(lkpCodeIdKey.ToString()))
            {
                int lkpCodeId = int.Parse(lkpCodeIdKey.ToString());
                biz.Get(lkpCodeId);
            }
            else
            {
                return;
            }
            // Set the lkpcode extracted from textbox
            foreach (string col in e.NewValues.Keys)
            {
                //if (biz.HasColumn(col))
                if (biz.HasField(col))
                {
                    biz[col] = e.NewValues[col];
                }
            }

            biz.Save();

            // Notify the built-in update event to cancel/i.e., not bubble
            e.Cancel = true;
        }
Beispiel #5
0
        /// <summary>
        /// Adds a grid using the current configuration proerpties
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="dataSource"></param>
        /// <param name="totalBlankRows"></param>
        /// <param name="totalVisibleBlankRows"></param>
        /// <param name="tableFieldsMetadata"></param>
        public virtual void BuildLayout(string tableName, IEnumerable <IBusinessObject> dataSource, int totalBlankRows, int totalVisibleBlankRows, Dictionary <string, Dictionary <string, string> > tableFieldsMetadata)
        {
            CaisisGridView grid = CICHelper.AddGridViewByTableName(this, dataSource, tableName, totalBlankRows, totalVisibleBlankRows, tableFieldsMetadata);

            grid.ShowDeleteButton = false;
        }