Exemple #1
0
        public bool UpdateAcademicBatch(ACD_Batch batch)
        {
            string sql = " Update ACD_Batch set BatchName=@BatchName, BatchCode=@BatchCode, " +
                         " StartDateAD=@StartDateAD, StartDateBS=@StartDateBS, OrganizationId=@OrganizationId, ProgramId=@ProgramId, " +
                         " EnteredBy=@EnteredBy, EnteredDate=@EnteredDate,LastUpdateBy=@LastUpdateBy, " +
                         " LastUpdatedDate=@LastUpdatedDate, IsDeleted=0, DeletedBy=0, DeletedDate=null" +
                         " where BatchId=@BatchId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, batch);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        public ActionResult Create(FormCollection frm)
        {
            var ses       = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid     = ses.OrganizationId;
            var aCD_Batch = new ACD_Batch();

            aCD_Batch.BatchCode      = frm["BatchCode"];
            aCD_Batch.BatchName      = frm["BatchName"];
            aCD_Batch.ProgramId      = Convert.ToInt32(frm["ProgramId"]);
            aCD_Batch.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]);
            aCD_Batch.StartDateAD    = DateTime.ParseExact(frm["StartDateAD"], "yyyy-MM-dd", null);
            aCD_Batch.StartDateBS    = frm["StartDateBS"];
            aCD_Batch.EnteredBy      = (User as CustomPrincipal).UserId;
            aCD_Batch.EnteredDate    = DateTime.Now;
            if (ModelState.IsValid)
            {
                //db.ACD_Batch.Add(aCD_Batch);
                db.InsertAcademicBatch(aCD_Batch);
                return(RedirectToAction("Index"));
            }
            ViewBag.ProgramId      = new SelectList(ddl.GetProgramList(orgid), "Id", "Name", aCD_Batch.ProgramId);
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", aCD_Batch.OrganizationId);

            return(View(aCD_Batch));
        }
Exemple #3
0
        public bool InsertAcademicBatch(ACD_Batch batch)
        {
            string sql = " Insert into  ACD_Batch (BatchName, BatchCode, StartDateAD, StartDateBS, OrganizationId, ProgramId, EnteredBy, EnteredDate," +
                         " LastUpdateBy, LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " +
                         " values " +
                         "(@BatchName, @BatchCode, @StartDateAD, @StartDateBS, @OrganizationId, @ProgramId, @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, batch);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        // GET: AcademicBatch/Edit/5
        public ActionResult Edit(int?id)
        {
            var ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid = ses.OrganizationId;

            if (id == null || id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ACD_Batch aCD_Batch = db.GetAcademicBatchById((int)id);

            if (aCD_Batch == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProgramId      = new SelectList(ddl.GetProgramList(orgid), "Id", "Name", aCD_Batch.ProgramId);
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", aCD_Batch.OrganizationId);
            return(View(aCD_Batch));
        }