Esempio n. 1
0
        }                                                                                    //End public void Delete

        public void Create()
        {
            SysinfodetailVM oViewModel = new SysinfoDS().getData();

            try
            {
                using (var db = new DBMAINContext())
                {
                    int nYEAR      = oViewModel.SYSDATE.Value.Year;
                    int nMONTH     = oViewModel.SYSDATE.Value.Month;
                    int nYEAR_FROM = 0;
                    int nYEAR_TO   = 0;
                    //1 Juli - 31 Desember (Semester 1)
                    if ((nMONTH >= 7) && (nMONTH <= 12))
                    {
                        nYEAR_FROM = nYEAR;
                        nYEAR_TO   = nYEAR + 1;
                    } //End if ((nMONTH >= 7) && (nMONTH <= 12))
                    //1 Januari - 30 Juni (Semester 2)
                    if ((nMONTH >= 1) && (nMONTH <= 6))
                    {
                        nYEAR_FROM = nYEAR - 1;
                        nYEAR_TO   = nYEAR;
                    } //End if ((nMONTH >= 1) && (nMONTH <= 6))
                    string   sYEAR_CODE = nYEAR_FROM.ToString() + " - " + nYEAR_TO.ToString();
                    DateTime?oDatefrom  = hlpConvertionAndFormating.ConvertStringToDateShort("01/07/" + nYEAR_FROM.ToString());
                    DateTime?oDateto    = hlpConvertionAndFormating.ConvertStringToDateShort("30/06/" + nYEAR_TO.ToString());


                    /*----------------------------------------------------------------------*/
                    YearDS       oDS   = new YearDS();
                    YeardetailVM oData = oDS.getData_byPeriod(oDatefrom, oDateto);
                    if (oData == null)
                    {
                        Year oModel = new Year();
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModel.DTA_STS        = valFLAG.FLAG_DTA_STS_CREATE;
                        oModel.YEAR_CODE      = sYEAR_CODE;
                        oModel.YEAR_SHORTDESC = sYEAR_CODE;
                        oModel.YEAR_DESC      = sYEAR_CODE;
                        oModel.YEAR_FROM      = oDatefrom;
                        oModel.YEAR_TO        = oDateto;

                        //Process CRUD
                        db.Years.Add(oModel);
                        db.SaveChanges();
                        this.ID = oModel.ID;
                    }                                                                          //End if (oData != null)
                }                                                                              //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create
Esempio n. 2
0
 //Instantiate
 private void Instantiate()
 {
     //CRUD
     this.oCRUD        = new TaskCRUD(this.db);
     this.oCRUD_detail = new TaskdCRUD(this.db);
     //DS
     this.oDSDetail   = new TaskdDS(this.db);
     this.oDSSysinfo  = new SysinfoDS(this.db);
     this.oDSEmployee = new EmployeeDS(this.db);
     this.oDSMonth    = new MonthDS(this.db);
     this.oDSYear     = new YearDS(this.db);
     //DATA
     this.oData = new TaskVM();
 } //End private void Instantiate()