Exemplo n.º 1
0
        public static void SaveGrn(Grn grn)
        {
            using (RetailDbContext retailDbContext = new RetailDbContext())
            {
                retailDbContext.Grns.Add(grn);
                retailDbContext.SaveChanges(); //This will give us a unique GrnID

                //QtyOnHand change
                foreach (Grnline gl in grn.Grnlines)
                {
                    StoreProduct storeProduct = retailDbContext.StoreProducts.ToList().SingleOrDefault <StoreProduct>(x => (x.ProductID == gl.ProductID) && (x.StoreID == grn.StoreID));
                    if (storeProduct == null)
                    {
                        storeProduct            = new StoreProduct();
                        storeProduct.ProductID  = gl.ProductID;
                        storeProduct.StoreID    = grn.StoreID;
                        storeProduct.QtyOnHand += gl.Quantity;
                        retailDbContext.StoreProducts.Add(storeProduct);
                    }
                    else
                    {
                        storeProduct.QtyOnHand += gl.Quantity;
                    }

                    StoreProductTran storeProductTran = new StoreProductTran();
                    storeProductTran.ProductID     = storeProduct.ProductID;
                    storeProductTran.DocumentType  = "G";
                    storeProductTran.DocumentID    = grn.GrnID;
                    storeProductTran.Quantity      = gl.Quantity;
                    storeProductTran.EffectiveTime = grn.TransactionTime;
                    retailDbContext.StoreProductTrans.Add(storeProductTran);
                }
                retailDbContext.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PutGrn(int id, Grn grn)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != grn.Id)
            {
                return(BadRequest());
            }

            db.Entry(grn).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GrnExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
 private void UploadGrn(Grn g)
 {
     Task taskA = Task.Factory.StartNew(() =>
     {
         PosWebService.PosWebServiceClient client = new PosWebService.PosWebServiceClient();
         client.UploadGrn(g);
     });
 }
Exemplo n.º 4
0
        public void FinaliseGrn(Grn g)
        {
            g.TransactionTime = DateTime.Now;
            DBRepository.SaveGrn(g);

            //Replicate to HODB using WCF service in a TPL task
            UploadGrn(g);
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> GetGrn(int id)
        {
            Grn grn = await db.Grns.FindAsync(id);

            if (grn == null)
            {
                return(NotFound());
            }

            return(Ok(grn));
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> PostGrn([FromBody] Grn datas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Grns.Add(datas);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = datas.Id }, datas));
        }
Exemplo n.º 7
0
        public async Task <IHttpActionResult> DeleteGrn(int id)
        {
            Grn grn = await db.Grns.FindAsync(id);

            if (grn == null)
            {
                return(NotFound());
            }

            db.Grns.Remove(grn);
            await db.SaveChangesAsync();

            return(Ok(grn));
        }
Exemplo n.º 8
0
        public XtraReport GenerateReport(NameValueCollection parameters)
        {
            var grnReport = new Grn();

            var grnReportData = AsyncContext.Run(() => _reportService.GetGrnReport(long.Parse(parameters["id"])));

            var grnObjectDataSource = new ObjectDataSource
            {
                DataSource = grnReportData,
                Name       = "GrnDataSource"
            };

            grnReport.DataSource = grnObjectDataSource;

            return(grnReport);
        }
Exemplo n.º 9
0
 public void UploadGrn(Grn grn)
 {
     DBRepository.SaveGrn(grn);
 }
Exemplo n.º 10
0
 public ActionResult FinaliseGrn(Grn grn)
 {
     rm.FinaliseGrn(grn);
     return(View("Index", rm));
 }
Exemplo n.º 11
0
 public GrnVM()
 {
     TheEntity = new Grn();
 }