public EditItemForm(Root root, IParentForm parent, Furniture data) : base(root, parent, Root.GetMsg("edit.title")) { _Item = data; BoxGroup = new Panel(); BoxGroup.AutoSize = true; ScrollPanel SP = new ScrollPanel(); SP.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); SP.AutoScroll = true; // create textboxes input BoxName = InsertField(Root.GetMsg("edit.name"), null, null, null); BoxDesc = InsertField(Root.GetMsg("edit.desc"), null, 160, null); BoxDimen1 = InsertField(Root.GetMsg("edit.dimen"), Validation.FloatField, null, 1); BoxDimen2 = InsertField(null, Validation.FloatField, null, 2); BoxDimen3 = InsertField(null, Validation.FloatField, null, 3); BoxPrice = InsertField(Root.GetMsg("edit.price"), (sender, e) => { Validation.NumberField(sender, e, 7); }, null, null); BoxDiscnt = InsertField(Root.GetMsg("edit.discount"), (sender, e) => { Validation.NumberField(sender, e, 2); }, null, null); BoxQty = InsertField(Root.GetMsg("edit.quantity"), (sender, e) => { Validation.NumberField(sender, e, 4); }, null, null); BoxReordrLv = InsertField(Root.GetMsg("edit.rl"), (sender, e) => { Validation.NumberField(sender, e, 4); }, null, null); BoxShelf = InsertField(Root.GetMsg("edit.sl"), Validation.ShelfLocationField, null, null); BoxCtgy = InsertDropDown(Root.GetMsg("edit.category")); BoxCtgy.SelectedIndexChanged += (sender, e) => { int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value; BoxSubCtgy.Items.Clear(); BoxSubCtgy.Items.AddRange(XQL.GetSubcategoeiesForDropDown(id)); BoxSubCtgy.SelectedIndex = 0; }; BoxSubCtgy = InsertDropDown(Root.GetMsg("edit.subcategory")); BoxCtgy.Items.Clear(); BoxCtgy.Items.AddRange(XQL.GetCategoeiesForDropDown()); BoxCtgy.SelectedIndex = 0; BoxPhoto = InsertField(Root.GetMsg("edit.photo"), null, null, null); BoxName.Text = _Item.Name; BoxDesc.Text = _Item.Description; string[] dimens = _Item.Dimension.Split('x'); BoxDimen1.Text = dimens[0]; BoxDimen2.Text = dimens[1]; BoxDimen3.Text = dimens[2]; BoxPrice.Text = _Item.Price.ToString(); BoxDiscnt.Text = _Item.Discount.ToString(); BoxQty.Text = _Item.Quantity.ToString(); BoxReordrLv.Text = _Item.ReorderLevel.ToString(); BoxShelf.Text = _Item.ShelfLocation.ToString(); BoxCtgy.Text = _Item.Category.ToString(); BoxSubCtgy.Text = _Item.SubCategory.ToString(); BoxPhoto.Text = _Item.Photo.AbsoluteUri; // add / update button BtnSubmit = new MetroButton(); BtnSubmit.AutoSize = true; BtnSubmit.Click += HandleSubmit; BtnSubmit.Text = Root.GetMsg("edit.btn-update"); BoxGroup.Controls.Add(BtnSubmit); BtnSubmit.Location = new Point((BoxPhoto.Left + BoxPhoto.Width) - BtnSubmit.Width, (BoxPhoto.Top + BoxPhoto.Height) + FieldPadding * 2); // align box group to middle SP.Controls.Add(BoxGroup); BoxGroup.Margin = new Padding((_This.ContentPanel.Width - SystemInformation.VerticalScrollBarWidth) / 2 - BoxGroup.Width / 2, 48, 0, 48); _This.ContentPanel.Controls.Add(SP); }
public SearchStoreFurnituresForm(Root root, IParentForm parent) : base(root, parent, Root.GetMsg("srch.title")) { BoxGroup = new Panel(); BoxGroup.AutoSize = true; ScrollPanel SP = new ScrollPanel(); SP.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); SP.AutoScroll = true; // create textboxes input BoxID = InsertField(Root.GetMsg("edit.id"), Validation.IDField); BoxName = InsertField(Root.GetMsg("edit.name"), null); BoxPrice = InsertField(Root.GetMsg("edit.price"), Validation.SearchFloatField); BoxQty = InsertField(Root.GetMsg("edit.quantity"), Validation.SearchFloatField); BoxCtgy = InsertDropDown(Root.GetMsg("edit.category")); BoxCtgy.SelectedIndexChanged += (sender, e) => { int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value; BoxSubCtgy.Items.Clear(); BoxSubCtgy.Items.AddRange(XQL.GetSubcategoeiesForDropDown(id)); BoxSubCtgy.SelectedIndex = 0; }; BoxSubCtgy = InsertDropDown(Root.GetMsg("edit.subcategory")); BoxCtgy.Items.Clear(); BoxCtgy.Items.AddRange(XQL.GetCategoeiesForDropDown()); BoxCtgy.SelectedIndex = 0; BoxOrderBy = InsertDropDown(Root.GetMsg("srch.order-by")); string asc = Root.GetMsg("srch.asc"); string desc = Root.GetMsg("srch.desc"); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.id") + " " + asc, 0)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.id") + " " + desc, 1)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.name") + " " + asc, 2)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.name") + " " + desc, 3)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.price") + " " + asc, 4)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.price") + " " + desc, 5)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.quantity") + " " + asc, 6)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.quantity") + " " + desc, 7)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.sl") + " " + asc, 8)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.sl") + " " + desc, 9)); BoxOrderBy.SelectedIndex = 0; // add / update button BtnSubmit = new MetroButton(); BtnSubmit.AutoSize = true; BtnSubmit.Click += HandleSubmit; BtnSubmit.Text = Root.GetMsg("srch.search"); BoxGroup.Controls.Add(BtnSubmit); BtnSubmit.Location = new Point((BoxOrderBy.Left + BoxOrderBy.Width) - BtnSubmit.Width, (BoxOrderBy.Top + BoxOrderBy.Height) + FieldPadding * 2); // reset button MetroButton BtnReset = new MetroButton(); BtnReset.AutoSize = true; BtnReset.Click += HandleReset; BtnReset.Text = Root.GetMsg("srch.reset"); BoxGroup.Controls.Add(BtnReset); BtnReset.Location = new Point(BtnSubmit.Left - BtnReset.Width - 32, BtnSubmit.Top); SP.Controls.Add(BoxGroup); BoxGroup.Margin = new Padding(_This.ContentPanel.Width / 2 - BoxGroup.Width / 2, _This.ContentPanel.Height / 2 - BoxGroup.Height / 2, 0, 0); _This.ContentPanel.Controls.Add(SP); }