示例#1
0
        public ViewResult Gecmis(string firstDate, string secondDate, string search)
        {
            HesapMakinesi.Models.GECMISDBEntities db    = new GECMISDBEntities();
            HesapMakinesi.Models.Gecmis           model = new Gecmis();
            DateTime a = DateTime.Parse(firstDate);
            DateTime b = DateTime.Parse(secondDate);

            var gecmis = db.Gecmis.Where(s => s.tarih >= a && s.tarih = < b);

            return(View(gecmis));
        }
        public ActionResult Index(double firstNumber, double secondNumber, string Cal)
        {
            double a = firstNumber;
            double b = secondNumber;
            double c = 0.0;
            string d = "Toplama";

            switch (Cal)
            {
            case "Add":
                c = a + b;
                d = "Toplama";
                break;

            case "Sub":
                c = a - b;
                d = "Çıkarma";
                break;

            case "Mul":
                c = a * b;
                d = "Çarpma";
                break;

            case "Div":
                c = a / b;
                d = "Bölme";
                break;
            }//viewbag cont dakı result degıskenının vıew de gorunmesını saglar
            ViewBag.Result = c;
            string sonuc = d;

            //obje olusturma
            HesapMakinesi.Models.GECMISDBEntities db    = new GECMISDBEntities();
            HesapMakinesi.Models.Gecmis           model = new Gecmis();
            //db ye yazdırma
            model.tarih    = Convert.ToDateTime(DateTime.Now.ToString("g"));
            model.sayi1    = firstNumber;
            model.sayi2    = secondNumber;
            model.sonuc    = sonuc;
            model.islemler = c;
            db.Gecmis.Add(model);
            db.SaveChanges();

            return(View());
        }