コード例 #1
0
        public ActionResult Create(CountriesClass Obj_Countries, string command)
        {
            using (CountriesCtl db = new CountriesCtl()){
                if (ModelState.IsValid)
                {
                    db.insert(Obj_Countries);
                    if (command.ToLower().Trim() == "save")
                    {
                        string sesionval = Convert.ToString(Session["CreatePreviousURL"]);
                        if (!string.IsNullOrEmpty(sesionval))
                        {
                            Session.Remove("CreatePreviousURL");
                            return(Redirect(sesionval));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ModelState.Clear();
                        return(View());
                    }
                }

                return(View(Obj_Countries));
            }
        }
コード例 #2
0
 public ActionResult Edit(Int32?Countryid)
 {
     using (CountriesCtl db = new CountriesCtl()){
         CountriesClass obj_Countries = db.selectById(Countryid);
         Session["EditPreviousURL"] = Convert.ToString(ControllerContext.HttpContext.Request.UrlReferrer);
         return(View(obj_Countries));
     }
 }
コード例 #3
0
 public ActionResult SaveRecords(FormCollection model)
 {
     if (ModelState.IsValid)
     {
         using (CountriesCtl db = new CountriesCtl()){
             var CountryidArray   = model.GetValues("item.Countryid");
             var CountrynameArray = model.GetValues("item.Countryname");
             var IsactiveArray    = model.GetValues("item.Isactive");
             var IsdeletedArray   = model.GetValues("item.Isdeleted");
             var CreatedonArray   = model.GetValues("item.Createdon");
             var DeletedonArray   = model.GetValues("item.Deletedon");
             for (Int32 i = 0; i < CountryidArray.Length; i++)
             {
                 CountriesClass obj_update = db.selectById(Convert.ToInt32(CountryidArray[i]));
                 if (!string.IsNullOrEmpty(Convert.ToString(CountryidArray)))
                 {
                     obj_update.Countryid = Convert.ToInt32(CountryidArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(CountrynameArray)))
                 {
                     obj_update.Countryname = Convert.ToString(CountrynameArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(IsactiveArray)))
                 {
                     obj_update.Isactive = Convert.ToBoolean(IsactiveArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(IsdeletedArray)))
                 {
                     obj_update.Isdeleted = Convert.ToBoolean(IsdeletedArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(CreatedonArray)))
                 {
                     obj_update.Createdon = Convert.ToDateTime(CreatedonArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(DeletedonArray)))
                 {
                     obj_update.Deletedon = Convert.ToDateTime(DeletedonArray[i]);
                 }
                 db.update(obj_update);
             }
         }
     }
     return(RedirectToAction("EditTable"));
 }
コード例 #4
0
 public ActionResult Edit(CountriesClass Obj_Countries)
 {
     using (CountriesCtl db = new CountriesCtl()){
         if (ModelState.IsValid)
         {
             db.update(Obj_Countries);
             string sesionval = Convert.ToString(Session["EditPreviousURL"]);
             if (!string.IsNullOrEmpty(sesionval))
             {
                 Session.Remove("EditPreviousURL");
                 return(Redirect(sesionval));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
         return(View(Obj_Countries));
     }
 }
コード例 #5
0
 public ActionResult Details(Int32?Countryid)
 {
     using (CountriesCtl db = new CountriesCtl()){ CountriesClass obj_Countries = db.selectById(Countryid);
                                                   return(View(obj_Countries)); }
 }