Esempio n. 1
0
        public ActionResult EditCHQPayment(int id = 0)
        {
            TBCHQPAYMENT obj = dbContext.TBCHQPAYMENTs.Where(x => x.SerialNo == id).FirstOrDefault();

            if (obj == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AccountHeadCodeList = GetAccountHeadCode();
            ViewBag.CustomerHeadList    = GetCustomerHead();
            ViewBag.CHQPaymentList      = dbContext.TBCHQPAYMENTs.ToList();
            return(View("CHQPayment", obj));
        }
Esempio n. 2
0
        public ActionResult CHQPaymentSaveChanges(TBCHQPAYMENT obj)
        {
            if (obj.SerialNo > 0)
            {
                TBCHQPAYMENT objbrand = dbContext.TBCHQPAYMENTs.Where(x => x.SerialNo == obj.SerialNo).FirstOrDefault();

                objbrand.SerialNo     = obj.SerialNo;
                objbrand.OpeningBal   = obj.OpeningBal;
                objbrand.Date         = obj.Date;
                objbrand.CustomerHead = obj.CustomerHead;
                objbrand.Voucher      = obj.Voucher;
                objbrand.Amount       = obj.Amount;
                objbrand.Discount     = obj.Discount;
                objbrand.Narration    = obj.Narration;
            }
            else
            {
                TBCHQPAYMENT objCHQPayment = JsonConvert.DeserializeObject <TBCHQPAYMENT>(JsonConvert.SerializeObject(obj));
                dbContext.TBCHQPAYMENTs.Add(objCHQPayment);
                dbContext.SaveChanges();
                var id = dbContext.TBCHQPAYMENTs.OrderByDescending(x => x.SerialNo).FirstOrDefault();

                TBDEBIT objDebit = new TBDEBIT();
                objDebit.FNEntryCode = Convert.ToInt32(id.SerialNo);
                objDebit.STType      = "CHQPA";
                objDebit.HeadCode    = Convert.ToInt32(id.CustomerHead);
                objDebit.FNAmount    = obj.Amount;
                objDebit.FNDate      = Convert.ToDateTime("1-4-2016");
                objDebit.Description = "CHEQUE PAYMENT AGAINST " + obj.Voucher + " " + obj.Narration;
                dbContext.TBDEBITs.Add(objDebit);
                dbContext.SaveChanges();


                TBCREDIT objCredit = new TBCREDIT();
                objCredit.FNEntryCode = Convert.ToInt32(id.SerialNo);
                objCredit.STType      = "CHQPA";
                objCredit.HeadCode    = Convert.ToInt32(id.AccountHeadCode);
                objCredit.FDAmount    = obj.Amount;
                objCredit.FDDate      = Convert.ToDateTime("1-4-2016");
                objCredit.Description = "CHEQUE PAYMENT AGAINST " + obj.Voucher + " " + obj.Narration;
                dbContext.TBCREDITs.Add(objCredit);
                dbContext.SaveChanges();
                ViewBag.savemsg             = "Saved Successfully!";
                ViewBag.AccountHeadCodeList = GetAccountHeadCode();
                ViewBag.CustomerHeadList    = GetCustomerHead();
                ViewBag.CHQPaymentList      = dbContext.TBCHQPAYMENTs.ToList();
            }
            return(View("CHQPayment"));
        }