Пример #1
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            List <CommonContract> list = await SAContract.GetAllContracts("Direct Sale");

            if (list.Count > 1 || list.Count == 0)
            {
                MessageBox.Show("Can not find direct sale user!");
                return;
            }

            CommonSale s = new CommonSale();

            s.BuyerId   = list.First().PartnerId;
            s.SellerId  = (DataHolder.Owner.OwnerId);
            s.SoldItems = new List <CommonSoldItem>();


            foreach (DataGridViewRow row in dgvSoldGoods.Rows)
            {
                var index = (int)row.Cells[6].Value;
                KeyValuePair <int, decimal> pair = DataHolder.Settings.VatSettingsByGroup.FirstOrDefault(p => p.Key == index);
                var item = new CommonSoldItem();
                if (row.Cells[5].Value != null)
                {
                    item.Price    = (1 + pair.Value) * decimal.Parse(row.Cells[3].Value.ToString());
                    item.Quantity = int.Parse(row.Cells[1].Value.ToString());
                    item.ItemId   = (Guid)row.Cells[5].Value;

                    s.SoldItems.Add(item);
                }
            }

            var sale = await SASale.PostCreateDirectSale(s);

            if (sale == null)
            {
                errorLabel.Visible = true;
                errorLabel.Text    = "not_enough_quantity";
            }
            else
            {
                ClearAll();
            }

            SalesReceiptForm form = new SalesReceiptForm(sale);

            if (form.ShowDialog() == DialogResult.OK)
            {
            }
        }
Пример #2
0
        private void btnViewSaleReceipt_Click(object sender, EventArgs e)
        {
            if (dgvTransactions.SelectedRows.Count == 1 && dgvTransactions.SelectedRows[0] != null)
            {
                CommonSale selectedItem = (CommonSale)dgvTransactions.SelectedRows[0].DataBoundItem;

                if (!string.IsNullOrEmpty(selectedItem.InvoiceId))
                {
                    SalesReceiptForm form = new SalesReceiptForm(selectedItem, false);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("Няма издаден документ към продажбата!");
                }
            }
        }