public List <CandidateClearanceVm> GetList(CandidateClearanceVm p, ref string msg)
        {
            List <CandidateClearanceVm> items = new List <CandidateClearanceVm>();
            DataTable dt = db.GetList(p, ref msg);

            if (msg != "")
            {
                return(new List <CandidateClearanceVm>());
            }

            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    CandidateClearanceVm item = new CandidateClearanceVm();
                    item.Id         = row["candidateClearanceId"].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 <CandidateClearanceVm>());
            }
        }
 //todo
 public bool DeleteOne(CandidateClearanceVm viewModel, ref string msg)
 {
     if (!EntryChecker.IsNotZeroOrNull(viewModel.PositionId.GetInt(), ref msg))
     {
         return(false);
     }
     return(db.DeleteOne(MapProperties(viewModel), ref msg));
 }
        private CandidateClearance MapProperties(CandidateClearanceVm p)
        {
            CandidateClearance baseObj = new CandidateClearance();

            baseObj.Id         = p.Id.GetInt();
            baseObj.PositionId = p.PositionId.GetInt();
            baseObj.GradeId    = p.GradeId.GetInt();
            baseObj.Active     = p.Active.GetBool();

            return(baseObj);
        }
 public CandidateClearanceVm GetOne(CandidateClearanceVm p, ref string msg)
 {
     try
     {
         return(GetList(p, ref msg).Single());
     }
     catch (Exception ex)
     {
         msg = ef.GetExceptionMessage(ex, msg);
         return(new CandidateClearanceVm());
     }
 }
Пример #5
0
        private void SaveCands()
        {
            string newMsg = "";

            cbl.ResetVmList();

            List <GradeComboVm> checkCands = CandidateClearanceCheckListBoxCon.CheckedItems.Cast <GradeComboVm>().ToList();

            foreach (GradeComboVm grade in gbl1.ComboItems)
            {
                CandidateClearanceVm newItem = new CandidateClearanceVm();
                newItem.PositionId = newId.GetString();
                newItem.GradeId    = grade.Id;
                newItem.Active     = checkCands.Exists(i => i.Id == grade.Id).GetBool();

                if (cbl.AddOne(newItem, ref newMsg))
                {
                    continue;
                }
                MessageBox.Show(newMsg, "Candidate Clearance Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }
 public void ResetVmParams()
 {
     VmParams = new CandidateClearanceVm();
 }
 public void ResetVmItem()
 {
     VmItem = new CandidateClearanceVm();
 }
Пример #8
0
        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);
            }
        }