Beispiel #1
0
 private void UpdateIssueItem(SKIssueItem item)
 {
     if (new StockDAL().UpdateIssueItem(item, _issueItemMode) <= 0)
     {
         MessageBox.Show("Can't update issue item!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
        public int UpdateIssueItem(SKIssueItem item, DataActionMode mode)
        {
            try
            {
                switch (mode)
                {
                case DataActionMode.Add:
                    _context.SKIssueItems.Add(item);
                    break;

                case DataActionMode.Edit:
                    var _item = GetIssueItemInfo(item.Id);
                    _item.Currency       = item.Currency;
                    _item.IsPosted       = item.IsPosted;
                    _item.IssueQty       = item.IssueQty;
                    _item.ItemId         = item.ItemId;
                    _item.ItemName       = item.ItemName;
                    _item.ItemNo         = item.ItemNo;
                    _item.UnitPrice      = item.UnitPrice;
                    _item.UnitCost       = item.UnitCost;
                    _item.TotalItemCost  = item.TotalItemCost;
                    _item.TotalItemPrice = item.TotalItemPrice;
                    _item.Unit           = item.Unit;
                    break;
                }

                return(_context.SaveChanges());
            }
            catch
            {
                return(0);
            }
        }
Beispiel #3
0
        private void getItem(int id)
        {
            switch (_issueItemMode)
            {
            case DataActionMode.Add:
                _item                = new SKIssueItem();
                _item.Currency       = "USD";
                _item.IsPosted       = false;
                _item.IssueQty       = 0m;
                _item.ItemId         = 0;
                _item.ItemName       = "";
                _item.ItemNo         = "";
                _item.SKI_ISSUE_NUM  = _issueNo;
                _item.SK_Code        = _skCode;
                _item.Unit           = "PC";
                _item.TotalItemPrice = 0m;
                _item.TotalItemCost  = 0m;
                _item.UnitPrice      = 0m;
                _item.UnitCost       = 0m;

                break;

            case DataActionMode.Edit:
                _item = new StockDAL().GetIssueItemInfo(id);
                break;
            }

            txtIssueQty.Text        = $"{_item.IssueQty:N2}";
            txtItemName.Text        = _item.ItemName;
            txtItemNo.Text          = _item.ItemNo;
            txtCurrency.Text        = _item.Currency;
            txtUnitCost.Text        = $"{_item.UnitCost:N2}";
            txtTotalCost.Text       = $"{_item.TotalItemCost:N2}";
            txtUnitPrice.Text       = $"{_item.UnitPrice:N2}";
            txtTotalIssuePrice.Text = $"{_item.TotalItemPrice:N2}";
            cbxUnit.SelectedValue   = _item.Unit;

            if (_issueItemMode == DataActionMode.Edit)
            {
                GetItemOnhand(_item.ItemNo);
            }

            updateUI();
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            _item.Currency       = txtCurrency.Text;
            _item.IssueQty       = Convert.ToDecimal(txtIssueQty.Text);
            _item.ItemNo         = txtItemNo.Text;
            _item.ItemName       = txtItemName.Text;
            _item.UnitPrice      = Convert.ToDecimal(txtUnitPrice.Text);
            _item.TotalItemPrice = Convert.ToDecimal(txtTotalIssuePrice.Text);
            _item.UnitCost       = Convert.ToDecimal(txtUnitCost.Text);
            _item.TotalItemCost  = Convert.ToDecimal(txtTotalCost.Text);

            switch (_issueMode)
            {
            case DataActionMode.Add:
                this.IssueItem = _item;
                break;

            case DataActionMode.Edit:
                UpdateIssueItem(_item);
                break;
            }
        }