Exemplo n.º 1
0
        public JsonResult CreateCashInFinal(CashIn cashflow, string log)
        {
            try
            {
                CashIn          cashInActive = cashflow;
                string          usr          = User.Identity.GetUserId();
                ApplicationUser xx           = db.Users.Find(usr);

                CutOff cutOff =
                    db.CutOffs.FirstOrDefault(p => p.BranchId == xx.BranchId && p.State == StateCutOff.Open) ??
                    SetCutOff(xx.BranchId.Value);


                if (cashflow.Id != 0)
                {
                    cashInActive = db.CashCards.OfType <CashIn>().First(p => p.Id == cashflow.Id);

                    Subtitution(cashInActive, cashflow);
                }
                else
                {
                    db.CashCards.Add(cashInActive);
                    //CashOut.Date = DateTime.Now;
                    cashInActive.CutOffId = cutOff.Id;
                    cashInActive.UserId   = usr;
                }


                cashInActive.SetToFinal();
                cashInActive.LogNote = DateTime.Now.ToString("yyyy-MM-dd HH:mm") + " | " + User.Identity.Name +
                                       " | Final | " + log + "<br>" + cashInActive.LogNote;

                cashInActive.SetTotal();
                db.SaveChanges();


                return(Json(new { Success = 1, CashOutId = cashflow.Id, ex = "" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = 0, ex = ex.Message }));
            }
        }
Exemplo n.º 2
0
        public JsonResult CreateCashInDraft(CashIn cashIn)
        {
            try
            {
                CashIn cashInActive = cashIn;

                string          usr = User.Identity.GetUserId();
                ApplicationUser xx  = db.Users.Find(usr);

                CutOff cutOff =
                    db.CutOffs.FirstOrDefault(p => p.BranchId == xx.BranchId && p.State == StateCutOff.Open) ??
                    SetCutOff(xx.BranchId.Value);

                if (cashIn.Id != 0)
                {
                    cashInActive = db.CashCards.OfType <CashIn>().First(p => p.Id == cashIn.Id);

                    Subtitution(cashInActive, cashIn);
                }
                else
                {
                    db.CashCards.Add(cashInActive);
                    //CashOut.Date = DateTime.Now;
                    cashInActive.CutOffId = cutOff.Id;
                    cashInActive.UserId   = usr;
                }
                //set subtotal and total

                cashInActive.SetToDraft();

                cashInActive.SetTotal();
                db.SaveChanges();


                return(Json(new { Success = 1, CashOutId = cashIn.Id, ex = "" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = 0, ex = ex.Message }));
            }
        }