public async Task <long> CreateBillImportAsync(BillImportRequest billImportRequest)
        {
            var billImport = new BillImport
            {
                UserId         = billImportRequest.UserId,
                TotalPrice     = billImportRequest.TotalPrice,
                BillImportType = billImportRequest.BillImportType,
                CreationTime   = billImportRequest.CreationTime
            };

            dbContext.BillImports.Add(billImport);
            await dbContext.SaveChangesAsync();

            return(billImport.Id);
        }
Exemplo n.º 2
0
        private void BtImpCreate_Click(object sender, EventArgs e)
        {
            if (TxtImpStorekeeper.Text == "" || TxtImpDeliver.Text == "")
            {
                MessageBox.Show("Fill in all information");
                return;
            }
            BillImport Bill = new BillImport();

            Bill.IDCompany     = Convert.ToInt16(CbImpSupplier.SelectedValue.ToString());
            Bill.IDStoreKeeper = Medium.IdSto;
            Bill.NameCustom    = TxtImpDeliver.Text;
            Bill.DateImport    = DateImp.Value;
            db.BillImports.Add(Bill);
            db.SaveChanges();
            for (int i = 0; i < DgvImpPro.RowCount; i++)
            {
                DetailImport Detail = new DetailImport();
                Detail.IDBill    = Bill.ID;
                Detail.IDProduct = Convert.ToInt16(DgvImpPro.Rows[i].Cells["ID"].Value.ToString());
                var res = db.DetailImports.Where(p => p.IDBill == Detail.IDBill && p.IDProduct == Detail.IDProduct).SingleOrDefault();
                if (res != null)
                {
                    res.Quantity = res.Quantity + Convert.ToInt16(DgvImpPro.Rows[i].Cells["Quantity"].Value.ToString());
                    db.SaveChanges();
                }
                else
                {
                    Detail.Quantity = Convert.ToInt16(DgvImpPro.Rows[i].Cells["Quantity"].Value.ToString());
                    db.DetailImports.Add(Detail);
                    db.SaveChanges();
                }
            }
            MessageBox.Show("Add Item successfully");
            LoadDgv();
            LoadDetail();
            LoadDgvPro();
            LoadDetailPro();
        }
Exemplo n.º 3
0
 public void init()
 {
     billImport = new BillImport();
     AddActionClassesToList(billImport);
 }