Ejemplo n.º 1
0
        public ActionResult RegistrationPengecer(Pengecers model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryPengecer = db.Pengecers.FirstOrDefault(u => u.Pengecer_Id == model.Pengecer_Id);

                    if (queryPengecer == null)
                    {
                        var pengecer = db.Pengecers.Create();
                        pengecer.Name        = model.Name;
                        pengecer.Pengecer_Id = model.Pengecer_Id;
                        pengecer.Alamat      = model.Alamat;
                        pengecer.Kecamatan   = model.Kecamatan;
                        pengecer.Telpon      = model.Telpon;
                        pengecer.Faks        = model.Faks;
                        pengecer.NPWP        = model.NPWP;
                        pengecer.Aktif       = model.Aktif;
                        db.Pengecers.Add(pengecer);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(RedirectToAction("RegistrationPengecer"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields have been");
            }
            return(View());
        }
Ejemplo n.º 2
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Pengecer_Id,Name,Alamat,Kecamatan,Telpon,Faks,NPWP,Aktif")] Pengecers pengecer)
        {
            //string timeToday = DateTime.Now.ToString("h:mm:ss tt");
            string dateToday       = DateTime.Now.ToString("M/dd/yyyy");
            Claim  sessionUsername = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier);
            string userName        = sessionUsername.Value;

            if (ModelState.IsValid)
            {
                var dbpengecer = db.Pengecers.Create();
                dbpengecer.Pengecer_Id = pengecer.Pengecer_Id;
                dbpengecer.Name        = pengecer.Name;
                dbpengecer.Alamat      = pengecer.Alamat;
                dbpengecer.Kecamatan   = pengecer.Kecamatan;
                dbpengecer.Telpon      = pengecer.Telpon;
                dbpengecer.Faks        = pengecer.Faks;
                dbpengecer.NPWP        = pengecer.NPWP;
                dbpengecer.Aktif       = pengecer.Aktif;
                dbpengecer.Createdby   = userName;
                dbpengecer.Createdon   = dateToday;
                db.Pengecers.Add(dbpengecer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pengecer));
        }
Ejemplo n.º 3
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(string id)
        {
            Pengecers pengecer = db.Pengecers.Find(id);

            db.Pengecers.Remove(pengecer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "Pengecer_Id,Name,Alamat,Kecamatan,Telpon,Faks,NPWP,Aktif")] Pengecers pengecer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pengecer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pengecer));
 }
Ejemplo n.º 5
0
        // GET: /Pengecers/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pengecers pengecer = db.Pengecers.Find(id);

            if (pengecer == null)
            {
                return(HttpNotFound());
            }
            return(View(pengecer));
        }