private void loadRecord() { try { EmployeeGradeInfo doi = (new EmployeeGradesController()).Get(Convert.ToInt32(lbGrades.SelectedValue)); txtGradeName.Text = doi.GradeName; txtGradeCode.Text = doi.GradeCode; txtGradeDescription.Text = doi.GradeDescription; } catch (Exception ex) { } }
private void loadGrades() { try { ArrayList obj = new ArrayList(); obj = (new EmployeeGradesController()).List(); if (obj.Count > 0) { int x = 0; while (x < obj.Count) { EmployeeGradeInfo di = (EmployeeGradeInfo)obj[x]; lbGrades.Items.Add(new ListItem(di.GradeName, di.GradeId.ToString())); x = x + 1; } } } catch (Exception ex) { } }
protected void bttnSave_Click(object sender, EventArgs e) { try { // save item //check if we are updating an old record or inserting a new one if (lblRecId.Text.Trim() == "") { try { EmployeeGradeInfo doi = new EmployeeGradeInfo(txtGradeName.Text, txtGradeCode.Text, txtGradeDescription.Text); int ret = new EmployeeGradesController().Add(doi); } catch (Exception Ex) { } } else { EmployeeGradeInfo doi = new EmployeeGradeInfo(Convert.ToInt32(lblRecId.Text), txtGradeName.Text, txtGradeCode.Text, txtGradeDescription.Text); (new EmployeeGradesController()).Update(doi); } // clear screen ClearScreen(); bttnNew.Visible = true; bttnCancel.Visible = false; bttnSave.Visible = false; PanelRight.Visible = false; // Reload listbox lbGrades.Items.Clear(); loadGrades(); } catch (Exception ex) { } }