예제 #1
0
        private async System.Threading.Tasks.Task AddDeliveryAsyncs(SortedList <int, string> IDList)
        {
            //ContactId	FirstName	LastName	MobileNo	PhoneNo	EMailAddress	Remarks	UserName

            var ws = xS.GetWS("Deliveries");
            var nonEmptyDataRows = ws.RowsUsed();
            int Row = 6;//Title;

            foreach (var dR in nonEmptyDataRows)
            {
                if (dR.RowNumber() > Row)
                {
                    //TalioringDeliveryId	DeliveryDate	TalioringBookingId	InvNo	Amount	Remarks	StoreId	UserName

                    TalioringDelivery del = new TalioringDelivery
                    {
                        DeliveryDate       = dR.Cell(2).GetDateTime(),
                        TalioringBookingId = await GetIDAsync(IDList.GetValueOrDefault(dR.Cell(3).GetValue <int>())),
                        InvNo   = dR.Cell(4).GetValue <string>(),
                        Amount  = dR.Cell(5).GetValue <decimal>(),
                        Remarks = dR.Cell(6).GetValue <string>(),
                        StoreId = 1,
                        //StoreId=dR.Cell(7).GetValue<int>(),
                        UserId      = dR.Cell(8).Value.ToString(),
                        IsReadOnly  = true,
                        EntryStatus = 0
                    };

                    await db.TailoringDeliveries.AddAsync(del);
                }
            }

            await db.SaveChangesAsync();
        }
        public async Task <IActionResult> Edit(int id, [Bind("TalioringDeliveryId,DeliveryDate,TalioringBookingId,InvNo,Amount,Remarks,StoreId,UserId,EntryStatus,IsReadOnly")] TalioringDelivery talioringDelivery)
        {
            if (id != talioringDelivery.TalioringDeliveryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    new TailorManager().OnUpdateData(_context, talioringDelivery, true, false);
                    _context.Update(talioringDelivery);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TalioringDeliveryExists(talioringDelivery.TalioringDeliveryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TalioringBookingId"] = new SelectList(_context.TalioringBookings, "TalioringBookingId", "BookingSlipNo", talioringDelivery.TalioringBookingId);
            ViewData["StoreId"]            = new SelectList(_context.Stores, "StoreId", "StoreId", talioringDelivery.StoreId);
            return(View(talioringDelivery));
        }
예제 #3
0
        public async Task <IActionResult> PutTalioringDelivery(int id, TalioringDelivery talioringDelivery)
        {
            if (id != talioringDelivery.TalioringDeliveryId)
            {
                return(BadRequest());
            }

            _context.Entry(talioringDelivery).State = EntityState.Modified;

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

            return(NoContent());
        }
예제 #4
0
        public async Task <ActionResult <TalioringDelivery> > PostTalioringDelivery(TalioringDelivery talioringDelivery)
        {
            _context.TailoringDeliveries.Add(talioringDelivery);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTalioringDelivery", new { id = talioringDelivery.TalioringDeliveryId }, talioringDelivery));
        }
        public void OnUpdateData(AprajitaRetailsContext db, TalioringDelivery delivery, bool isEdit, bool isDelete = false)
        {
            TalioringBooking booking = db.TalioringBookings.Find(delivery.TalioringBookingId);

            if (isEdit)
            {
                if (booking != null)
                {
                    var oldId = db.TailoringDeliveries.Where(c => c.TalioringDeliveryId == delivery.TalioringDeliveryId).Select(c => new { c.TalioringBookingId }).FirstOrDefault();
                    if (oldId.TalioringBookingId != delivery.TalioringBookingId)
                    {
                        TalioringBooking old = db.TalioringBookings.Find(oldId.TalioringBookingId);
                        old.IsDelivered         = false;
                        booking.IsDelivered     = true;
                        db.Entry(booking).State = EntityState.Modified;
                        db.Entry(old).State     = EntityState.Modified;
                    }
                }
            }
            else
            {
                if (booking != null)
                {
                    if (isDelete)
                    {
                        booking.IsDelivered = false;
                    }
                    else
                    {
                        booking.IsDelivered = true;
                    }
                    db.Entry(booking).State = EntityState.Modified;
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TalioringDelivery talioringDelivery = db.Deliveries.Find(id);

            db.Deliveries.Remove(talioringDelivery);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "TalioringDeliveryId,DeliveryDate,TalioringBookingId,InvNo,Amount,Remarks")] TalioringDelivery talioringDelivery)
 {
     if (ModelState.IsValid)
     {
         db.Entry(talioringDelivery).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TalioringBookingId = new SelectList(db.Bookings, "TalioringBookingId", "CustName", talioringDelivery.TalioringBookingId);
     return(View(talioringDelivery));
 }
        public ActionResult Create([Bind(Include = "TalioringDeliveryId,DeliveryDate,TalioringBookingId,InvNo,Amount,Remarks")] TalioringDelivery talioringDelivery)
        {
            if (ModelState.IsValid)
            {
                ProcessData(talioringDelivery.TalioringBookingId);
                db.Deliveries.Add(talioringDelivery);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TalioringBookingId = new SelectList(db.Bookings, "TalioringBookingId", "CustName", talioringDelivery.TalioringBookingId);
            return(View(talioringDelivery));
        }
예제 #9
0
        public async Task <IActionResult> Create([Bind("TalioringDeliveryId,DeliveryDate,TalioringBookingId,InvNo,Amount,Remarks")] TalioringDelivery talioringDelivery)
        {
            if (ModelState.IsValid)
            {
                _context.Add(talioringDelivery);
                new TailoringManager().OnUpdateData(_context, talioringDelivery, false, false);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TalioringBookingId"] = new SelectList(_context.TalioringBookings.Where(c => !c.IsDelivered), "TalioringBookingId", "BookingSlipNo", talioringDelivery.TalioringBookingId);
            return(PartialView(talioringDelivery));
        }
        // GET: TalioringDeliveries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TalioringDelivery talioringDelivery = db.Deliveries.Find(id);

            if (talioringDelivery == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(talioringDelivery));
        }
        // GET: TalioringDeliveries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TalioringDelivery talioringDelivery = db.Deliveries.Find(id);

            if (talioringDelivery == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TalioringBookingId = new SelectList(db.Bookings, "TalioringBookingId", "CustName", talioringDelivery.TalioringBookingId);
            return(View(talioringDelivery));
        }