public FinancialYearViewModel SetRecordinEdit(tblFinancialyear tblyear)
        {
            FinancialYearViewModel year = new FinancialYearViewModel();

            year.ID = tblyear.FinancialyearID;
            year.FinancialYearFrom = tblyear.Financialyearfrom.ToShortDateString();
            year.FinancialYearTo   = tblyear.Financialyearto.ToShortDateString();
            return(year);
        }
예제 #2
0
        public ActionResult FinancialYear()
        {
            ButtonVisiblity("Index");
            int ID      = Convert.ToInt32(Session["FinancialYearId"]);
            var tblyear = _financialYearService.GetFinancialYearById(ID);
            var model   = new FinancialYearViewModel();

            if (tblyear != null)
            {
                model = _financialYearService.SetDataOnEdit(tblyear);
            }
            return(View(model));
        }
예제 #3
0
        public ActionResult GetFinancialYearById(int ID)
        {
            string operation = Session["Operation"].ToString();

            ButtonVisiblity(operation);
            var tblyear = _financialYearService.GetFinancialYearById(ID);
            var year    = new FinancialYearViewModel();

            if (tblyear != null)
            {
                year = _financialYearService.SetDataOnEdit(tblyear);
            }
            year.operation = operation;
            return(View("FinancialYear", year));
        }
        public int SaveUpdateRecord()
        {
            int Status;
            tblFinancialyear tblfinancial = new tblFinancialyear();
            var financial = new FinancialYearViewModel();

            financial.ID = Convert.ToInt32(HttpContext.Current.Session["FinancialYearId"]);
            tblfinancial = _context.tblFinancialyears.Where(x => x.FinancialyearID == financial.ID).FirstOrDefault();
            if (tblfinancial != null)
            {
                var localPar   = new SqlParameter("@FinancialYearId", financial.ID);
                var Paramater2 = new SqlParameter("@Message", "");
                Paramater2.Direction = ParameterDirection.Output;
                //Paramater2.Size = 50;
                Paramater2.DbType = DbType.Int32;

                var parameters = new List <SqlParameter>();
                parameters.Add(localPar);
                parameters.Add(Paramater2);

                var result = _context.Database.SqlQuery <object>("EXEC generatefinancialyear @FinancialYearId=@FinancialYearId,@Message=@Message OUTPUT", parameters.ToArray());
                var x      = result.FirstOrDefault();
                Status = Convert.ToInt32(Paramater2.Value);
            }
            else
            {
                tblfinancial = new tblFinancialyear();
                DateTime thisDate    = DateTime.Now;
                string   currentyear = DateTime.Now.ToString("yyyy");
                DateTime nextyear    = thisDate.AddYears(1);
                financial.FinancialYearFrom = "01/04/" + currentyear;
                financial.FinancialYearTo   = "31/03/" + nextyear.Year;

                tblfinancial.Financialyearfrom = Convert.ToDateTime(financial.FinancialYearFrom);
                tblfinancial.Financialyearto   = Convert.ToDateTime(financial.FinancialYearTo);
                tblfinancial.StartDate         = Convert.ToDateTime(financial.FinancialYearFrom);
                tblfinancial.EndDate           = Convert.ToDateTime(financial.FinancialYearTo);
                tblfinancial.CompID            = 1;
                tblfinancial.Financialyear     = "April" + tblfinancial.Financialyearfrom.Year + "-" + "March" + tblfinancial.Financialyearto.Year;
                _context.tblFinancialyears.Add(tblfinancial);
                _context.SaveChanges();
                Status = 1;
            }
            financial.ID = _context.tblFinancialyears.Max(x => x.FinancialyearID);
            return(Status);
        }