public ActionResult DeleteConfirmed(int id)
        {
            Subject_tbl subject_tbl = db.Subject_tbl.Find(id);

            db.Subject_tbl.Remove(subject_tbl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "subject_id,subject_title,subject_code")] Subject_tbl subject_tbl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subject_tbl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(subject_tbl));
 }
        public ActionResult Create([Bind(Include = "subject_id,subject_title,subject_code")] Subject_tbl subject_tbl)
        {
            if (ModelState.IsValid)
            {
                db.Subject_tbl.Add(subject_tbl);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subject_tbl));
        }
        // GET: /Subject/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Subject_tbl subject_tbl = db.Subject_tbl.Find(id);

            if (subject_tbl == null)
            {
                return(HttpNotFound());
            }
            return(View(subject_tbl));
        }
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string IP = GetVisitorIpAddress();
            Subject_tbl tblSub = new Subject_tbl();
            Tuple<Subject_tbl, UniversityEntities> tuple = new Tuple<Subject_tbl, UniversityEntities>(null, null);

            if (btn_submit.Text == "Submit")
            {

                try
                {
                    tblSub.SubjectName = txtbx_subname.Text;
                    tblSub.CenterID = 1;
                    tblSub.SubjectType = ddltype.SelectedValue;
                    tblSub.SubjectLang = ddllang.SelectedValue;
                    tblSub.Description = txtbx_subdesc.Text;
                    tblSub.IsBitDeleted = false;
                    tblSub.CreatedBy = "Admin";
                    tblSub.CreateDate = Convert.ToDateTime(System.DateTime.Now);
                    tblSub.CreateIP = IP;
                    int deptid = ManageSubjectsBAL.SaveDesignation(tblSub);
                    lblmsg.Text = "Subjects added sucessfully!!!";
                    lblmsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff6230");

                }
                catch
                {
                    //Exception
                }
                finally
                {
                    BindGrid(grid_subject.PageSize, grid_subject.PageIndex);
                    Clear();
                }
            }
            else if (btn_submit.Text == "Update")
            {
                try
                {
                    tblSub.SubjectID = Convert.ToInt32(lblsubid.Text);
                    tblSub.SubjectName = txtbx_subname.Text;
                    tblSub.SubjectType = ddltype.SelectedValue;
                    tblSub.SubjectLang = ddllang.SelectedValue;
                    tblSub.Description = txtbx_subdesc.Text;

                    tblSub.ModifiedBy = "Admin";
                    tblSub.ModifiedDate = Convert.ToDateTime(System.DateTime.Now);
                    tblSub.ModifiedIP = IP;

                    int subid = ManageSubjectsBAL.UpdateSubject(tblSub);
                    lblmsg.Text = "Record Updated Sucessfully";
                    lblmsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff6230");

                }
                catch
                {
                    //Exception
                }
                finally
                {
                    BindGrid(grid_subject.PageSize, grid_subject.PageIndex);
                    Clear();
                }
            }
        }