protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lbllevelid.Text.Length > 0)
            {
                try
                {
                    EduLevelsRepository elir = new EduLevelsRepository();

                    if (elir.FindBytitle(TextBox1.Text) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatTitle, Color.Red);

                        return;
                    }
                    EduLevel editlevel = new EduLevel();
                    if ((TextBox1.Text.Length > 0) && (TextBox1.Text != lbltitle.Text))
                    {
                        editlevel.LevelTitle = TextBox1.Text;
                    }

                    editlevel.LevelID = lbllevelid.Text.ToInt();
                    elir.SaveEduLevel(editlevel);

                    ClearForm();


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("EduLevelId,EduLevelName")] EduLevel eduLevel)
        {
            if (id != eduLevel.EduLevelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(eduLevel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EduLevelExists(eduLevel.EduLevelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(eduLevel));
        }
        public void LoadLevelData(string Levelid)
        {
            try
            {
                EduLevelsRepository elir  = new EduLevelsRepository();
                EduLevel            level = elir.FindByid(Levelid.ToInt());


                if (level != null)
                {
                    lbltitle.Text = level.LevelTitle;

                    lbllevelid.Text = level.LevelID.ToString();
                    TextBox1.Text   = level.LevelTitle;
                }
                else
                {
                    Redirector.Goto(Redirector.PageName.errorpage);
                }
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }
        public async Task <IActionResult> Create([Bind("EduLevelId,EduLevelName")] EduLevel eduLevel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eduLevel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eduLevel));
        }
Example #5
0
        public EduLevel FindByid(int id)
        {
            EduLevel result = null;

            using (PersonsDBEntities DC = conn.GetContext())
            {
                //--  SELECT * FROM vPhoneList WHERE PhobeID = phoneID

                result = (from r in DC.EduLevels
                          where r.LevelID == id
                          select r).FirstOrDefault();
            }

            return(result);
        }
Example #6
0
        public void SaveEduLevel(EduLevel edulevel)
        {
            using (PersonsDBEntities DC = conn.GetContext())
            {
                if (edulevel.LevelID > 0)
                {
                    //==== UPDATE ====
                    DC.EduLevels.Attach(edulevel);
                    DC.Entry(edulevel).State = EntityState.Modified;
                }
                else
                {
                    //==== INSERT ====
                    DC.EduLevels.Add(edulevel);
                }

                DC.SaveChanges();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            EduLevelsRepository level = new EduLevelsRepository();

            if (level.FindBytitle(TextBox1.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;



            try
            {
                EduLevel newEduLevel = new EduLevel();
                newEduLevel.LevelTitle = TextBox1.Text.Trim();

                EduLevelsRepository elir = new EduLevelsRepository();
                elir.SaveEduLevel(newEduLevel);



                ClearForm();
            }
            catch (System.Exception err)
            {
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }
 /// <summary>
 /// There are no comments for EduLevel in the schema.
 /// </summary>
 public void AddToEduLevel(EduLevel eduLevel)
 {
     base.AddObject("EduLevel", eduLevel);
 }
 /// <summary>
 /// Create a new EduLevel object.
 /// </summary>
 /// <param name="eLId">Initial value of ELId.</param>
 public static EduLevel CreateEduLevel(int eLId)
 {
     EduLevel eduLevel = new EduLevel();
     eduLevel.ELId = eLId;
     return eduLevel;
 }
Example #10
0
        public void ParseCellOnce(ICell cell, string cellStrValue, CellRangeAddress cellRangeAddress, WorkbookParserContext context, out bool parseCellAgain, out bool skipRow)
        {
            parseCellAgain = false;
            skipRow        = false;

            if (context.State == WorkbookParserState.Initial)
            {
                context.State  = WorkbookParserState.Header;
                parseCellAgain = true;
                return;
            }

            if (context.State == WorkbookParserState.Header)
            {
                if (!cell.IsMergedCell)
                {
                    if (cell.ColumnIndex == 0 && cellStrValue.Equals("№ п/п", StringComparison.CurrentCultureIgnoreCase))
                    {
                        context.State = WorkbookParserState.TableHeader;
                        return;
                    }
                }
                else if (cell.IsMergedCell && cellRangeAddress.NumberOfCells >= 10)
                {
                    if (Regex.IsMatch(cellStrValue, "факультет|институт", RegexOptions.IgnoreCase))
                    {
                        var divisionTitle = cellStrValue.ToLower();
                        var division      = divisions.FindOne(d => d.Title == divisionTitle);
                        if (division == null)
                        {
                            division = new Division {
                                Title = divisionTitle
                            };
                            var id = divisions.Insert(division);
                            db.Commit();
                            division.Id = id.AsInt32;
                        }
                        context.Division = division;
                    }
                    if (Regex.IsMatch(cellStrValue, "форма обучения", RegexOptions.IgnoreCase))
                    {
                        var eduForm = eduForms.FindOne(ef => ef.Title == cellStrValue);
                        if (eduForm == null)
                        {
                            eduForm = new EduForm {
                                Title = cellStrValue
                            };
                            var id = eduForms.Insert(eduForm);
                            db.Commit();
                            eduForm.Id = id.AsInt32;
                        }
                        context.EduForm = eduForm;
                    }
                    if (Regex.IsMatch(cellStrValue, "бюджет|договор", RegexOptions.IgnoreCase))
                    {
                        var financingTitle = cellStrValue.ToLower();
                        var financing      = financings.FindOne(f => f.Title == financingTitle);
                        if (financing == null)
                        {
                            financing = new Financing {
                                Title = financingTitle
                            };
                            var id = financings.Insert(financing);
                            db.Commit();
                            financing.Id = id.AsInt32;
                        }
                        context.Financing = financing;
                    }
                    if (Regex.IsMatch(cellStrValue, "бакалавриат|специалитет|магистратур|подготовки кадров|основного общего|среднего общего", RegexOptions.IgnoreCase))
                    {
                        var eduLevelStrValue = GetEduLevelString(cellStrValue);

                        var eduLevel = eduLevels.FindOne(el => el.Title == eduLevelStrValue);
                        if (eduLevel == null)
                        {
                            eduLevel = new EduLevel {
                                Title = eduLevelStrValue
                            };
                            var id = eduLevels.Insert(eduLevel);
                            db.Commit();
                            eduLevel.Id = id.AsInt32;
                        }
                        context.EduLevel = eduLevel;

                        if (context.EduLevel.Title.StartsWith("специалитет СПО", StringComparison.CurrentCultureIgnoreCase))
                        {
                            context.IsCollegeList = true;
                        }
                        else
                        {
                            context.IsCollegeList = false;
                        }

                        var eduProgramTitle = Regex.Match(cellStrValue, @"«[^»]+»", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                        var eduProfileTitle = Regex.Match(cellStrValue, @"Профиль:(.*)", RegexOptions.Singleline | RegexOptions.IgnoreCase).Groups [1].Value;
                        if (string.IsNullOrEmpty(eduProfileTitle))
                        {
                            eduProfileTitle = Regex.Match(cellStrValue, @"на базе .* общего образования", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                        }

                        eduProgramTitle = FormatEduProgramTitle(eduProgramTitle);
                        eduProfileTitle = FormatEduProgramTitle(eduProfileTitle);

                        if (context.EduProgram == null)
                        {
                            context.EduProgram = new EduProgram();
                        }

                        context.EduProgram.Title        = eduProgramTitle;
                        context.EduProgram.ProfileTitle = eduProfileTitle;
                        context.EduProgram.EduLevelId   = context.EduLevel.Id;
                        context.EduProgram.DivisionId   = context.Division.Id;
                    }
                }
                return;
            }

            if (context.State == WorkbookParserState.TableHeader && context.IsCollegeList)
            {
                if (cell.ColumnIndex == 5)
                {
                    context.EduProgram.Exam1Title = cellStrValue;
                }
                else if (cell.ColumnIndex == 7)
                {
                    context.EduProgram.Exam2Title = cellStrValue;
                }
                else if (cell.ColumnIndex > 7)
                {
                    context.State = WorkbookParserState.List;
                    context.Order = 0;
                    skipRow       = true;
                    InsertEduProgram(context);
                }
                return;
            }

            if (context.State == WorkbookParserState.TableHeader && !context.IsCollegeList)
            {
                if (cell.ColumnIndex == 4)
                {
                    context.EduProgram.Exam1Title = cellStrValue;
                }
                else if (cell.ColumnIndex == 5)
                {
                    context.EduProgram.Exam2Title = cellStrValue;
                }
                else if (cell.ColumnIndex == 6)
                {
                    context.EduProgram.Exam3Title = cellStrValue;
                }
                else if (cell.ColumnIndex > 6)
                {
                    context.State = WorkbookParserState.List;
                    context.Order = 0;
                    skipRow       = true;
                    InsertEduProgram(context);
                }
                return;
            }

            if (context.State == WorkbookParserState.List)
            {
                if (cell.IsMergedCell && cellRangeAddress.NumberOfCells >= 10)
                {
                    context.State  = WorkbookParserState.Header;
                    parseCellAgain = true;
                    return;
                }
                if (cell.ColumnIndex == 0)
                {
                    context.Applicant       = new Applicant();
                    context.Applicant.Order = ++context.Order;
                    if (int.TryParse(cellStrValue, out int rankedOrder))
                    {
                        context.Applicant.RankedOrder = rankedOrder;
                    }
                }
                else if (cell.ColumnIndex == 1)
                {
                    context.Applicant.Name = cellStrValue;
                }
            }

            if (context.State == WorkbookParserState.List && context.IsCollegeList)
            {
                if (cell.ColumnIndex == 3)
                {
                    context.Applicant.HasOriginal = cellStrValue.Equals("Оригинал", StringComparison.CurrentCultureIgnoreCase);
                }
                else if (cell.ColumnIndex == 5)
                {
                    if (decimal.TryParse(cellStrValue, out decimal exam1Rate))
                    {
                        context.Applicant.Exam1Rate = exam1Rate;
                    }
                }
                else if (cell.ColumnIndex == 7)
                {
                    context.Applicant.Exam2Mark = cellStrValue;
                }
                else if (cell.ColumnIndex == 9)
                {
                    if (decimal.TryParse(cellStrValue, out decimal totalRate))
                    {
                        context.Applicant.TotalRate = totalRate;
                    }
                }
                else if (cell.ColumnIndex == 10)
                {
                    context.Applicant.Status = cellStrValue;
                }
                else if (cell.ColumnIndex == 11)
                {
                    context.Applicant.RejectReason = cellStrValue;
                }
                else if (cell.ColumnIndex > 11)
                {
                    context.Applicant.EduProgramId = context.EduProgram.Id;
                    context.Applicant.EduFormId    = context.EduForm.Id;
                    context.Applicant.FinancingId  = context.Financing.Id;
                    applicants.Insert(context.Applicant);
                    skipRow = true;
                }
                return;
            }

            if (context.State == WorkbookParserState.List && !context.IsCollegeList)
            {
                if (cell.ColumnIndex == 2)
                {
                    context.Applicant.HasOriginal = cellStrValue.Equals("Оригинал", StringComparison.CurrentCultureIgnoreCase);
                }
                else if (cell.ColumnIndex == 3)
                {
                    context.Applicant.HasAgreement = cellStrValue.Equals("Да", StringComparison.CurrentCultureIgnoreCase);
                }
                if (cell.ColumnIndex == 4)
                {
                    if (decimal.TryParse(cellStrValue, out decimal exam1Rate))
                    {
                        context.Applicant.Exam1Rate = exam1Rate;
                    }
                }
                else if (cell.ColumnIndex == 5)
                {
                    if (decimal.TryParse(cellStrValue, out decimal exam2Rate))
                    {
                        context.Applicant.Exam2Rate = exam2Rate;
                    }
                }
                else if (cell.ColumnIndex == 6)
                {
                    if (decimal.TryParse(cellStrValue, out decimal exam3Rate))
                    {
                        context.Applicant.Exam3Rate = exam3Rate;
                    }
                }
                else if (cell.ColumnIndex == 7)
                {
                    if (decimal.TryParse(cellStrValue, out decimal achRate))
                    {
                        context.Applicant.AchRate = achRate;
                    }
                }
                else if (cell.ColumnIndex == 8)
                {
                    if (decimal.TryParse(cellStrValue, out decimal totalRate))
                    {
                        context.Applicant.TotalRate = totalRate;
                    }
                }
                else if (cell.ColumnIndex == 9)
                {
                    context.Applicant.Category = cellStrValue;
                }
                else if (cell.ColumnIndex == 10)
                {
                    if (cellStrValue.Equals("Да", StringComparison.CurrentCultureIgnoreCase))
                    {
                        context.Applicant.HasPreemptiveRight = true;
                    }
                }
                else if (cell.ColumnIndex == 11)
                {
                    context.Applicant.Status = cellStrValue;
                }
                else if (cell.ColumnIndex == 12)
                {
                    context.Applicant.RejectReason = cellStrValue;
                }
                else if (cell.ColumnIndex > 12)
                {
                    context.Applicant.EduProgramId = context.EduProgram.Id;
                    context.Applicant.EduFormId    = context.EduForm.Id;
                    context.Applicant.FinancingId  = context.Financing.Id;
                    applicants.Insert(context.Applicant);
                    skipRow = true;
                }
                return;
            }
        }