public bool UpdateAcademicSection(ACD_Section section)
        {
            string sql = " Update ACD_Section set SectionName=@SectionName, SectionCode=@SectionCode, " +
                         " OrganizationId=@OrganizationId, " +
                         " EnteredBy=@EnteredBy, EnteredDate=@EnteredDate,LastUpdatedBy=@LastUpdatedBy, " +
                         " LastUpdatedDate=@LastUpdatedDate, IsDeleted=0, DeletedBy=0, DeletedDate=null" +
                         " where SectionId=@SectionId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, section);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        public bool InsertAcademicSection(ACD_Section section)
        {
            string sql = " Insert into  ACD_Section (SectionName, SectionCode,OrganizationId, EnteredBy, EnteredDate," +
                         " LastUpdatedBy, LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " +
                         " values " +
                         "(@SectionName, @SectionCode,@OrganizationId, @EnteredBy, @EnteredDate," +
                         " 0, null, 0, 0, null)";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, section);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Beispiel #3
0
        // GET: AcademicSection/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ACD_Section aCD_Section = db.GetAcademicSectionById((int)id);

            if (aCD_Section == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", aCD_Section.OrganizationId);
            return(View(aCD_Section));
        }
Beispiel #4
0
        public ActionResult Edit(FormCollection frm)
        {
            var         ses         = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int         orgid       = ses.OrganizationId;
            ACD_Section aCD_Section = db.GetAcademicSectionById(Convert.ToInt32(frm["SectionId"]));

            aCD_Section.SectionCode     = frm["SectionCode"];
            aCD_Section.SectionName     = frm["SectionName"];
            aCD_Section.OrganizationId  = orgid;// Convert.ToInt32(frm["OrganizationId"]);
            aCD_Section.LastUpdatedBy   = (User as CustomPrincipal).UserId;
            aCD_Section.LastUpdatedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.UpdateAcademicSection(aCD_Section);
                return(RedirectToAction("Index"));
            }
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", aCD_Section.OrganizationId);
            return(View(aCD_Section));
        }
Beispiel #5
0
        public ActionResult Create(FormCollection frm)
        {
            var ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid = ses.OrganizationId;

            string      fsectionCode = frm["SectionCode"];
            string      fsectionName = frm["SectionName"];
            string      sc = null, sn = null;
            int         isdelete        = 0;
            ACD_Section sectionCodeName = db.GetSectionCodeName(fsectionCode, fsectionName, isdelete);

            ACD_Section aCD_Section = new ACD_Section();

            if (sectionCodeName == null)
            {
                aCD_Section.SectionCode    = frm["SectionCode"];
                aCD_Section.SectionName    = frm["SectionName"];
                aCD_Section.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]);
                aCD_Section.EnteredBy      = (User as CustomPrincipal).UserId;
                aCD_Section.EnteredDate    = DateTime.Now;
                if (ModelState.IsValid)
                {
                    db.InsertAcademicSection(aCD_Section);
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                if (sectionCodeName.IsDeleted == false)
                {
                    sn = sectionCodeName.SectionName;
                    sc = sectionCodeName.SectionCode;
                    if (sn == fsectionName)
                    {
                        ViewBag.CNMsg = "Already Exist..";
                    }
                    if (sc == fsectionCode)
                    {
                        ViewBag.CBMsg = "Already Exist..";
                    }
                    else
                    {
                        aCD_Section.SectionCode    = frm["SectionCode"];
                        aCD_Section.SectionName    = frm["SectionName"];
                        aCD_Section.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]);
                        aCD_Section.EnteredBy      = (User as CustomPrincipal).UserId;
                        aCD_Section.EnteredDate    = DateTime.Now;
                        if (ModelState.IsValid)
                        {
                            db.InsertAcademicSection(aCD_Section);
                            return(RedirectToAction("Index"));
                        }
                    }
                }
                else
                {
                    aCD_Section.SectionCode    = frm["SectionCode"];
                    aCD_Section.SectionName    = frm["SectionName"];
                    aCD_Section.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]);
                    aCD_Section.EnteredBy      = (User as CustomPrincipal).UserId;
                    aCD_Section.EnteredDate    = DateTime.Now;
                    if (ModelState.IsValid)
                    {
                        db.InsertAcademicSection(aCD_Section);
                        return(RedirectToAction("Index"));
                    }
                }
            }
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", aCD_Section.OrganizationId);
            return(View(aCD_Section));
        }