Beispiel #1
0
        } //End public Task_workerCRUD()

        public void Create(TaskVM poViewModel)
        {
            try
            {
                //Init
                this.oVM            = poViewModel;
                this.oData_employee = this.oDSEmployee.getData(this.oVM.RES_ID);
                //Date
                if (oVM.TASK_DT == null)
                {
                    oVM.TASK_DT = DateTime.Now.Date;
                }
                //Month
                this.oData_month = this.oDSMonth.getData_byMonthNum(oVM.MONTH_ID);
                if (this.oData_month == null)
                {
                    this.oData_month = this.oDSMonth.getData_byMonthNum(oVM.TASK_DT.Value.Month);
                }
                if (this.oData_month == null)
                {
                    this.oData_month = this.oDSMonth.getData_byMonthNum(DateTime.Now.Month);
                }
                //Year
                this.oData_year = this.oDSYear.getData(this.oVM.YEAR_ID);
                if (this.oData_year == null)
                {
                    this.oData_year = this.oDSYear.getData_byYearNum(oVM.TASK_DT.Value.Year);
                }
                if (this.oData_year == null)
                {
                    this.oData_year = this.oDSYear.getData_byYearNum(DateTime.Now.Year);
                }

                //Header
                this.mapModel();
                this.oCRUD.Create(this.oVM);
                this.oCRUD.Commit();
                this.ID = this.oCRUD.ID;
                //Detail
                if (!this.oCRUD.isERR)
                {
                    foreach (var item in oVM.DETAIL)
                    {
                        this.oVM_detail = item;
                        this.mapModel_detail();
                        this.oCRUD_detail.Create(oVM_detail);
                    } //End foreach
                    this.oCRUD_detail.Commit();
                    this.DETAIL_ID = this.oCRUD_detail.ID;
                }                                                                              //End if
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create
Beispiel #2
0
        }                                                                                      //End public void Create

        public void Update(MonthVM poViewModel)
        {
            try
            {
                this.oModel = this.db.Months.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                //Map Form Data
                this.oModel.InjectFrom(poViewModel);
                //Set Field Header
                this.oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                //Set DTA_STS
                this.oModel.DTA_STS = valFLAG.FLAG_DTA_STS_UPDATE;
                //Process CRUD
                this.db.Entry(this.oModel).State = EntityState.Modified;
                //this.db.SaveChanges();
                //this.ID = this.oModel.ID;
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch
        }                                                                                    //End public void Update
Beispiel #3
0
        }                   //End public MonthCRUD()

        public void Create(MonthVM poViewModel)
        {
            try
            {
                this.oModel = new Month();
                //Map Form Data
                this.oModel.InjectFrom(poViewModel);
                //Set Field Header
                this.oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                //Set DTA_STS
                this.oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE;
                //Process CRUD
                this.db.Months.Add(this.oModel);
                //this.db.SaveChanges();
                //this.ID = this.oModel.ID;
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create