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);
        }
        public void OnRowInserted(string name = null)
        {
            try
            {
                MobileTableRow values = this.dataGrid.GetControlValues();
                if (name == null)
                {
                    var grid = GetRow(values);
                    Body.Children.Add(grid);
                }
                else
                {
                    MobileTableRow row    = this.dataGrid.GetControlValues();
                    MobileTableRow oldRow = dataDictionary[name];
                    row.RowId            = oldRow.RowId;
                    dataDictionary[name] = row;

                    for (int i = 0; i < Body.Children.Count; i++)
                    {
                        if (Body.Children[i].ClassId == name)
                        {
                            Body.Children.Remove(Body.Children[i]);
                            var ig = GetRow(row, name);
                            Body.Children.Insert(i, ig);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }
Example #3
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);
        }
Example #4
0
 public bool CanRowPersist(MobileTableRow row)
 {
     if (PersistRowExprCode != null)
     {
         try
         {
             SetRowData(row);
             bool status = evaluator.Execute <bool>(PersistRowExprCode);
             if (!status)
             {
                 if (row.RowId <= 0)
                 {
                     return(false);
                 }
                 else
                 {
                     row.IsDelete = true;
                 }
             }
         }
         catch (Exception ex)
         {
         }
     }
     return(true);
 }
Example #5
0
        public DGDynamicFrame(MobileTableRow row, EbMobileTableLayout layout, bool isHeader = false)
        {
            IsHeader = isHeader;

            DynamicGrid = new DynamicGrid(layout);
            this.FillTableColums(row, layout.CellCollection);

            this.Content = DynamicGrid;
        }
 public void SetValue(EbDataTable dataTable)
 {
     foreach (EbDataRow row in dataTable.Rows)
     {
         MobileTableRow tableRow = DR2TableRow(row);
         var            rowView  = GetRow(tableRow);
         Body.Children.Add(rowView);
     }
 }
 private async Task GetFileData(EbMobileControl ctrl, MobileTable table, MobileTableRow row)
 {
     if (ctrl is EbMobileFileUpload fup)
     {
         table.Files.Add(ctrl.Name, fup.GetValue <List <FileWrapper> >());
     }
     else if (ctrl is EbMobileDisplayPicture || ctrl is EbMobileAudioInput)
     {
         await SendAndFillFupPersisant(ctrl, 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;
                }
            }
        }
        public DataGridForm(EbMobileDataGrid dataGrid, MobileTableRow row, string name)
        {
            InitializeComponent();

            mode          = GridMode.Edit;
            rowName       = name;
            this.dataGrid = dataGrid;

            SaveAndContinue.IsVisible = false;
            Grid.SetColumn(SaveAndClose, 0);
            Grid.SetColumnSpan(SaveAndClose, 3);
            Grid.SetColumn(CancelAndClose, 3);
            Grid.SetColumnSpan(CancelAndClose, 3);

            CreateForm();
            FillValue(row);
        }
        private View GetRow(MobileTableRow row, string name = null)
        {
            string guid = name ?? Guid.NewGuid().ToString("N");

            StackLayout stack = new StackLayout
            {
                ClassId     = guid,
                Orientation = Xamarin.Forms.StackOrientation.Horizontal,
                Padding     = new Thickness(5, 5, 0, 5)
            };

            stack.BackgroundColor = dataGrid.RowHelper.GetBackGroundColor(row);
            dataGrid.RowHelper.SetFontFromExprEvalResult();

            DGDynamicFrame dynamicFrame = new DGDynamicFrame(row, dataGrid.DataLayout)
            {
                ClassId            = guid,
                BackgroundColor    = Color.Transparent,
                Padding            = 0,
                GestureRecognizers = { this.tapRecognizer },
                HorizontalOptions  = LayoutOptions.FillAndExpand
            };

            stack.Children.Add(dynamicFrame);

            if (!dataGrid.DisableDelete)
            {
                Button rowOptions = new Button
                {
                    ClassId = guid,
                    Style   = (Style)HelperFunctions.GetResourceValue("DGEditRowButton")
                };
                rowOptions.Clicked += RowDelete_Clicked;
                stack.Children.Add(rowOptions);
            }
            if (name == null)
            {
                dataDictionary[guid] = row;
            }

            return(stack);
        }
Example #11
0
        public Color GetBackGroundColor(MobileTableRow row)
        {
            Color color = Color.White;

            if (RowColorExprCode != null)
            {
                try
                {
                    SetRowData(row);
                    string hexcolur = evaluator.Execute <string>(RowColorExprCode);
                    if (!string.IsNullOrWhiteSpace(hexcolur))
                    {
                        color = Color.FromHex(hexcolur);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(color);
        }
Example #12
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);
        }
Example #15
0
 private void SetRowData(MobileTableRow row)
 {
     foreach (MobileTableColumn Column in row.Columns)
     {
         if (ColumnDictionary.TryGetValue(Column.Name, out MobileTableColumn column))
         {
             if (Column.Type == EbDbTypes.Decimal)
             {
                 decimal.TryParse(Column.Value?.ToString(), out decimal val);
                 column.Value = val;
             }
             else
             {
                 column.Value = Column.Value;
             }
             if (RowColorExprCode != null && FontCopyDict.TryGetValue(Column.Name, out EbFont _font))
             {
                 if (_font == null)
                 {
                     column.Font = null;
                 }
                 else
                 {
                     if (column.Font == null)
                     {
                         column.Font = new EbFont();
                     }
                     column.Font.Color = _font.Color;
                     column.Font.Caps  = _font.Caps;
                     column.Font.Size  = _font.Size;
                     column.Font.Style = _font.Style;
                 }
             }
         }
     }
 }