예제 #1
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();
            }
        }
예제 #2
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();
        }