Example #1
0
        public static Result add(School school)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var repo = new Repository<School>(db);
                    var sch = repo.Find(d => d.Ad == school.Ad && d.IsDeleted == false);
                    var schmeb = repo.Find(d => d.MebKodu == school.MebKodu && d.IsDeleted == false);

                    if (sch.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniOkulSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                    else if (schmeb.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniMebKoduSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                    repo.Add(school);
                    result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                    return result;
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return result;
                }
            }
        }
Example #2
0
        public static Result SinavOlustur(Sinav sinav, NameValueCollection collection)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    SinavOturum otur = new SinavOturum();
                    School sch = new School();
                    otur.Okullar = new List<School>();

                    sinav.SinavOturum = new List<SinavOturum>();
                    int oturumNo = 1;
                    //sinav.SinavDurum = db.SinavDurum.FirstOrDefault(d => d.KisaDurum == "Onaylanmadı");

                    foreach (var item in collection.AllKeys)
                    {
                        if (item.Contains("sinavoturum_Tarih"))
                        {
                            otur = new SinavOturum();
                            otur.Tarih = Convert.ToDateTime(collection.GetValues(item)[0]);
                        }
                        else if (item.Contains("sinavoturum_Saat"))
                        {
                            otur.Saat = collection.GetValues(item)[0];
                            otur.OturumNo = oturumNo++;
                            otur.SinavOturumDurumId = (int)SG_DAL.Enums.EnumSinavDurum.OnaylanmamisSinav;
                            sinav.SinavOturum.Add(otur);
                        }
                        else if (item.Contains("duallistbox_okullar"))
                        {
                            foreach (var okulid in collection.GetValues(item))
                            {
                                var okulRepo = new Repository<School>(db);
                                int id = Convert.ToInt32(okulid);
                                var okul = okulRepo.First(d => d.SchoolId == id);
                                //////////////////////

                                //////////////////////
                                List<SinavOturumOkullari> oturumokullist = new List<SinavOturumOkullari>();
                                foreach (var sinavoturumlari in sinav.SinavOturum)
                                {
                                    sinavoturumlari.Okullar.Add(okul);
                                }
                            }

                        }
                    }

                    var sinavRepo = new Repository<Sinav>(db);
                    sinavRepo.Add(sinav);

                    var sinavOturumlari = SinavManager.GetSinavOturumlari(sinav.SinavId);

                    foreach (var oturum in sinavOturumlari)
                    {
                        var sinavoturumokulu = new SinavOturumOkullari();

                        var sinavOtrOkul = SchoolManager.GetSinavOturumOkullari(oturum.SinavOturumId);

                        foreach (var okul in sinavOtrOkul)
                        {
                            sinavoturumokulu.SchoolId = okul.SchoolId;
                            sinavoturumokulu.SinavOturumId = oturum.SinavOturumId;

                            sinavoturumokulu.AsilGozetmenSayisi = 0;
                            sinavoturumokulu.YedekGozetmenSayisi = 0;
                            db.SinavOturumOkullari.Add(sinavoturumokulu);
                            db.SaveChanges();
                        }
                    }

                    result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                    return result;
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return result;
                }
            }
        }
 public CreateSchoolWrapperModel(School school, List<School> schools)
 {
     this.schools = schools;
     this.school = school;
 }
Example #4
0
        internal static List<School> ReadSchoolsFromExcel(string filePath)
        {
            var data = new StringBuilder();
            try
            {
                Net.SourceForge.Koogra.IWorkbook wb = null;

                string fileExt = Path.GetExtension(filePath);

                if (string.IsNullOrEmpty(fileExt))
                {
                    throw new Exception("File extension not found");
                }

                if (fileExt.Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
                {
                    wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcel2007Reader(filePath);
                }
                else if (fileExt.Equals(".xls", StringComparison.OrdinalIgnoreCase))
                {
                    wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcelBIFFReader(filePath);
                }

                Net.SourceForge.Koogra.IWorksheet ws = wb.Worksheets.GetWorksheetByIndex(0);
                List<School> list = new List<School>();

                for (uint r = ws.FirstRow + 1; r <= ws.LastRow; ++r)
                {
                    Net.SourceForge.Koogra.IRow row = ws.Rows.GetRow(r);
                    if (row != null)
                    {
                        School school = new School();

                        for (uint colCount = ws.FirstCol; colCount <= ws.LastCol; ++colCount)
                        {
                            string cellData = string.Empty;

                            if (row.GetCell(colCount) != null && row.GetCell(colCount).Value != null)
                            {
                                cellData = row.GetCell(colCount).Value.ToString();

                                switch (colCount)
                                {
                                    case 0: school.Ad = cellData;
                                        break;
                                    case 1: school.MebKodu = Convert.ToInt32(cellData);
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }

                        if (school.MebKodu != 0)
                        {
                            list.Add(school);
                        }
                    }
                }
                return list;
            }
            catch (Exception)
            {
                return new List<School>();
            }
        }
 public ActionResult OkulGuncelle(School okul)
 {
     TempData["EventResult"] = SchoolManager.OkulGuncelle(okul);
     return RedirectToAction("Create");
 }
 public ActionResult Create(School school)
 {
     TempData["EventResult"] = SchoolManager.add(school);
     return RedirectToAction("Create");
 }
Example #7
0
        public static Result OkulGuncelle(School guncelokul)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var repo = new Repository<School>(db);
                    School okul = repo.First(d => d.SchoolId == guncelokul.SchoolId);
                    okul.MebKodu = guncelokul.MebKodu;
                    okul.Ad = guncelokul.Ad;
                    repo.UpdateSaveChanges();

                    result = new Result("İşlem başarılı", SystemRess.Messages.basarili_durum.ToString());
                    return result;
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return result;
                }
            }
        }
 public TeacherWrapperModel(User user, Teacher teacher, School okul)
 {
     this.user = user;
     this.teacher = teacher;
     this.okul = okul;
 }