Exemple #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();
        }
Exemple #2
0
        void B_ChangeDate_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];
            DateTime        oldDate = DateTime.Parse((string)row.Cells["COL_Date"].Value);

            DateTime newDate;

            using (FRM_SelectDateOfSale frmSelectDate = new FRM_SelectDateOfSale("-", -1, -1))
            {
                if (frmSelectDate.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                newDate = frmSelectDate.Date;
            }

            if (newDate == oldDate)
            {
                MessageBox.Show(this, Resources.NEW_DATE_IS_SAME_AS_OLD_ONE_SO_CHANGE_NOTHING, Resources.CANCELATION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                DocSale sale = DocSale.Restore((int)(long)row.Cells["COL_Id"].Value);
                sale.TimeSold = newDate;
                sale.Flush();
            }
        }