protected void btnSave_Click(object sender, EventArgs e)
        {
            var receivingManager = new ReceivingManager();
            var receivingDetailManager = new ReceivingDetailManager();
            var newReceiving = new Receiving
            {
                AloBsNumber = txtAlobsNumber.Text,
                Amount = decimal.Parse(txtAmount.Text),
                SellingAmount = decimal.Parse(txtSellingAmount.Text),
                CategoryId = int.Parse(DDLCategories.SelectedValue),
                DepartmentId = int.Parse(DDLDepartments.SelectedValue),
                EndUserId = 0, // todo: to be replace by logged user
                InvoiceNumber = txtInvoiceNumber.Text,
                ModeProcurement = txtModeProcurement.Text,
                PrNumber = txtPRNumber.Text,
                PurchaseOrderNumber = txtPONumber.Text,
                ReceivingDate = DateTime.Parse(txtReceivingDate.Text),
                ReceivingKey = Guid.NewGuid(),
                ReferenceNumber = txtReferenceNumber.Text,
                Status = true,
                SupplierId = int.Parse(DDLSuppliers.SelectedValue),
                Uid = Guid.NewGuid()
            };
            receivingManager.Save(newReceiving);

            var identity = receivingManager.Identity;

            var receivingDetails = ReceivedItems().Select(item => new ReceivingDetail
            {
                Barcode = item.Barcode,
                BinId = item.BinId,
                DateCreated = DateTime.Now,
                DepartmentId = item.DepartmentId,
                ExpiryDate = item.ExpiryDate,
                ItemId = item.ItemId,
                LocationId = item.LocationId,
                Price = item.Price,
                RackId = item.RackId,
                ReceiveQuantity = item.ReceivedQuantity,
                ReceivingId = identity,
                ReceivingReamrks = item.Remarks,
                ReferenceNumber = item.ReferenceNumber,
                Remarks = item.Remarks,
                SellingPrice = item.SellingPrice,
                Shelfid = item.ShelveId,
                SupplierId = item.SupplierId,
                TotalAmount = item.TotalAmount,
                UnitId = item.UnitId,
                Uid = Guid.NewGuid()
            }).ToList();

            receivingDetailManager.Save(receivingDetails);
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     var newReceiving = new Receiving
     {
         AloBsNumber = txtAlobsNumber.Text,
         Amount = decimal.Parse(txtAmount.Text),
         SellingAmount = decimal.Parse(txtSellingAmount.Text),
         CategoryId = int.Parse(DDLCategories.SelectedValue),
         DepartmentId = int.Parse(DDLDepartments.SelectedValue),
         EndUserId = 0, // todo: to be replace by logged user
         InvoiceNumber = txtInvoiceNumber.Text,
         ModeProcurement = txtModeProcurement.Text,
         PrNumber = txtPRNumber.Text,
         PurchaseOrderNumber = txtPONumber.Text,
         ReceivingDate = DateTime.Parse(txtReceivingDate.Text),
         ReceivingKey = Guid.NewGuid(),
         ReferenceNumber = txtReferenceNumber.Text,
         Status = true,
         SupplierId = int.Parse(DDLSuppliers.SelectedValue),
         Uid = Guid.NewGuid(),
         Id = ReceivingId
     };
     _receivingManager.Save(newReceiving);
 }