Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
0
        }                                                 //End public void Delete

        public void Create_prepare(CPARStdref_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARStdref oModel = new CPARStdref();
                    //Map Form Data
                    Mapper.CreateMap <CPARStdref_DetailVM, CPARStdref>();
                    oModel = Mapper.Map <CPARStdref_DetailVM, CPARStdref>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE;
                    this.oModel    = oModel;
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Create_prepare(CPARStdref_DetailVM poViewModel)
Esempio n. 4
0
        }                                                 //End public void Create

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

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARStdref oModel = db.CPARStdrefs.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Map Form Data
                    Mapper.CreateMap <CPARStdref_DetailVM, CPARStdref>();
                    oModel = Mapper.Map <CPARStdref_DetailVM, CPARStdref>(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
Esempio n. 5
0
        }                           //End public CPARStdrefCRUD()

        public void Create(CPARStdref_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARStdref oModel = new CPARStdref();
                    //Map Form Data
                    Mapper.CreateMap <CPARStdref_DetailVM, CPARStdref>();
                    oModel = Mapper.Map <CPARStdref_DetailVM, CPARStdref>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Process CRUD
                    db.CPARStdrefs.Add(oModel);
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Create
Esempio n. 6
0
        }                                                 //End public void Create

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

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPAR oModel = db.CPARs.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    poViewModel.CPAR_STS         = oModel.CPAR_STS;
                    poViewModel.CPAR_TYPE        = oModel.CPAR_TYPE;
                    poViewModel.AUDITORDEPT_RUID = oModel.AUDITORDEPT_RUID;
                    poViewModel.AUDITEEDEPT_RUID = oModel.AUDITEEDEPT_RUID;

                    //Reflect data VM
                    if (oModel.CPAR_TYPE == valFLAG.FLAG_CPAR_TYPE_CC)
                    {
                        poViewModel.AUDITEE_RUID     = oModel.AUDITEE_RUID;
                        poViewModel.AUDITEEDEPT_RUID = oModel.AUDITEEDEPT_RUID;
                        poViewModel.CPAR_DT          = oModel.CPAR_DT;
                        poViewModel.CPAR_TRGT_DT     = oModel.CPAR_TRGT_DT;
                        //poViewModel.CPAR_DESC = oModel.CPAR_DESC;
                        poViewModel.CPAR_RESOLUTION2 = oModel.CPAR_RESOLUTION2;
                        poViewModel.COMPLAIN_RUID    = oModel.COMPLAIN_RUID;
                    } //End if (this.CPAR_TYPE == valFLAG.FLAG_CPAR_TYPE_CC)

                    //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();

                    //Set CPAR_FINISG_DT base on CPAR_DT
                    //oModel.setFIELD_finishdate(poViewModel);
                    oModel.setFIELD_finishdate();
                    //Set CPAR_RSPNLMT_DT base on CPAR_DT
                    //oModel.setFIELD_responsedate(poViewModel);
                    oModel.setFIELD_responsedate();
                    //Set CPAR_VERLMT_DT base on CPAR_DT
                    //oModel.setFIELD_verifydate(poViewModel);
                    oModel.setFIELD_verifydate();

                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;

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

                    //Set CPAR_stdref Add by STDREF_LIST
                    if (poViewModel.STDREF_LIST != null)
                    {
                        foreach (var item in poViewModel.STDREF_LIST)
                        {
                            //LASTWORK
                            CPARStdref_DetailVM oItem = new CPARStdref_DetailVM();
                            //Map Form Data
                            Mapper.CreateMap <CPARStdref_ListVM, CPARStdref_DetailVM>();
                            oItem           = Mapper.Map <CPARStdref_ListVM, CPARStdref_DetailVM>(item);
                            oItem.CPAR_RUID = oModel.RUID;
                            oCRUD_Stdref.Create_prepare(oItem);

                            db.CPARStdrefs.Add(oCRUD_Stdref.oModel);
                        } //End foreach (var item in poViewModel.STDREF_LIST)
                    }     //End if (poViewModel.STDREF_LIST != null)

                    //Process CRUD
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Update