public ActionResult DeleteConfirmed(int id)
        {
            InOutRegsRecpt inOutRegsRecpt = db.InOutRegsRecpts.Find(id);

            db.InOutRegsRecpts.Remove(inOutRegsRecpt);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "IORecptID,RegisterTypeID,TDate,ItemID,Qty,Value,RVno")] InOutRegsRecpt inOutRegsRecpt, int?OldQty)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        int id      = (int)inOutRegsRecpt.RVno;
                        var voucher = db.Vouchers.Find(id);
                        if (inOutRegsRecpt.RegisterTypeID == 21)
                        {
                            db.Entry(inOutRegsRecpt).State = EntityState.Modified;
                            voucher.Amount = inOutRegsRecpt.Value;
                            db.Entry(voucher).Property(a => a.Amount).IsModified = true;

                            voucher.ActualAmount = inOutRegsRecpt.Value;
                            db.Entry(voucher).Property(a => a.ActualAmount).IsModified = true;
                            db.SaveChanges();
                        }
                        else
                        {
                            //Let the user manually create a Correction if required
                            //voucher.Amount = inOutRegsRecpt.Qty * inOutRegsRecpt.Value;


                            //db.Entry(voucher).Property(a => a.Amount).IsModified = true;

                            //voucher.ActualAmount = inOutRegsRecpt.Qty * inOutRegsRecpt.Value;
                            //db.Entry(voucher).Property(a => a.ActualAmount).IsModified = true;

                            var item = db.Inventories.Where(x => x.ItemID == inOutRegsRecpt.ItemID).FirstOrDefault();
                            if (item != null)
                            {
                                item.Qty = item.Qty - (int)OldQty;
                                item.Qty = item.Qty + (int)inOutRegsRecpt.Qty;
                            }
                        }

                        db.Entry(inOutRegsRecpt).State = EntityState.Modified;
                        db.SaveChanges();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }

                return(RedirectToAction("Index", new { rt = inOutRegsRecpt.RegisterTypeID }));
            }
            ViewBag.RegisterTypeID = inOutRegsRecpt.RegisterTypeID;
            ViewBag.ItemID         = new SelectList(db.InvItems, "ItemID", "Item", inOutRegsRecpt.ItemID);
            return(View(inOutRegsRecpt));
        }
        // GET: InOutRegsRecpts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InOutRegsRecpt inOutRegsRecpt = db.InOutRegsRecpts.Find(id);

            if (inOutRegsRecpt == null)
            {
                return(HttpNotFound());
            }
            return(View(inOutRegsRecpt));
        }
Esempio n. 4
0
        public ActionResult EditAquisition([Bind(Include = "IORecptID,RegisterTypeID,TDate,ItemID,Qty,Value,RVno,PropertyParticulars,SituatedWhere,DepositPurpose,ValuationDetails,SanctionDateNo,SanctionByWhom,PeriodToSpendYrs,TreasureVoucherDetails")] InOutRegsRecpt inOutRegsRecpt, int?wrk)
        {
            if (ModelState.IsValid)
            {
                db.Entry(inOutRegsRecpt).State = EntityState.Modified;
                db.SaveChanges();
                if (wrk != null)
                {
                    return(RedirectToAction("Edit", "Works", new { id = (int)wrk }));
                }
                return(RedirectToAction("Index", new { rt = inOutRegsRecpt.RegisterTypeID }));
            }

            return(View(inOutRegsRecpt));
        }
        // GET: InOutRegsRecpts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InOutRegsRecpt inOutRegsRecpt = db.InOutRegsRecpts.Find(id);


            if (inOutRegsRecpt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OldQty         = (int)inOutRegsRecpt.Qty;
            ViewBag.RegisterTypeID = inOutRegsRecpt.RegisterTypeID;
            ViewBag.ItemID         = new SelectList(db.InvItems, "ItemID", "Item", inOutRegsRecpt.ItemID);

            return(View(inOutRegsRecpt));
        }
Esempio n. 6
0
        // GET: SD9EMD6/Edit/5
        public ActionResult EditAquisition(int?id, int?wrk)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InOutRegsRecpt inOutRegsRecpt = db.InOutRegsRecpts.Find(id);

            if (inOutRegsRecpt == null)
            {
                return(HttpNotFound());
            }
            if (inOutRegsRecpt.RegisterTypeID == 22)
            {
                ViewBag.isRVtoday = db.Vouchers.Find(inOutRegsRecpt.RVno).PayDate == DateTime.Today;
                return(View("EditAquisition6", inOutRegsRecpt));
            }

            if (inOutRegsRecpt.RegisterTypeID == 21 || inOutRegsRecpt.RegisterTypeID == 23 || inOutRegsRecpt.RegisterTypeID == 24)
            {
                ViewBag.isRVtoday = db.Form4.Find(inOutRegsRecpt.RVno).PayDate == DateTime.Today;
            }

            ViewBag.wrk = wrk;
            if (inOutRegsRecpt.RegisterTypeID == 21)
            {
                return(View("EditAquisition9", inOutRegsRecpt));
            }
            if (inOutRegsRecpt.RegisterTypeID == 23)
            {
                return(View("EditAquisitionSD", inOutRegsRecpt));
            }
            if (inOutRegsRecpt.RegisterTypeID == 24)
            {
                return(View("EditAquisitionEMD", inOutRegsRecpt));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Esempio n. 7
0
        public ActionResult CreateAquisition([Bind(Include = "IORecptID,RegisterTypeID,TDate,ItemID,Qty,Value,RVno,PropertyParticulars,SituatedWhere,DepositPurpose,ValuationDetails,SanctionDateNo,SanctionByWhom,PeriodToSpendYrs,TreasureVoucherDetails")] InOutRegsRecpt inOutRegsRecpt, int?wrk)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        //Create a voucher for Form6
                        if (inOutRegsRecpt.RegisterTypeID == 22)
                        {
                            string UserID = User.Identity.GetUserName();
                            var    pn     = db.Configs.Select(x => x.VP).FirstOrDefault();
                            var    item   = new Voucher {
                                PassedBy = UserID, of = pn, Amount = inOutRegsRecpt.Value, ActualAmount = inOutRegsRecpt.Value, For = inOutRegsRecpt.PropertyParticulars, PayDate = DateTime.Today, CBfolio = null, ResNo = null, HeldOn = inOutRegsRecpt.TDate, Meeting = "N/A", LedgerID = 10, SubLedgerID = 69
                            };
                            db.Vouchers.Add(item);
                            db.SaveChanges();
                            inOutRegsRecpt.RVno = item.VoucherID;
                        }

                        if (inOutRegsRecpt.RegisterTypeID == 21 || inOutRegsRecpt.RegisterTypeID == 23 || inOutRegsRecpt.RegisterTypeID == 24)
                        {
                            var item = new Form4 {
                                Amount = inOutRegsRecpt.Value, LedgerID = 3, PayDate = DateTime.Today, RecvdFrom = "Conditional Grants", SubLedgerID = 5
                            };
                            if (inOutRegsRecpt.RegisterTypeID == 23 || inOutRegsRecpt.RegisterTypeID == 24)
                            {
                                item.RecvdFrom = inOutRegsRecpt.PropertyParticulars; inOutRegsRecpt.TDate = DateTime.Today;
                            }
                            if (inOutRegsRecpt.RegisterTypeID == 23)
                            {
                                item.SubLedgerID = 26; item.LedgerID = 7;
                            }
                            if (inOutRegsRecpt.RegisterTypeID == 24)
                            {
                                item.SubLedgerID = 25; item.LedgerID = 7;
                            }
                            db.Form4.Add(item);
                            db.SaveChanges();
                            inOutRegsRecpt.RVno = item.RecieptNo;
                        }
                        db.InOutRegsRecpts.Add(inOutRegsRecpt);
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
                if (wrk != null)
                {
                    return(RedirectToAction("Edit", "Works", new { id = (int)wrk, IOrID = inOutRegsRecpt.IORecptID, rt = inOutRegsRecpt.RegisterTypeID }));
                }

                return(RedirectToAction("Index", new { rt = inOutRegsRecpt.RegisterTypeID }));
            }

            return(View(inOutRegsRecpt));
        }
        public ActionResult Create([Bind(Include = "IORecptID,RegisterTypeID,TDate,ItemID,Qty,Value,RVno")] InOutRegsRecpt inOutRegsRecpt)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        inOutRegsRecpt.TDate = DateTime.Now;
                        db.SaveChanges();
                        int    lid = 0, sid = 0;
                        string UserID = User.Identity.GetUserName();

                        if (inOutRegsRecpt.RegisterTypeID == 17)
                        {
                            lid = 8;
                            sid = 42;
                        }
                        if (inOutRegsRecpt.RegisterTypeID == 18)
                        {
                            lid = 8;
                            sid = 137;
                        }
                        if (inOutRegsRecpt.RegisterTypeID == 19)
                        {
                            lid = 8;
                            sid = 138;
                        }
                        if (inOutRegsRecpt.RegisterTypeID == 20)
                        {
                            lid = 8;
                            sid = 139;
                        }

                        int vid = 0;
                        if (inOutRegsRecpt.RegisterTypeID == 21)
                        {
                            lid = 8;
                            sid = 139;
                            var pn   = db.Configs.Select(x => x.VP).FirstOrDefault();
                            var item = new Voucher {
                                PassedBy = UserID, of = pn, Amount = inOutRegsRecpt.Value, ActualAmount = inOutRegsRecpt.Value, For = null, PayDate = inOutRegsRecpt.TDate, CBfolio = null, ResNo = null, HeldOn = inOutRegsRecpt.TDate, Meeting = "N/A", LedgerID = lid, SubLedgerID = sid
                            };
                            db.Vouchers.Add(item);
                            db.SaveChanges();
                            vid = item.VoucherID;
                        }
                        else
                        {
                            var pn      = db.Configs.Select(x => x.VP).FirstOrDefault();
                            var ForWhat = db.InvItems.FirstOrDefault(i => i.ItemID == inOutRegsRecpt.ItemID).Item;
                            var item    = new Voucher {
                                PassedBy = UserID, of = pn, Amount = inOutRegsRecpt.Value * inOutRegsRecpt.Qty, ActualAmount = inOutRegsRecpt.Value * inOutRegsRecpt.Qty, For = ForWhat, PayDate = inOutRegsRecpt.TDate, CBfolio = null, ResNo = null, HeldOn = inOutRegsRecpt.TDate, Meeting = "N/A", LedgerID = lid, SubLedgerID = sid
                            };
                            db.Vouchers.Add(item);
                            db.SaveChanges();
                            vid = item.VoucherID;
                        }
                        inOutRegsRecpt.RVno = vid;
                        db.InOutRegsRecpts.Add(inOutRegsRecpt);
                        db.SaveChanges();
                        var item1 = db.Inventories.Where(x => x.ItemID == inOutRegsRecpt.ItemID).FirstOrDefault();
                        if (item1 != null)
                        {
                            if (inOutRegsRecpt.RegisterTypeID == 21)
                            {
                                item1.Qty = item1.Qty + (int)inOutRegsRecpt.Value;
                                db.Entry(item1).Property(a => a.Qty).IsModified = true;
                                inOutRegsRecpt.Qty = (int)inOutRegsRecpt.Value;

                                db.SaveChanges();
                            }
                            else
                            {
                                item1.Qty = item1.Qty + (int)inOutRegsRecpt.Qty;
                                db.Entry(item1).Property(a => a.Qty).IsModified = true;
                                db.SaveChanges();
                            }
                        }
                        else
                        {
                            if (inOutRegsRecpt.RegisterTypeID != 21)
                            {
                                var item2 = new Inventory {
                                    ItemID = (int)inOutRegsRecpt.ItemID, Qty = (int)inOutRegsRecpt.Qty
                                };
                                db.Inventories.Add(item2);
                            }
                            else
                            {
                                inOutRegsRecpt.Qty = (int)inOutRegsRecpt.Value;
                                var item2 = new Inventory {
                                    ItemID = (int)inOutRegsRecpt.ItemID, Qty = (int)inOutRegsRecpt.Value
                                };
                                db.Inventories.Add(item2);
                            }

                            db.SaveChanges();
                        }

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
                return(RedirectToAction("Index", new { rt = inOutRegsRecpt.RegisterTypeID }));
            }


            ViewBag.RegisterTypeID = inOutRegsRecpt.RegisterTypeID;
            ViewBag.ItemID         = new SelectList(db.InvItems, "ItemID", "Item", inOutRegsRecpt.ItemID);
            return(View(inOutRegsRecpt));
        }