예제 #1
0
파일: CheckoutForm.cs 프로젝트: nodegin/dhs
        public CheckoutForm(Root root, IParentForm parent, bool isCheckout) : base(root, parent, isCheckout ? Root.GetMsg("cart.checkout") : Root.GetMsg("cart.order"))
        {
            IsCheckout = isCheckout;
            Cart = IsCheckout ? _Root.ShoppingCart : _Root.OrderCart;
            _This.InsertActionButtons(Root.GetMsg("cart.action.clear-all"), Properties.Resources.clear_all, (sender, e) =>
            {
                Cart.Clear();
                UpdateList();
            });
            ItemList.Size = new Size((int)Math.Round(_This.ContentPanel.Width * .65) + PanePadding, _This.ContentPanel.Height);
            ItemList.Paint += (sender, e) => {
                int strip = (int)(InfoPane.Height * .1);
                Pen borderPen = new Pen(new SolidBrush(Color.FromArgb(77, 77, 77)));
                int off = ItemList.Width - 1;
                e.Graphics.DrawLine(borderPen, new Point(off, strip), new Point(off, ItemList.Height - strip - 1));
            };
            _This.ContentPanel.Controls.Add(ItemList);
            InfoPane.AutoSize = true;
            InfoPane.MinimumSize = new Size((int)Math.Round(_This.ContentPanel.Width * .35), 0);
            InfoPane.Left = ItemList.Width + PanePadding / 2;
            _This.ContentPanel.Controls.Add(InfoPane);
            InitialInfoPaneComponents();

            // must reload parent list avoid any inconsistency
            OverrideBackReloadDHS = true;
            UpdateList();
        }
예제 #2
0
파일: BackableForm.cs 프로젝트: nodegin/dhs
 public BackableForm(Root root, IParentForm parent, string name)
 {
     _Parent = parent;
     _RefRoot = root;
     _RefThis = new MetroForm(_Root, name, 1136, 720, OnBack);
     _This.Tag = this;
     if (_Parent.GetType().BaseType == typeof(MetroForm))
     {
         _Parent.AnimateHideForm((sn, ev) =>
         {
             ((MetroForm)_Parent).Hide(((MetroForm)_Parent));
         });
     }
     else
     {
         IParentForm parentAtTaskBar = _Parent;
         while (((BackableForm)parentAtTaskBar)._Parent.GetType() != typeof(MainForm))
         {
             parentAtTaskBar = ((BackableForm)parentAtTaskBar)._Parent;
         }
         _Parent.AnimateHideForm((sn, ev) =>
         {
             ((BackableForm) parentAtTaskBar)._This.Hide(((BackableForm) parentAtTaskBar)._This);
         });
     }
 }
예제 #3
0
 public ImportFurnitureForm(Root root, IParentForm parent) : base(root, parent, Root.GetMsg("main.menu.import-furnitures"))
 {
     _This.InsertActionButtons(Root.GetMsg("imfu.import-csv"), Properties.Resources.import_file, ActionImportFromCSV);
     ItemList.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height - TopSelectorBarSize);
     ItemList.Top = TopSelectorBarSize;
     _This.ContentPanel.Controls.Add(ItemList);
     InsertCategorySelector();
 }
예제 #4
0
파일: EditItemForm.cs 프로젝트: nodegin/dhs
 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);
 }
예제 #5
0
        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);
        }
예제 #6
0
 public Controler(IParentForm iparent, ChildFormFactory factory)
 {
     this.IParentFrm = iparent;
     this.IParentFrm.IMDIControler = this;
     this.Factory            = factory;
     this.Factory.MControler = this;
     iparent.SetFrmText(this.Factory.MDIFrmText);
     this.IParentFrm.SetChildrenButton(factory.ItemParamters);
     this.IChildrens = this.Factory.GetOneOrMoreForm();
 }
        public static IParentForm FindForm(String PClassname, String Caption = null, bool IsPrintout = false)
        {
            IParentForm form = null;

            //check if form is already opened, to reuse it
            if (Caption != null)
            {
                if (SubCategories.Select(String.Format("ListForm = '{0}'", PClassname)).Length > 0 &&
                    SubCategories.Select(String.Format("ListForm = '{0}'", PClassname))[0]["Category"].ToString() == "Report")
                {
                    form = Classes.Find(c => c.Name == PClassname && c.Caption == "Report");
                }
                else
                {
                    form = Classes.Find(c => c.Name == PClassname && c.Caption == Caption);
                }

                if (form != null)
                {
                    Classes.Remove(form);
                }
            }

            //open new instance
            if (IsPrintout)
            {
                if (form == null && Type.GetType("Jk_Accounting_Software.External.Report." + PClassname) != null)
                {
                    form = Activator.CreateInstance(Type.GetType("Jk_Accounting_Software.External.Report." + PClassname)) as IParentForm;
                }
            }
            else
            {
                foreach (DataRow category in Categories.Rows)
                {
                    if (form == null && Type.GetType("Jk_Accounting_Software.External." + category["Name"] + "." + PClassname) != null)
                    {
                        form = Activator.CreateInstance(Type.GetType("Jk_Accounting_Software.External." + category["Name"] + "." + PClassname)) as IParentForm;
                    }
                }
            }

            //assign tag for navigation purposes of all opened forms
            if (form != null)
            {
                form.Parent = ParentPanel;
                form.Tag    = CurrentTag;
                CurrentTag++;
            }

            return(form);
        }
        public static IParentForm OpenPreviousForm(IParentForm form)
        {
            if (Classes.Find(c => c.Tag.ToString() == form.Tag.ToString() && c.Name == form.Name) != null)
            {
                Classes.Remove(Classes.Find(c => c.Tag.ToString() == form.Tag.ToString() && c.Name == form.Name));
            }

            if (Classes.Count > 0)
            {
                return(Classes[Classes.Count - 1]);
            }

            return(null);
        }
예제 #9
0
        public CreateDatabaseForm(SqlServer dbServer, WindowLogging loggingWindow, IParentForm parentForm)
        {
            InitializeComponent();

            _dbServer      = dbServer;
            _loggingWindow = loggingWindow;
            _parentForm    = parentForm;

            if (_dbServer.Connected)
            {
                this.gbCreateDB.Enabled = true;

                var dbs = _dbServer.DatabaseList().ToArray();
                cmbTargetDatabase.Items.AddRange(dbs);

                cmbTargetCollation.Items.AddRange(_dbServer.ServerCollations.ToArray());
            }
        }
 //This will store the opened forms for further retrieving rather than creating a new instance of the form
 public static void AddUsedForm(IParentForm PClassname)
 {
     Classes.Add(PClassname);
 }
예제 #11
0
 public FurnitureDetailsForm(Root root, IParentForm parent, Furniture item) : base(root, parent, item.Name)
 {
     _Item = item;
     if (Root.CurrentStaff.IsManager())
     {
         _This.InsertActionButtons(Root.GetMsg("edit.title"), Properties.Resources.edit, EditDetails);
         _This.InsertActionButtons(Root.GetMsg("edit.delete-item"), Properties.Resources.delete, DeleteItem);
     }
     int borderSpacing = 12;
     Font fieldFont = new Font("Segoe UI Light", 15);
     // left side description pane
     Panel leftSide = new Panel();
     leftSide.AutoSize = true;
     leftSide.Width = (int)(_This.ContentPanel.Width * .5);
     _This.ContentPanel.Controls.Add(leftSide);
     PictureBox pic = new PictureBox();
     pic.Image = Properties.Resources.loader_medium;
     pic.ImageLocation = _Item.Photo.AbsoluteUri;
     pic.Size = new Size(200, 200);
     pic.Paint += (sender, e) => {
         ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 0, pic.Width, pic.Height), Color.FromArgb(64, 128, 128, 128), ButtonBorderStyle.Solid);
     };
     pic.SizeMode = PictureBoxSizeMode.CenterImage;
     pic.LoadCompleted += (sender, e) => {
         pic.SizeMode = PictureBoxSizeMode.Zoom;
     };
     leftSide.Controls.Add(pic);
     pic.Location = new Point(leftSide.Width / 2 - pic.Width / 2, borderSpacing * 2);
     // description
     Label desc = new Label();
     desc.AutoSize = true;
     desc.MaximumSize = new Size(leftSide.Width, _This.ContentPanel.Height - _This.ContentPanel.Top - pic.Height - pic.Top * 2);
     desc.Font = fieldFont;
     desc.ForeColor = Color.FromArgb(204, 204, 204);
     desc.Padding = new Padding(borderSpacing * 2, borderSpacing * 4, borderSpacing * 2, borderSpacing * 2);
     desc.Text = _Item.Description;
     leftSide.Controls.Add(desc);
     desc.Location = new Point(leftSide.Width / 2 - desc.Width / 2, _This.ContentPanel.Top + pic.Height - pic.Top * 2);
     leftSide.Top = _This.ContentPanel.Height / 2 - leftSide.Height / 2;
     // right side details pane
     Panel rightSide = new Panel();
     rightSide.Left = leftSide.Width;
     rightSide.Size = new Size(_This.ContentPanel.Width - rightSide.Left, _This.ContentPanel.Height);
     // textboxes for _Item k
     Label kes = new Label();
     kes.TextAlign = ContentAlignment.MiddleRight;
     kes.Size = new Size((int)(rightSide.Width * .4) - borderSpacing, rightSide.Height);
     kes.Font = fieldFont;
     kes.Text = Root.GetMsg("edit.id") + "\n\n" +
         Root.GetMsg("edit.dimen") + "\n\n" +
         Root.GetMsg("edit.price") + "\n\n" +
         Root.GetMsg("edit.discount") + "\n\n" +
         Root.GetMsg("edit.quantity") + "\n\n" +
         Root.GetMsg("edit.rl") + "\n\n" +
         Root.GetMsg("edit.sl") + "\n\n" +
         Root.GetMsg("edit.category") + "\n\n" +
         Root.GetMsg("edit.subcategory") + "\n\n" +
         Root.GetMsg("edit.date");
     rightSide.Controls.Add(kes);
     // textboxes for _Item v
     Label ves = new Label();
     ves.TextAlign = ContentAlignment.MiddleLeft;
     ves.ForeColor = Color.FromArgb(204, 204, 204);
     ves.Font = fieldFont;
     ves.Size = new Size((int)(rightSide.Width * .6) - borderSpacing, rightSide.Height);
     ves.Text = _Item.ID + "\n\n" +
         _Item.Dimension.Replace("x", " × ") + "\n\n" +
         _Item.Price.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + "\n\n" +
         _Item.Discount + "%" + "\n\n" +
         _Item.Quantity + "\n\n" +
         _Item.ReorderLevel + "\n\n" +
         _Item.ShelfLocation + "\n\n" +
         _Item.Category + "\n\n" +
         (String.IsNullOrEmpty(_Item.SubCategory) ? Root.GetMsg("ui.not-set") : _Item.SubCategory) + "\n\n" +
         _Item.Date.ToString("yyyy-MM-dd HH:mm");
     ves.Left = kes.Width + borderSpacing * 2;
     rightSide.Controls.Add(ves);
     _This.ContentPanel.Controls.Add(rightSide);
 }
예제 #12
0
파일: PaymentForm.cs 프로젝트: nodegin/dhs
        public PaymentForm(Root root, IParentForm parent, bool isCheckout, bool payByCash, double total,
            bool delivery, string customer = null, string address = null, string phone = null) : base(root, parent, Root.GetMsg("cart.make-payment"))
        {
            FinalTotal = total;
            IsCheckout = isCheckout;
            PaymentMethodCash = payByCash;
            IsDelivery = delivery;
            CustomerName = customer;
            CustomerAddress = address;
            CustomerPhone = Int32.TryParse(phone, out CustomerPhone) ? CustomerPhone : -1;
            int panelpw = (int)(_This.ContentPanel.Width * (1 / 3.0));
            Panel container = new Panel();
            container.AutoSize = true;
            // amount
            Label hintAmount = new Label();
            hintAmount.AutoSize = true;
            hintAmount.Text = delivery ? Root.GetMsg("cart.deposit") : Root.GetMsg("cart.total");
            hintAmount.Font = new Font("Segoe UI Light", 13);
            hintAmount.ForeColor = Color.FromArgb(204, 204, 204);
            container.Controls.Add(hintAmount);
            hintAmount.Location = new Point(0, offsetY);
            bool canPay = false;
            if (delivery)
            {
                Label hintDeposit = new Label();
                hintDeposit.AutoSize = true;
                hintDeposit.Text = "(" + (total * .2).ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + " - " + total.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + ")";
                hintDeposit.Font = new Font("Segoe UI Light", 12);
                hintDeposit.ForeColor = Color.FromArgb(255, 213, 77);
                container.Controls.Add(hintDeposit);
                hintDeposit.Location = new Point(hintAmount.Width, offsetY + hintAmount.Height / 2 - hintDeposit.Height / 2);
            }
            offsetY += hintAmount.Height + 12;
            Control amount;
            if (delivery)
            {
                amount = new MetroTextBox(panelpw, 32);
                amount.KeyPress += Validation.FloatField;
                amount.KeyUp += (sender, e) =>
                {
                    double deposit = double.TryParse(amount.Text, out deposit) ? deposit : 0.0;
                    double minimum = total * .2;
                    if (deposit >= minimum && deposit <= total)
                    {
                        canPay = true;
                        /*if (PaymentMethodCash) _This.SelectNextControl((Control)sender, true, true, true, true);
                        else */if (!PaymentMethodCash) CashIn.ForeColor = Color.White;
                    }
                    else
                    {
                        canPay = false;
                        if (!BtnPaid.Disabled) BtnPaid.Disabled = true;
                        if (!PaymentMethodCash) CashIn.ForeColor = Color.Gray;
                    }
                };
            }
            else
            {
                amount = new Label();
                amount.AutoSize = true;
                amount.Text = total.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK"));
                amount.Font = new Font("Segoe UI Light", 16);
                canPay = true;
            }
            container.Controls.Add(amount);
            amount.Location = new Point(0, offsetY);
            offsetY += amount.Height + 12;
            // cash in
            Label hintCashIn = new Label();
            hintCashIn.AutoSize = true;
            hintCashIn.Text = Root.GetMsg("cart.cash-in");
            hintCashIn.Font = new Font("Segoe UI Light", 13);
            hintCashIn.ForeColor = Color.FromArgb(204, 204, 204);
            container.Controls.Add(hintCashIn);
            hintCashIn.Location = new Point(0, offsetY);
            offsetY += hintCashIn.Height + 12;
            if (PaymentMethodCash)
            {
                Change.Text = 0.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK"));
                MetroTextBox tbx = new MetroTextBox(panelpw, 32);
                tbx.KeyPress += Validation.FloatField;
                EventHandler eh = new EventHandler((sender, e) =>
                {
                    double paid = double.TryParse(tbx.Text, out paid) ? paid : 0.0;
                    // <!> MUST be used only in Deposit scenario
                    double deposit = double.TryParse(amount.Text, out deposit) ? deposit : 0.0;
                    // </!> MUST be used only in Deposit scenario
                    double ttl = delivery ? deposit : total;
                    if (canPay)
                    {
                        Change.Text = (paid - ttl > 0 ? paid - ttl : 0).ToString("C", CultureInfo.CreateSpecificCulture("zh-HK"));
                        FinalAmount = ttl;
                        FinalCashIn = paid; 
                        BtnPaid.Disabled = paid < ttl;
                    }
                });
                tbx.GotFocus += eh;
                tbx.KeyUp += new KeyEventHandler(eh);
                container.Controls.Add(tbx);
                tbx.Location = new Point(0, offsetY);
                offsetY += tbx.Height + 12;
            }
            else
            {
                Change.Text = "N/A";
                // icon
                PictureBox icon = new PictureBox();
                icon.Size = new Size(24, 24);
                icon.Image = Properties.Resources.scan;
                container.Controls.Add(icon);
                icon.Location = new Point(0, offsetY);
                // status text
                CashIn = new Label();
                CashIn.AutoSize = true;
                CashIn.Text = Root.GetMsg("cart.pay-by-card");
                CashIn.Font = new Font("Segoe UI Light", 16);
                if (delivery) CashIn.ForeColor = Color.Gray;
                container.Controls.Add(CashIn);
                CashIn.Location = new Point(0 + icon.Width + 12, offsetY + (icon.Height / 2 - CashIn.Height / 2));
                offsetY += icon.Height + 12;
                // emulate payment process
                int ticked = 0;
                bool paymentSucceed = false;
                Timer emulate = new Timer();
                emulate.Interval = 500;
                emulate.Tick += (sender, e) =>
                {
                    if (paymentSucceed)
                    {
                        icon.Image = Properties.Resources.tick;
                        CashIn.Text = Root.GetMsg("cart.payment-ok");
                        BtnPaid.Disabled = false;
                        FinalAmount = !delivery ? total : double.TryParse(amount.Text, out FinalAmount) ? FinalAmount : 0.0;
                        FinalCashIn = FinalAmount; 
                        emulate.Stop();
                    }
                    else
                    {
                        if (ticked < 4)
                            CashIn.Text = Root.GetMsg("cart.payment-card-phase-1");
                        else if (ticked < 8)
                            CashIn.Text = Root.GetMsg("cart.payment-card-phase-2");
                        else if (ticked < 16)
                            CashIn.Text = Root.GetMsg("cart.payment-card-phase-3");
                        else if (ticked < 24)
                            CashIn.Text = Root.GetMsg("cart.payment-card-phase-4");
                        else
                            paymentSucceed = true;
                        ticked++;
                    }
                };
                EventHandler eh = null;
                eh = new EventHandler((sender, e) => {
                    if (delivery && !canPay) return;
                    emulate.Enabled = true;
                    emulate.Start();
                    icon.Image = Properties.Resources.loader_small;
                    icon.Click -= eh;
                    icon.Cursor = Cursors.Default;
                    CashIn.Click -= eh;
                    CashIn.Cursor = Cursors.Default;
                });
                icon.Click += eh;
                icon.Cursor = Cursors.Hand;
                CashIn.Click += eh;
                CashIn.Cursor = Cursors.Hand;
            }
            // changes
            Label hintChange = new Label();
            hintChange.AutoSize = true;
            hintChange.Text = Root.GetMsg("cart.change");
            hintChange.Font = new Font("Segoe UI Light", 13);
            hintChange.ForeColor = Color.FromArgb(204, 204, 204);
            container.Controls.Add(hintChange);
            hintChange.Location = new Point(0, offsetY);
            offsetY += hintChange.Height + 12;
            Change.AutoSize = true;
            Change.Font = new Font("Segoe UI Light", 16);
            container.Controls.Add(Change);
            Change.Location = new Point(0, offsetY);
            offsetY += Change.Height + 12;
            // offset for buttons
            offsetY += 32;
            // mark order paid
            BtnPaid.AutoSize = true;
            BtnPaid.Text = Root.GetMsg("cart.mark-and-return");
            BtnPaid.Click += ActionPaymentCompleted;
            BtnPaid.Disabled = true;
            container.Controls.Add(BtnPaid);
            BtnPaid.Location = new Point(0, offsetY);
            offsetY += BtnPaid.Height + 12;
            // print invoice checkbox
            container.Controls.Add(PrintInvoice);
            PrintInvoice.Location = new Point(BtnPaid.Left + BtnPaid.Width + 32, BtnPaid.Top + BtnPaid.Height / 2 - PrintInvoice.Height / 2);
            Label hintPrintInvoice = new Label();
            hintPrintInvoice.AutoSize = true;
            hintPrintInvoice.Text = Root.GetMsg("cart.print-invoice");
            hintPrintInvoice.Font = new Font("Segoe UI Light", 12);
            hintPrintInvoice.ForeColor = Color.FromArgb(204, 204, 204);
            container.Controls.Add(hintPrintInvoice);
            hintPrintInvoice.Location = new Point(PrintInvoice.Left + PrintInvoice.Width + 8, BtnPaid.Top + BtnPaid.Height / 2 - hintPrintInvoice.Height / 2);

            _This.ContentPanel.Controls.Add(container);
            container.Location = new Point(_This.ContentPanel.Width / 2 - container.Width / 2, _This.ContentPanel.Height / 2 - container.Height / 2 - _This.ContentPanel.Top / 2);
        }
예제 #13
0
 public CartActionPanel(IParentForm parent, int rowSize, Furniture data, bool isOrder, EventHandler callback = null)
 {
     Parent = parent;
     Item = data;
     IsOrderCart = isOrder;
     Cart = IsOrderCart ? parent._Root.OrderCart : parent._Root.ShoppingCart;
     Callback = callback;
     this.BackColor = Color.FromArgb(77, 77, 77);
     this.Size = new Size((int)(rowSize * 1.25), rowSize - 2);
     this.Margin = Padding.Empty;
     // label number in cart   
     ItemQuantity.BorderStyle = BorderStyle.None;
     ItemQuantity.BackColor = this.BackColor;
     ItemQuantity.Font = new Font("Segoe UI Light", 18);
     ItemQuantity.TextAlign = HorizontalAlignment.Center;
     ItemQuantity.ForeColor = Color.White;
     ItemQuantity.MaximumSize = new Size(this.Width - 32 - 1, this.Height);
     if (Cart.ContainsKey(Item.ID))
         ItemQuantity.Text = Cart[Item.ID].ToString();
     else
         ItemQuantity.Text = "0";
     bool txtChanged = false;
     Timer checkText = new Timer();
     checkText.Tick += (sender, e) =>
     {
         checkText.Stop();
         if (ItemQuantity.Text.Length < 1) return;
         int inputtedQty = Int32.Parse(ItemQuantity.Text);
         if (inputtedQty < 0 || inputtedQty > (IsOrderCart ? Item.InventoryQuantity : Item.Quantity))
             inputtedQty = (IsOrderCart ? Item.InventoryQuantity : Item.Quantity);
         int oldQty = Cart.ContainsKey(Item.ID) ? Cart[Item.ID] : 0;
         Cart[Item.ID] = inputtedQty;
         ItemQuantity.Text = inputtedQty.ToString();
         ItemQuantity.Select(ItemQuantity.Text.Length, 0);
         if (txtChanged && null != Callback) Callback(oldQty, e);
         txtChanged = false;
     };
     checkText.Enabled = true;
     ItemQuantity.ImeMode = System.Windows.Forms.ImeMode.Disable;
     ItemQuantity.MaxLength = 4;
     ItemQuantity.TextChanged += (sender, e) => {
         checkText.Stop();
         txtChanged = true;
         checkText.Start();
     };
     ItemQuantity.KeyPress += (sender, e) => { Validation.NumberField(sender, e, 4); };
     ItemQuantity.Leave += (sender, e) => {
         if (String.IsNullOrEmpty(ItemQuantity.Text))
         {
             Cart[Item.ID] = 0;
             ItemQuantity.Text = "0";
         }
     };
     this.Controls.Add(ItemQuantity);
     ItemQuantity.Top = this.Height / 2 - ItemQuantity.Height / 2;
     // increase amount button
     AddItem.BackgroundImage = Properties.Resources.arrow_increase;
     AddItem.BackColor = IsOrderCart ? Color.FromArgb(204, 128, 34) : Color.FromArgb(77, 160, 45);
     AddItem.FlatStyle = FlatStyle.Flat;
     AddItem.FlatAppearance.BorderSize = 0;
     AddItem.BackgroundImageLayout = ImageLayout.Center;
     AddItem.Size = new Size(32, (int)(this.Height * .5));
     AddItem.Click += UpdateCart;
     AddItem.Left = ItemQuantity.Width + 1;
     AddItem.TabStop = false;
     this.Controls.Add(AddItem);
     // decrease amount button
     SubtractItem.BackgroundImage = Properties.Resources.arrow_decrease;
     SubtractItem.BackColor = AddItem.BackColor;
     SubtractItem.FlatStyle = AddItem.FlatStyle;
     SubtractItem.FlatAppearance.BorderSize = AddItem.FlatAppearance.BorderSize;
     SubtractItem.BackgroundImageLayout = AddItem.BackgroundImageLayout;
     SubtractItem.Size = AddItem.Size;
     SubtractItem.Top = AddItem.Height;
     SubtractItem.Left = AddItem.Left;
     SubtractItem.Click += UpdateCart;
     SubtractItem.TabStop = false;
     this.Controls.Add(SubtractItem);
 }