Beispiel #1
0
        private void cmdInOut_Click(object sender, EventArgs e)
        {
            if (_item == null)
            {
                MessageBox.Show("Please select Item!",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (txtQty.Text == "0" || string.IsNullOrWhiteSpace(txtQty.Text))
            {
                MessageBox.Show("Please provide Quantity!",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtNote.Text))
            {
                MessageBox.Show("Please provide Notes!",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            InOutParam p = new InOutParam();

            p.Item = _item;
            p.Qty  = Convert.ToDouble(txtQty.Text);
            p.Name = _name;

            if (_inOrOut == InOrOut.In)
            {
                p.InOrOut = InOrOut.In;

                string note = p.Qty + " stock(s) added to inventory of " + p.Item.Name;
                p.Note = note + " : (" + txtNote.Text + ")";

                _inOutService.In(p);
                MessageBox.Show(note);
            }
            else if (_inOrOut == InOrOut.Out)
            {
                p.InOrOut = InOrOut.Out;

                string note = p.Qty + " stock(s) subtracted to inventory of " + p.Item.Name;
                p.Note = note + " : (" + txtNote.Text + ")";

                _inOutService.Out(p);
                MessageBox.Show(note);
            }

            _haveChangedQuantity = true;
            this.Close();
        }
Beispiel #2
0
        public void In(InOutParam inParam)
        {
            Item   itemAfterIn = _itemService.Find(inParam.Item.Id);
            double oldQty      = itemAfterIn.GetAppropriateQuantity;

            InOutHelper.AddToAppopriateMeasurement(itemAfterIn, inParam.Qty);

            double newQty = itemAfterIn.GetAppropriateQuantity;

            var         p = CreateHistoryParameter(inParam, oldQty, newQty);
            ItemHistory h = InOutHelper.MakeHistory(p);

            _historyService.Add(h);
            _itemService.Edit(itemAfterIn);
        }
Beispiel #3
0
        public void Out(InOutParam outParam)
        {
            Item   itemAfterOut = _itemService.Find(outParam.Item.Id);
            double oldQty       = itemAfterOut.GetAppropriateQuantity;

            InOutHelper.SubtractToAppopriateMeasurement(itemAfterOut, outParam.Qty);

            double newQty = itemAfterOut.GetAppropriateQuantity;

            var         p = CreateHistoryParameter(outParam, oldQty, newQty);
            ItemHistory h = InOutHelper.MakeHistory(p);

            _historyService.Add(h);
            _itemService.Edit(itemAfterOut);
        }
Beispiel #4
0
        private static HistoryParam CreateHistoryParameter(InOutParam param, double oldQty, double newQty)
        {
            HistoryParam p = new HistoryParam();

            p.InOrOut       = param.InOrOut;
            p.ItemToMonitor = param.Item;
            p.OldQty        = oldQty;
            p.NewQty        = newQty;

            p.InOutQty = param.Qty;
            p.Note     = param.Note;
            p.Name     = param.Name;

            return(p);
        }