public List <VoterClearanceVm> GetList(VoterClearanceVm p, ref string msg) { List <VoterClearanceVm> items = new List <VoterClearanceVm>(); DataTable dt = db.GetList(p, ref msg); if (msg != "") { return(new List <VoterClearanceVm>()); } try { foreach (DataRow row in dt.Rows) { VoterClearanceVm item = new VoterClearanceVm(); item.Id = row["voterClearanceId"].GetString(); item.PositionId = row["positionId"].GetString(); item.Position = row["positionName"].GetString(); item.GradeId = row["gradeId"].GetString(); item.Grade = row["gradeName"].GetString(); item.Active = row["active"].GetBool(); items.Add(item); } return(items); } catch (Exception ex) { msg = ef.GetExceptionMessage(ex, msg); return(new List <VoterClearanceVm>()); } }
public bool DeleteOne(VoterClearanceVm viewModel, ref string msg) { if (!EntryChecker.IsNotZeroOrNull(viewModel.Id.GetInt(), ref msg)) { return(false); } return(db.DeleteOne(MapProperties(viewModel), ref msg)); }
public bool EditOne(VoterClearanceVm viewModel, ref string msg) { if (!EntryChecker.IsNotZeroOrNull(viewModel.Id.GetInt(), viewModel.GradeId.GetInt(), viewModel.PositionId.GetInt(), ref msg)) { return(false); } return(db.EditOne(MapProperties(viewModel), ref msg)); }
private VoterClearance MapProperties(VoterClearanceVm p) { VoterClearance baseObj = new VoterClearance(); baseObj.Id = p.Id.GetInt(); baseObj.PositionId = p.PositionId.GetInt(); baseObj.GradeId = p.GradeId.GetInt(); baseObj.Active = p.Active.GetBool(); return(baseObj); }
public VoterClearanceVm GetOne(VoterClearanceVm p, ref string msg) { try { return(GetList(p, ref msg).Single()); } catch (Exception ex) { msg = ef.GetExceptionMessage(ex, msg); return(new VoterClearanceVm()); } }
private void SaveVoters() { string newMsg = ""; vbl.ResetVmList(); List <GradeComboVm> checkVoters = VoterClearanceCheckedListBoxCon.CheckedItems.Cast <GradeComboVm>().ToList(); foreach (GradeComboVm grade in gbl2.ComboItems) { VoterClearanceVm newItem = new VoterClearanceVm(); newItem.PositionId = newId.GetString(); newItem.GradeId = grade.Id; newItem.Active = checkVoters.Exists(i => i.Id == grade.Id); if (vbl.AddOne(newItem, ref newMsg)) { continue; } MessageBox.Show(newMsg, "Voter Clearance Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
private void LoadCombo() { string msgs = ""; gbl1.ComboItems = gbl1.GetCombo(ref msgs); //attempt to add all //will fail if dupplicate foreach (var item in gbl1.ComboItems) { CandidateClearanceVm obj = new CandidateClearanceVm(); obj.GradeId = item.Id; obj.PositionId = id; cbl.AddOne(obj, ref msgs); } //retieve the candidate clearances msgs = ""; cbl.VmParams.PositionId = id; cbl.ListVm = cbl.GetList(cbl.VmParams, ref msgs); //make the candidate clearances as the datasource CandidateClearanceCheckListBoxCon.DataSource = cbl.ListVm; CandidateClearanceCheckListBoxCon.DisplayMember = "Grade"; CandidateClearanceCheckListBoxCon.ValueMember = "Id"; //set each items checked if active for (int i = 0; i < cbl.ListVm.Count; i++) { CandidateClearanceCheckListBoxCon.SetItemChecked(i, cbl.ListVm[i].Active); } gbl2.ComboItems = gbl2.GetCombo(ref msgs); //attempt to add all //will fail if dupplicate foreach (var item in gbl2.ComboItems) { VoterClearanceVm obj = new VoterClearanceVm(); obj.GradeId = item.Id; obj.PositionId = id; vbl.AddOne(obj, ref msgs); } //retieve the voter clearances msgs = ""; vbl.VmParams.PositionId = id; vbl.ListVm = vbl.GetList(vbl.VmParams, ref msgs); //make the voter clearances as the datasource VoterClearanceCheckedListBoxCon.DataSource = vbl.ListVm; VoterClearanceCheckedListBoxCon.DisplayMember = "Grade"; VoterClearanceCheckedListBoxCon.ValueMember = "Id"; //set each items checked if active for (int i = 0; i < vbl.ListVm.Count; i++) { VoterClearanceCheckedListBoxCon.SetItemChecked(i, vbl.ListVm[i].Active); } }
public void ResetVmParams() { VmParams = new VoterClearanceVm(); }
public void ResetVmItem() { VmItem = new VoterClearanceVm(); }