private MobileTableRow DR2TableRow(EbDataRow row)
        {
            int dataId = row["id"] != null?Convert.ToInt32(row["id"]) : 0;

            MobileTableRow tableRow = new MobileTableRow(dataId);

            foreach (EbMobileControl ctrl in dataGrid.ChildControls)
            {
                if (ctrl is INonPersistControl || ctrl is ILinesEnabled)
                {
                    continue;
                }

                MobileTableColumn column = new MobileTableColumn
                {
                    Name    = ctrl.Name,
                    Type    = ctrl.EbDbType,
                    Value   = row[ctrl.Name] ?? null,
                    Control = ctrl
                };

                column.DisplayValue = ctrl.GetDisplayName4DG(column.Value);
                tableRow.Columns.Add(column);
            }
            return(tableRow);
        }
Example #2
0
        public MobileTableRow GetControlValues(bool isHeader = false)
        {
            MobileTableRow row = new MobileTableRow();

            try
            {
                foreach (EbMobileControl ctrl in ChildControls)
                {
                    if (ctrl is INonPersistControl || ctrl is ILinesEnabled)
                    {
                        continue;
                    }

                    MobileTableColumn column = new MobileTableColumn
                    {
                        Name    = ctrl.Name,
                        Type    = ctrl.EbDbType,
                        Value   = isHeader ? ctrl.Label : ctrl.GetValue(),
                        Control = ctrl
                    };

                    if (ctrl is EbMobileSimpleSelect ps)
                    {
                        column.DisplayValue = ps.GetDisplayValue();
                    }
                    row.Columns.Add(column);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
            return(row);
        }
        private void FillValue(MobileTableRow row)
        {
            foreach (EbMobileControl ctrl in dataGrid.ChildControls)
            {
                MobileTableColumn col = row[ctrl.Name];

                if (col != null)
                {
                    ctrl.DoNotPropagateChange = true;
                    ctrl.SetValue(col.Value);
                    ctrl.DoNotPropagateChange = false;
                }
            }
        }
Example #4
0
        private void FillTableColums(MobileTableRow row, List <EbMobileTableCell> CellCollection)
        {
            foreach (EbMobileTableCell cell in CellCollection)
            {
                if (cell.ControlCollection.Count > 0)
                {
                    EbMobileDataColumn column = (EbMobileDataColumn)cell.ControlCollection[0];

                    MobileTableColumn tableColumn = row[column.ColumnName];

                    if (tableColumn != null)
                    {
                        var value = tableColumn.DisplayValue ?? tableColumn.Value;

                        EbXLabel label = new EbXLabel(column)
                        {
                            Text              = value?.ToString(),
                            VerticalOptions   = LayoutOptions.FillAndExpand,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            XBackgroundColor  = Color.Transparent
                        };
                        XViewExtensions.SetTextAlignment(label, column.HorrizontalTextAlign, column.VerticalTextAlign);

                        if (IsHeader)
                        {
                            label.FontFamily    = (OnPlatform <string>)HelperFunctions.GetResourceValue("Roboto-Medium");
                            label.LineBreakMode = LineBreakMode.WordWrap;
                        }
                        else
                        {
                            label.SetFont(column.Font, this.IsHeader);
                            label.SetTextWrap(column.TextWrap);
                        }

                        DynamicGrid.SetPosition(label, cell.RowIndex, cell.ColIndex, column.RowSpan, column.ColumnSpan);
                    }
                }
            }
        }
        private async Task SendAndFillFupPersisant(EbMobileControl ctrl, MobileTableRow row)
        {
            List <FileWrapper> Files = ctrl.GetValue <List <FileWrapper> >();

            if (!Files.Any())
            {
                return;
            }

            try
            {
                List <ApiFileData> resp = await FormService.Instance.SendFilesAsync(Files);

                if (resp.Any())
                {
                    MobileTableColumn column = ctrl.GetMobileTableColumn();
                    List <int>        refIds = (from item in resp where item.FileRefId > 0 select item.FileRefId).ToList();
                    if (refIds.Count > 0)
                    {
                        string uploadedRefs = string.Join <int>(",", refIds);

                        if (ctrl is EbMobileAudioInput audio && audio.MultiSelect)
                        {
                            if (audio.OldValue != null)
                            {
                                uploadedRefs = audio.OldValue.ToString() + CharConstants.COMMA + uploadedRefs;
                            }
                        }
                        column.Value = uploadedRefs;
                        row.Columns.Add(column);
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error("error occured when sending persistant fup controls values");
                EbLog.Error(ex.Message + ", STACKTRACE:" + ex.StackTrace);
            }
        }
        private async Task <MobileFormData> GetFormData(int RowId)
        {
            MobileFormData formData = new MobileFormData(this.TableName);

            MobileTable table = formData.CreateTable();

            MobileTableRow row = table.CreateRow(RowId);

            foreach (KeyValuePair <string, EbMobileControl> pair in this.ControlDictionary)
            {
                EbMobileControl ctrl = pair.Value;

                if (ctrl is IFileUploadControl)
                {
                    await this.GetFileData(ctrl, table, row);
                }
                else if (ctrl is EbMobileDataGrid dataGrid)
                {
                    formData.Tables.Add(dataGrid.GetValue <MobileTable>());
                }
                else
                {
                    MobileTableColumn Column = ctrl.GetMobileTableColumn();

                    if (Column != null)
                    {
                        row.Columns.Add(Column);
                    }
                }
            }

            if (RowId <= 0)
            {
                row.AppendEbColValues(NetworkType == NetworkMode.Offline, true);
            }
            ;
            return(formData);
        }