コード例 #1
0
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Jobtype oModel = db.Jobtypes.Find(id);
                    db.Jobtypes.Remove(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
コード例 #2
0
        }                                                                                      //End public void Create

        public void Update(JobtypedetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Jobtype oModel = db.Jobtypes.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch
        }                                                                                    //End public void Update
コード例 #3
0
        }                        //End public JobtypeCRUD()

        public void Create(JobtypedetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Jobtype oModel = new Jobtype();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Process CRUD
                    db.Jobtypes.Add(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                              //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create