Exemplo n.º 1
0
        protected void EmployeeGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var id = long.Parse(EmployeeGridView.DataKeys[e.RowIndex].Value.ToString());

            RecordsRepository.GetRepository().DelRecord(id);
            var data = RecordsRepository.GetRepository().GetAllRecords();

            EmployeeGridView.DataSource = data;
            EmployeeGridView.DataBind();
            EmployeeGridView.Visible = true;
            FilePersistence.SaveRecords();
        }
Exemplo n.º 2
0
        protected void SubmitEmployeeData_Click(object sender, EventArgs e)
        {
            EmployeeRecord record = new EmployeeRecord();

            if (TryUpdateModel(record, new FormValueProvider(ModelBindingExecutionContext)))
            {
                var allRecords = RecordsRepository.GetRepository().GetAllRecords();
                if (allRecords.Any())
                {
                    record.Id = RecordsRepository.GetRepository().GetAllRecords().Max(x => x.Id) + 1;
                }
                else
                {
                    record.Id = 0;
                }
                RecordsRepository.GetRepository().AddRecord(record);
                FilePersistence.SaveRecords();
                Response.Redirect("Index.aspx");
            }
        }
Exemplo n.º 3
0
 protected void Application_Start(object sender, EventArgs e)
 {
     FilePersistence.LoadRecords();
 }