Ejemplo n.º 1
0
        public HttpResponseMessage unlockJournalVoucher(String id, Models.TrnJournalVoucher journalVoucher)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var journalVouchers = from d in db.TrnJournalVouchers where d.Id == Convert.ToInt32(id) select d;
                if (journalVouchers.Any())
                {
                    var updateJournalVoucher = journalVouchers.FirstOrDefault();
                    updateJournalVoucher.IsLocked        = false;
                    updateJournalVoucher.UpdatedById     = userId;
                    updateJournalVoucher.UpdatedDateTime = DateTime.Now;

                    postJournal.deleteJVJournal(Convert.ToInt32(id));
                    db.SubmitChanges();

                    updateBalances(Convert.ToInt32(id));

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 2
0
        public Int32 insertJournalVoucher(Models.TrnJournalVoucher journalVoucher)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var lastJVNumber   = from d in db.TrnJournalVouchers.OrderByDescending(d => d.Id) where d.BranchId == currentBranchId() select d;
                var JVNumberResult = "0000000001";

                if (lastJVNumber.Any())
                {
                    var JVNumber = Convert.ToInt32(lastJVNumber.FirstOrDefault().JVNumber) + 0000000001;
                    JVNumberResult = zeroFill(JVNumber, 10);
                }

                Data.TrnJournalVoucher newJournalVoucher = new Data.TrnJournalVoucher();
                newJournalVoucher.BranchId        = currentBranchId();
                newJournalVoucher.JVNumber        = JVNumberResult;
                newJournalVoucher.ManualJVNumber  = "NA";
                newJournalVoucher.JVDate          = DateTime.Today;
                newJournalVoucher.Particulars     = "NA";
                newJournalVoucher.PreparedById    = userId;
                newJournalVoucher.CheckedById     = userId;
                newJournalVoucher.ApprovedById    = userId;
                newJournalVoucher.IsLocked        = false;
                newJournalVoucher.CreatedById     = userId;
                newJournalVoucher.CreatedDateTime = DateTime.Now;
                newJournalVoucher.UpdatedById     = userId;
                newJournalVoucher.UpdatedDateTime = DateTime.Now;

                db.TrnJournalVouchers.InsertOnSubmit(newJournalVoucher);
                db.SubmitChanges();

                return(newJournalVoucher.Id);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage updateJournalVoucher(String id, Models.TrnJournalVoucher journalVoucher)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var journalVouchers = from d in db.TrnJournalVouchers where d.Id == Convert.ToInt32(id) select d;
                if (journalVouchers.Any())
                {
                    var updateJournalVoucher = journalVouchers.FirstOrDefault();
                    updateJournalVoucher.BranchId        = journalVoucher.BranchId;
                    updateJournalVoucher.JVNumber        = journalVoucher.JVNumber;
                    updateJournalVoucher.ManualJVNumber  = journalVoucher.ManualJVNumber;
                    updateJournalVoucher.JVDate          = Convert.ToDateTime(journalVoucher.JVDate);
                    updateJournalVoucher.Particulars     = journalVoucher.Particulars;
                    updateJournalVoucher.PreparedById    = journalVoucher.PreparedById;
                    updateJournalVoucher.CheckedById     = journalVoucher.CheckedById;
                    updateJournalVoucher.ApprovedById    = journalVoucher.ApprovedById;
                    updateJournalVoucher.IsLocked        = true;
                    updateJournalVoucher.UpdatedById     = userId;
                    updateJournalVoucher.UpdatedDateTime = DateTime.Now;

                    postJournal.insertJVJournal(Convert.ToInt32(id));
                    db.SubmitChanges();

                    updateBalances(Convert.ToInt32(id));

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }