예제 #1
0
        }                             //End public PhotogalleryCRUD()

        public void Create(PhotogallerydetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Photogallery oModel = new Photogallery();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE;
                    //Set Image file name
                    oModel.PHOTO_IMG = Utility_FileUploadDownload.setImage_Gallery();

                    //Process CRUD
                    db.Photogallerys.Add(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Gallery(poFileimage, oModel.PHOTO_IMG);
                    }                                                                                //End if (poFileimage != null)
                } //End using
            } //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create
예제 #2
0
        }                                                 //End public void Create

        public void Update(Complain_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    Complain oModel = db.Complains.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    poViewModel.COMPLAIN_STS = oModel.COMPLAIN_STS;
                    poViewModel.IS_CPAR      = oModel.IS_CPAR;
                    //Map Form Data
                    Mapper.CreateMap <Complain_DetailVM, Complain>();
                    oModel = Mapper.Map <Complain_DetailVM, Complain>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE;
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Update
예제 #3
0
        }                                                 //End public void Update

        public void Delete(string id)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPAR oModel = db.CPARs.Find(id);
                    db.CPARs.Remove(oModel);

                    //Set CPAR_stdref Delete by CPAR RUID
                    oDSCPARStdref = new CPARStdrefDS();
                    var oQRY = oDSCPARStdref.getDatalist_byCPAR_RUID(id);
                    foreach (var item in oQRY)
                    {
                        CPARStdref oItem = db.CPARStdrefs.Find(item.RUID);
                        db.CPARStdrefs.Remove(oItem);
                    } //End foreach (var item in oQRY)

                    //Process CRUD
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Delete
예제 #4
0
        }                                                                                      //End public void Create

        public void Update(StudentdetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Student oModel = db.Students.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_DTA_STS_UPDATE;
                    //Set Image file name
                    if (poFileimage != null)
                    {
                        if ((oModel.STUDENT_IMG == null) || (oModel.STUDENT_IMG == ""))
                        {
                            oModel.STUDENT_IMG = Utility_FileUploadDownload.setImage_Student();
                        }
                    }                                                                                                                                                                    //End if (poFileimage != null)
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Student(poFileimage, oModel.STUDENT_IMG);
                    }                                                                        //End if (poFileimage != null)
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch
        }                                                                                    //End public void Update
예제 #5
0
        }                                                 //End public void Cancel(CPAR_VerifyVM poViewModel)

        //PATCH morefeature#1
        public void patch_morefeature1(CPAR_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    var oData = oDSCPAR.getDatalist();
                    foreach (var item in oData)
                    {
                        CPAR oModel = db.CPARs.AsNoTracking().SingleOrDefault(fld => fld.RUID == item.RUID);
                        //Set CPAR_FINISG_DT base on CPAR_DT
                        if (oModel.CPAR_FINISH_DT == null)
                        {
                            oModel.setFIELD_finishdate();
                        } //End if (oModel.CPAR_FINISH_DT == null)

                        //Set CPAR_RSPNLMT_DT base on CPAR_DT
                        oModel.setFIELD_responsedate();
                        //Set CPAR_VERLMT_DT base on CPAR_DT
                        oModel.setFIELD_verifydate();
                        //Process CRUD
                        db.Entry(oModel).State = EntityState.Modified;
                        //Process CRUD
                        db.SaveChanges();
                    }                                     //End foreach (var item in oData)
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void patch_morefeature1(CPAR_DetailVM poViewModel)
예제 #6
0
        }                                                 //End public void Update

        public void UpdateQuit(Employee_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    #region Employee
                    Employee oModel = db.Employees.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Map Form Data
                    Mapper.CreateMap <Employee_DetailVM, Employee>();
                    oModel = Mapper.Map <Employee_DetailVM, Employee>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                    //Set RES_TYPE
                    oModel.setRES_TYPE();
                    //Set BP_STS
                    oModel.BP_STS = APPBASE.Svcbiz.valFLAG.FLAG_EMP_BPSTS_QUIT;

                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    #endregion
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Update
예제 #7
0
        }                                                                                      //End public void Create

        public void Update(SuggestdetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    poViewModel.SHORT_DESC = poViewModel.FULL_DESC;
                    Suggest         oModel       = db.Suggests.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    SuggesthiddenVM oModelhidden = new SuggesthiddenVM();
                    oModelhidden.InjectFrom(oModel);
                    poViewModel.InjectFrom(oModelhidden);

                    //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;
                    this.TIMELINE_ID = oModel.TIMELINE_ID;
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch
        }                                                                                    //End public void Update
예제 #8
0
        }                                                 //End public void Delete

        public void Career(Employee_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    //Get Current Data by RUID
                    Employee oModel = db.Employees.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                    //Set Job info
                    oModel.RES_STS        = poViewModel.RES_STS;
                    oModel.DEPT_RUID      = poViewModel.DEPT_RUID;
                    oModel.JOB_TITLE_RUID = poViewModel.JOB_TITLE_RUID;
                    oModel.JOIN_DT        = poViewModel.JOIN_DT;
                    oModel.JAMSOSTEK_NO   = poViewModel.JAMSOSTEK_NO;

                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Update
예제 #9
0
        }                                                 //End public void Update

        public void Delete(string id)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    #region Employee
                    Employee oModel = db.Employees.Find(id);
                    db.Employees.Remove(oModel);
                    #endregion

                    #region Employee_address
                    //Delete old address
                    var oModel_address = db.Employee_addresss.Where(fld => fld.RES_RUID == id);
                    foreach (Employee_address item in oModel_address)
                    {
                        db.Employee_addresss.Remove(item);
                    }                                                                                            //End foreach
                    #endregion
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Delete
예제 #10
0
        }                        //End public StudentCRUD()

        public void Create(StudentdetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Student oModel = new Student();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set Image file name
                    if (poFileimage != null)
                    {
                        oModel.STUDENT_IMG = Utility_FileUploadDownload.setImage_Student();
                    }                                                                                                //End if (poFileimage != null)

                    //Process CRUD
                    db.Students.Add(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Student(poFileimage, oModel.STUDENT_IMG);
                    }                                                                                //End if (poFileimage != null)
                } //End using
            } //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create
예제 #11
0
        }                                                 //End public void Close(CPAR_VerifyVM poViewModel)

        public void Cancel(CPAR_VerifyVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPAR oModel = db.CPARs.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Map Form Data
                    //Mapper.CreateMap<CPAR_DetailVM, CPAR>();
                    //oModel = Mapper.Map<CPAR_DetailVM, CPAR>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_UPDATE;
                    //Set FIELD
                    oModel.setFIELD_cancel();
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Cancel(CPAR_VerifyVM poViewModel)
예제 #12
0
        public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        {
            string vsMsgErr = "";
            try
            {
                using (var db = new DBMAINContext())
                {
                    #region User Area
                        User oModel = new User();
                        //Map Form Data
                        //Mapper.CreateMap<User_DetailCPARVM, User>();
                        //oModel = Mapper.Map<User_DetailCPARVM, User>(poViewModel);
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.CREATE);
                        //Set BP_STS (Active)
                        oModel.setActivate();
                        //Set model from Viewmodel
                        oModel.USR_ID = poViewModel.USR_ID;
                        oModel.USR_NM1 = poViewModel.USR_NM1;
                        //Encrypt password
                        oModel.USR_PSWD = hlpObf.randomEncrypt(poViewModel.USR_PSWD);
                    #endregion

                    #region Employee Area
                        Employee oModelEmployee = new Employee();
                        //Set Field Header
                        oModelEmployee.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModelEmployee.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.CREATE);
                        //Set RES_TYPE
                        oModelEmployee.setRES_TYPE();
                        //Set BP_STS
                        oModelEmployee.setActivate();
                        //Set model from Viewmodel
                        oModelEmployee.RES_NM1 = poViewModel.USR_NM1;
                        oModelEmployee.DEPT_RUID = poViewModel.DEPT_RUID;
                        //Set Image file name
                        if (poFileimage != null)
                        {
                            oModelEmployee.IMG_SRC = Utility_FileUploadDownload.setImage(oModelEmployee.RUID);
                            Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModelEmployee.IMG_SRC);
                        } //End if (poFileimage != null)
                    #endregion

                    //Set RES_RUID in User Table
                    oModel.RES_RUID = oModelEmployee.RUID;
                    //Process CRUD
                    db.Users.Add(oModel);
                    db.Employees.Add(oModelEmployee);
                    //Save to Database
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
예제 #13
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
예제 #14
0
        } //End public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        public void UpdateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        {
            string vsMsgErr = "";
            try
            {
                using (var db = new DBMAINContext())
                {
                    #region User Area
                        User oModel = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                        //Set DTA_STS
                        oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                        //Set BP_STS (Active)
                        oModel.setActivate();
                        //Set model from Viewmodel
                        oModel.USR_NM1 = poViewModel.USR_NM1;
                        oModel.USR_PSWD = hlpObf.randomEncrypt(poViewModel.USR_PSWD);
                    #endregion

                    #region Employee Area
                        Employee oModelEmployee = db.Employees.AsNoTracking().SingleOrDefault(fld => fld.RUID == oModel.RES_RUID);
                        //Set Field Header
                        oModelEmployee.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                        //Set DTA_STS
                        oModelEmployee.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                        //Set RES_TYPE
                        oModelEmployee.setRES_TYPE();
                        //Set model from Viewmodel
                        oModelEmployee.RES_NM1 = poViewModel.USR_NM1;
                        oModelEmployee.DEPT_RUID = poViewModel.DEPT_RUID;

                        //Set Image file name
                        if (poFileimage != null)
                        {
                            oModelEmployee.IMG_SRC = Utility_FileUploadDownload.setImage(oModelEmployee.RUID);
                            Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModelEmployee.IMG_SRC);
                        } //End if (poFileimage != null)

                    #endregion

                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.Entry(oModelEmployee).State = EntityState.Modified;
                    //Save to Database
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void UpdateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
예제 #15
0
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Classroom oModel = db.Classrooms.Find(id);
                    db.Classrooms.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
예제 #16
0
        }                                                 //End public void Update

        public void Delete(string id)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARStdref oModel = db.CPARStdrefs.Find(id);
                    db.CPARStdrefs.Remove(oModel);
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Delete
예제 #17
0
        }                                                                                            //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Photogallery oModel = db.Photogallerys.Find(id);
                    db.Photogallerys.Remove(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Delete Image file
                    Utility_FileUploadDownload.deleteImage_Gallery(oModel.PHOTO_IMG);
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
예제 #18
0
        }                                                           //End public UserCRUD()

        //ALL
        public void Changepassword(UserChangepasswordVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    User oModel = db.Users.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    poViewModel.PASSWORD_NEW = hlpObf.randomEncrypt(poViewModel.PASSWORD_NEW);
                    oModel.PASSWORD          = poViewModel.PASSWORD_NEW;
                    //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
예제 #19
0
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Student oModel = db.Students.Find(id);
                    db.Students.Remove(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Delete Image file name
                    Utility_FileUploadDownload.deleteImage_Student(oModel.STUDENT_IMG);
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
예제 #20
0
        }                                                                                    //End public void Update

        public void DeletePARENT(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    User oModel = db.Users.Find(id);
                    db.Users.Remove(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Delete Image file
                    Utility_FileUploadDownload.deleteImage_User(oModel.USER_IMG);
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
예제 #21
0
 } //End public void ActivateCPAR(string id)
 public void DeactivateCPAR(string id)
 {
     string vsMsgErr = "";
     try
     {
         using (var db = new DBMAINContext())
         {
             User oModel = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == id);
             oModel.setDeactivate();
             //Set Field Header
             oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
             //Process CRUD
             db.Entry(oModel).State = EntityState.Modified;
             db.SaveChanges();
         } //End using
     } //End try
     catch (Exception e) { vsMsgErr = e.Message; } //End catch
 } //End public void DeactivateCPAR(string id)
예제 #22
0
        }                        //End public StudentCRUD()

        public void Create(StudentdetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    using (var edupar = new hlpEduparInfo(poViewModel.REG_DT, poViewModel.CLASSLEVEL_ID, poViewModel.CLASSROOM_ID)) {
                        Student oModel = new Student();
                        //Map Form Data
                        oModel.InjectFrom(poViewModel);
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE;
                        //Set main parameter fields

                        oModel.BRANCH_ID     = edupar.DEFBRANCH_ID;
                        oModel.YEAR_ID       = edupar.YEAR_ID;
                        oModel.SEMESTER_ID   = edupar.SEMESTER_ID;
                        oModel.CLASSLEVEL_ID = oDSClassroom.getData(poViewModel.CLASSROOM_ID).CLASSLEVEL_ID;
                        oModel.CLASSTYPE_ID  = oDSClasslevel.getData(oModel.CLASSLEVEL_ID).CLASSTYPE_ID;
                        oModel.CLASSROOM_ID  = poViewModel.CLASSROOM_ID;

                        //Set Image file name
                        if (poFileimage != null)
                        {
                            oModel.STUDENT_IMG = Utility_FileUploadDownload.setImage_Student();
                        }                                                                                                //End if (poFileimage != null)

                        //Process CRUD
                        db.Students.Add(oModel);
                        db.SaveChanges();
                        this.ID = oModel.ID;

                        //Save file
                        if (poFileimage != null)
                        {
                            Utility_FileUploadDownload.saveImage_Student(poFileimage, oModel.STUDENT_IMG);
                        }                                                                                  //End if (poFileimage != null)
                    } //End using (var edupar = new hlpEduparInfo())
                } //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create
예제 #23
0
        }                                                 //End public void Delete

        public void Delete_byUSR_RUID(string id)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    var oQRY = oDS_cparchatnotify.getDatalist_fordelte(id);
                    foreach (var item in oQRY)
                    {
                        CPARChatnotify oModel = db.CPARChatnotifys.Find(item.RUID);
                        db.CPARChatnotifys.Remove(oModel);
                    }                                     //End foreach (var item in oQRY)
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Delete_byUSR_RUID(string id)
예제 #24
0
        }                                                                                      //End public void Create

        public void Update(ThemedetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Theme oModel = db.Themes.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
예제 #25
0
        }                      //End public ThemeCRUD()

        public void Create(ThemedetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Theme oModel = new Theme();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Process CRUD
                    db.Themes.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
예제 #26
0
        } //End public void Deactivate

        public void Create_Usermenu(Userrole_DetailVM poViewModel, string psMDLE_RUID)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    ////Map Form Data
                    //List<Userrolemenu_ListVM> oUserrolemenu_ListVM = poViewModel.Userrolemenu_ListVM;
                    //Mapper.CreateMap < List<Userrolemenu_ListVM>, List<Usermenu>>();
                    Mapper.CreateMap<Userrolemenu_ListVM, Usermenu>();
                    List<Usermenu> oModel = Mapper.Map<List<Userrolemenu_ListVM>, List<Usermenu>>(poViewModel.Userrolemenu_ListVM);
                    var oCurrentModel = db.Usermenus.Where(fld => fld.MDLE_RUID == psMDLE_RUID &&
                                        fld.USR_RUID == poViewModel.RUID);
                    //Delete old usermenu
                    foreach (Usermenu item in oCurrentModel) { db.Usermenus.Remove(item); } //End foreach
                    //Add New usermenu
                    foreach (Usermenu item in oModel) {
                        item.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        item.MDLE_RUID = psMDLE_RUID;
                        item.USR_RUID = poViewModel.RUID;
                        item.IS_GRANTED = hlpGeneral.FlagInfo.getFlagValid();
                        db.Usermenus.Add(item);
                    } //End foreach
                    //Update User (field ROLE_RUID)
                    User oModelUser = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Set Field Header
                    oModelUser.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set ROLE_RUID
                    oModelUser.ROLE_RUID = poViewModel.ROLE_RUID;
                    //Process CRUD
                    db.Entry(oModelUser).State = EntityState.Modified;
                    
                    //Save Database
                    db.SaveChanges();
                    
                    
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void Create
예제 #27
0
        }                             //End public AnnouncementCRUD()

        public void Create(AnnouncementdetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    poViewModel.SHORT_DESC = poViewModel.FULL_DESC.Substring(0, 200);
                    Announcement oModel = new Announcement();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Process CRUD
                    db.Announcements.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
예제 #28
0
 } //End public void Create
 public void Update(User_DetailVM poViewModel)
 {
     string vsMsgErr = "";
     try
     {
         using (var db = new DBMAINContext())
         {
             User oModel = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
             //Map Form Data
             Mapper.CreateMap<User_DetailVM, User>();
             oModel = Mapper.Map<User_DetailVM, User>(poViewModel);
             //Set Field Header
             oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
             //Process CRUD
             db.Entry(oModel).State = EntityState.Modified;
             db.SaveChanges();
         } //End using
     } //End try
     catch (Exception e) { vsMsgErr = e.Message; } //End catch
 } //End public void Update
예제 #29
0
        }                          //End public ClassroomCRUD()

        public void Create(ClassroomdetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Classroom oModel = new Classroom();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE;
                    //Process CRUD
                    db.Classrooms.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
예제 #30
0
 } //End public void UpdateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
 public void DeleteCPAR(string id)
 {
     string vsMsgErr = "";
     try
     {
         using (var db = new DBMAINContext())
         {
             //User Area
             User oModel = db.Users.Find(id);
             db.Users.Remove(oModel);
             //Employee Area
             Employee oModelEmployee = db.Employees.Find(oModel.RES_RUID);
             db.Employees.Remove(oModelEmployee);
             //Save to Database
             db.SaveChanges();
             //Delete Photo
             Utility_FileUploadDownload.deleteImage_Employee(oModel.RES_RUID);
         } //End using
     } //End try
     catch (Exception e) { vsMsgErr = e.Message; } //End catch
 } //End public void DeleteCPAR(string id)