Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                SetContentView(Resource.Layout.single_line_item_main);

                _recyclerView = FindViewById <RecyclerView>(Resource.Id.rvSingleItems);
                _recyclerView.HasFixedSize = true;

                _layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                _recyclerView.SetLayoutManager(_layoutManager);

                VerticalInnerDividerItemDecorator dividerItemDecoration =
                    new VerticalInnerDividerItemDecorator(
                        ContextCompat.GetDrawable(_recyclerView.Context, Resource.Drawable.divider)
                        );
                _recyclerView.AddItemDecoration(dividerItemDecoration);

                _items   = new ListItemDataSource();
                _adapter = new SingleLineItemActionAdapter(_items);

                if (_adapter as SingleLineItemActionAdapter != null)
                {
                    SingleLineItemActionAdapter adapter = _adapter as SingleLineItemActionAdapter;
                    adapter.ItemSecondaryActionClicked += AvatarAction_OnItemSecondaryActionClicked;
                }

                if (_adapter as SingleLineItemAvatarActionAdapter != null)
                {
                    SingleLineItemAvatarActionAdapter adapter = _adapter as SingleLineItemAvatarActionAdapter;
                    adapter.ItemSecondaryActionClicked += AvatarAction_OnItemSecondaryActionClicked;
                }

                _recyclerView.SetAdapter(_adapter);
            }
            catch (Exception ex)
            {
                Log.Debug("SingleLineItemActivity", ex.ToString());
            }
        }
Пример #2
0
 public SingleLineItemAdapter(ListItemDataSource items) => Items = items;
Пример #3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!IsEdit && ChkField)
            {
                Alert(Label1, "字段已经存在!", "line1px_2");
            }
            else
            {
                Int32 _length = 0;
                Int32.TryParse(@Length.Text, out _length);
                @Length.Text = _length.ToString();

                Int32 _columns = 1;
                Int32.TryParse(RepeatColumns.Text, out _columns);
                RepeatColumns.Text = _columns.ToString();

                String sql            = String.Empty;
                Int32  _datatypevalue = Convert.ToInt32(Enum.Parse(db.dbType, @DataType.SelectedValue, true));
                DataTypeValue.Value = _datatypevalue.ToString();
                if (IsEdit)
                {
                    CurrentField = CurrentFields.Find(a => { return(a.ID == EditID); });

                    #region 检查数据库改动

                    if (isVirtual.SelectedIndex == 1)
                    {
                        //类型类型改动
                        sql = String.Format("ALTER TABLE {0} ALTER COLUMN {1} {2}", CurrentTable.TableName, CurrentField.FieldName, @DataType.SelectedValue);
                        if (CurrentField.Length != _length && _length != 0)//检查长度
                        {
                            sql += "(" + _length + ")";
                        }
                        if (CurrentField.DataType != _datatypevalue || (CurrentField.Length != _length && _length != 0))
                        {
                            try
                            {
                                db.ExecuteCommand(sql);
                            }
                            catch (Exception ex)
                            {
                                Alert(Label1, ex.Message, "line1px_2");
                                return;
                            }
                        }
                    }

                    #endregion
                }
                else
                {
                    CurrentField = new WebSite.Core.Table.Field()
                    {
                        ID = Guid.NewGuid()
                    };
                    if (isVirtual.SelectedIndex == 1)//添加真实字段
                    {
                        sql = sql = String.Format("ALTER TABLE {0} ADD {1} {2}", CurrentTable.TableName, FieldName.Text, @DataType.SelectedValue);
                        if (_length != 0)//设置长度
                        {
                            sql += "(" + _length + ")";
                        }

                        try
                        {
                            db.ExecuteCommand(sql);
                        }
                        catch (Exception ex)
                        {
                            Alert(Label1, ex.Message, "line1px_2");
                            return;
                        }
                    }

                    CurrentFields.Add(CurrentField);
                }
                CurrentField = this.GetFormValue <WebSite.Core.Table.Field>(CurrentField);

                //数据源类型
                CurrentField.DataSource = this.GetFormValue <FieldDataSource>(CurrentField.DataSource);
                //布局模式
                CurrentField.DataSource.Layout = this.GetFormValue <DataSourceLayout>(CurrentField.DataSource.Layout);
                //SQL数据源
                CurrentField.DataSource.SQLDataSource = this.GetFormValue <SQLDataSource>(CurrentField.DataSource.SQLDataSource);
                //列表项目
                if (Repeater1.Items.Count > 0)
                {
                    CurrentField.DataSource.ListItemDataSource = new List <ListItemDataSource>();
                    foreach (RepeaterItem item in Repeater1.Items)
                    {
                        String             text     = ((TextBox)item.Controls[0].FindControl("t1")).Text;
                        String             value    = ((TextBox)item.Controls[0].FindControl("t2")).Text;
                        Boolean            chk      = ((CheckBox)item.Controls[0].FindControl("c1")).Checked;
                        ListItemDataSource listitem = new ListItemDataSource
                        {
                            Selected = chk,
                            Text     = text,
                            Value    = value
                        };
                        CurrentField.DataSource.ListItemDataSource.Add(listitem);
                    }
                }

                SiteTable.SaveTables(SiteTable.Tables);
                Alert(Label1, "保存成功!", "line1px_3");
            }
        }