Ejemplo n.º 1
0
        void B_Sell_Click(object sender, System.EventArgs e)
        {
            if (!int.TryParse(T_Amount.Text, out int amount) || amount < 1)
            {
                MessageBox.Show(this, Resources.INVALID_SKU_QTY_IS_ENTERED, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (amount > _selectedCell.Amount)
            {
                MessageBox.Show(this, Resources.QTY_TOO_BIG_FOR_GIVEN_CELL, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (!int.TryParse(T_PriceOfSell.Text, out int unitPrice) || unitPrice < 0)
            {
                MessageBox.Show(this, Resources.INVALID_UNIT_PRICE_OF_SELL, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DateTime dateOfSale      = DateTime.Today;
            bool     dateNotSelected = true;
            bool     paymentByCard   = false;

            while (dateNotSelected)
            {
                using (FRM_SelectDateOfSale frmDateSelector = new FRM_SelectDateOfSale(_skuInStock.Article.Name, amount, unitPrice))
                {
                    if (frmDateSelector.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    dateOfSale = frmDateSelector.Date;

                    DateTime maxOldDate = DateTime.Today.AddDays(-19);
                    if (maxOldDate.CompareTo(dateOfSale) > 0)
                    {
                        string month = c_months[dateOfSale.Month - 1].ToUpper();
                        if (MessageBox.Show(this, string.Format(Resources.CONFIRM_SELECTED_DATE, dateOfSale.Day, month), Resources.QUESTION_ABOUT_DATE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            continue;
                        }
                    }

                    Settings.Default.LastDateOfSale = frmDateSelector.Date;
                    Settings.Default.Save();
                    dateNotSelected = false;

                    paymentByCard = frmDateSelector.PaymentByCard;
                }
            }

            // TODO: Implement transaction
            _selectedCell         = _skuInStock[_selectedCell.X, _selectedCell.Y]; // This is because of whilst render of the size chart, it's current cell can detach itself from the SKU on the object level (see comment about re-calculating above)
            _selectedCell.Amount -= amount;
            _skuInStock.Flush();
            DocSale sale = DocSale.CreateNew(dateOfSale, _skuInStock.Article, _skuInStock.PointOfSale, unitPrice, amount, _selectedCell, paymentByCard);

            sale.Flush();

            ((PanelViewSku)Parent.Parent.Parent).UpdateWOldSearch();
        }
Ejemplo n.º 2
0
        public ManageSkuMiniPanel(DataRow in_source, Control in_parent, DataTable in_pointsOfSale) : this()
        {
            _source     = in_source;
            _skuInStock = SkuInStock.Restore(Article.Restore((int)(long)_source["id"]), Registry.CurrentPointOfSale);
            Parent      = in_parent;

            T_Name.Text            = _skuInStock.Article.Name;
            T_PriceOfSell.Text     = _skuInStock.Article.PriceOfSell.ToString();
            T_InStock.Text         = _skuInStock.TotalAmount.ToString();
            T_PriceOfPurchase.Text = _skuInStock.Article.PriceOfPurchase.ToString();
            T_PriceOfSellPlan.Text = _skuInStock.Article.PriceOfSell.ToString();
            T_Amount.Text          = "0";

            CB_PointsOfSale.Items.AddRange(LiteBizItem.FromTable(in_pointsOfSale).ToArray());
            if (CB_PointsOfSale.Items.Count != 0)
            {
                CB_PointsOfSale.SelectedIndex = 0;
            }
            else
            {
                CB_PointsOfSale.Enabled = false;
                B_Move.Enabled          = false;
            }

            if (_skuInStock.Article.Matrix.IsSingleCell)
            {
                _selectedCell = _skuInStock[0, 0];

                T_CellX.Visible = false;
                T_CellY.Visible = false;
                B_Net.Visible   = false;

                PAN_NoNet.Visible = true;
            }
        }
Ejemplo n.º 3
0
            public NetButton(Control in_parent, CellInStock in_cell, int in_cellX, int in_cellY, int in_buttonX, int in_buttonY, int in_width, int in_height)
            {
                _cell = in_cell;
                _x    = in_cellX;
                _y    = in_cellY;

                Parent   = in_parent;
                Text     = _cell.Amount.ToString();
                Location = new Point(in_buttonX, in_buttonY);
                Size     = new Size(in_width, in_height);
            }
Ejemplo n.º 4
0
        string TextBoxToCell(TextBox in_textBox, CellInStock in_cell)
        {
            if (in_textBox.Text == string.Empty)
            {
                in_cell.Amount = 0;
                return(null);
            }

            if (!int.TryParse(in_textBox.Text, out int value) || value < 0)
            {
                return(string.Format(c_errInvalidCellQty, in_cell.X, in_cell.Y));
            }
            else
            {
                in_cell.Amount = value;
                return(null);
            }
        }
Ejemplo n.º 5
0
        void B_Net_Click(object sender, System.EventArgs e)
        {
            Cursor oldCur = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            try
            {
                Application.DoEvents();
                _skuInStock = SkuInStock.Restore(_skuInStock.Article, _skuInStock.PointOfSale); // Force re-calculating of size cells in stock
                using (FRM_CellSelector frmSelector = new FRM_CellSelector(_skuInStock))
                {
                    this.Cursor = oldCur;

                    if (frmSelector.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }

                    _selectedCell = frmSelector.SelectedCell;
                }

                T_CellX.Text = _selectedCell.X;
                T_CellY.Text = _selectedCell.Y;
                if (T_Amount.Text == string.Empty || T_Amount.Text == "0")
                {
                    T_Amount.Text = "1";
                }
                else
                {
                    if (!int.TryParse(T_Amount.Text, out int oldAmount) || oldAmount > _selectedCell.Amount)
                    {
                        T_Amount.Text = _selectedCell.Amount.ToString();
                    }
                }
            }
            finally
            {
                if (this.Cursor != oldCur)
                {
                    this.Cursor = oldCur;
                }
            }
        }
Ejemplo n.º 6
0
        void B_VoidSale_Click(object sender, EventArgs e)
        {
            if (DGV_SalesJournal.Rows.GetRowCount(DataGridViewElementStates.Selected) <= 0)
            {
                MessageBox.Show(this, Resources.NO_ROW_SELECTED, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DataGridViewRow row  = DGV_SalesJournal.SelectedRows[0];
            int             id   = (int)(long)row.Cells["COL_Id"].Value;
            string          name = (string)row.Cells["COL_ArticleName"].Value;
            int             sum  = (int)(long)row.Cells["COL_PriceSum"].Value;

            if (MessageBox.Show(this, string.Format(Resources.ASK_CANCEL_SALE, name, sum), Resources.CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            // TODO: Implement transaction
            DocSale sale = DocSale.Restore(id);

            sale.Doc.TimeCancelled = DateTime.Now;
            SkuInStock  skuInStock = SkuInStock.Restore(Article.Restore(sale.ArticleId), PointOfSale.Restore(sale.PointOfSaleId));
            CellInStock cell       = CellInStock.Restore(sale.CellX, sale.CellY, skuInStock);

            if (cell == null)
            {
                cell = CellInStock.Restore(0, DateTime.Now, skuInStock, sale.CellX, sale.CellY, sale.UnitCount, true);
            }
            else
            {
                cell.Amount += sale.UnitCount;
            }
            sale.Doc.Flush();
            cell.Flush();

            RefillTable();
        }