Exemplo n.º 1
0
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                this.oModel = this.db.Transaction_ins.Find(id);
                this.db.Transaction_ins.Remove(oModel);
                //this.db.SaveChanges();
                //this.ID = oModel.ID;
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
Exemplo n.º 2
0
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Transaction_in oModel = db.Transaction_ins.Find(id);
                    db.Transaction_ins.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
Exemplo n.º 3
0
        }                                                                                      //End public void Create

        public void Update(Transaction_indetailVM poViewModel)
        {
            try
            {
                this.oModel = this.db.Transaction_ins.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(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
Exemplo n.º 4
0
        } //End public Transaction_inCRUD()

        public void Create(Transaction_indetailVM poViewModel)
        {
            try
            {
                this.oModel = new Transaction_in();
                //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.Transaction_ins.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
Exemplo n.º 5
0
        }                               //End public Transaction_inCRUD()

        public void Create(Transaction_indetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Transaction_in oModel = new Transaction_in();
                    //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.Transaction_ins.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
Exemplo n.º 6
0
        } //End private Installment_in setINST(Installment_in oModelINST)

        public void SaveNEW_create_BACKUP(Transaction_indetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    //TRN
                    Transaction_in oModelTRN = new Transaction_in();
                    //Map Form Data
                    oModelTRN.InjectFrom(poViewModel);
                    //Set Field Header
                    oModelTRN.setFIELD_HEADER(this.FIELD_HEADER);
                    //Set DTA_STS
                    oModelTRN.DTA_STS = this.DTA_STS;
                    //Process CRUD
                    db.Transaction_ins.Add(oModelTRN);
                    //Update database
                    db.SaveChanges();
                    this.ID     = oModelTRN.ID;
                    this.TRN_DT = oModelTRN.TRN_DT;

                    //INST - SPP
                    Installment_in oModelINST = null;
                    //Create
                    if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                    {
                        oModelINST = new Installment_in();
                        //Map Form Data
                        oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                        //Set Field Header
                        oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS : Set in METHOD controller
                        //oModelINST.DTA_STS = this.DTA_STS;
                        //Set TRN_DT
                        oModelINST.INST_DT = this.TRN_DT;
                        //Process CRUD
                        db.Installment_ins.Add(oModelINST);
                    } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                    //Update
                    if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                    {
                        oModelINST = db.Installment_ins.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                        //Map Form Data
                        oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                        //Set Field Header
                        oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                        //Set DTA_STS : Set in METHOD controller
                        //oModelINST.DTA_STS = this.DTA_STS;
                        //Process CRUD
                        db.Entry(oModelINST).State = EntityState.Modified;
                    } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)

                    //Update database
                    db.SaveChanges();
                    this.INST_ID = oModelINST.ID;

                    //TRNDetail
                    Transaction_ind oModelTRN_detail = null;
                    foreach (var item in poViewModel.DETAIL)
                    {
                        oModelTRN_detail = new Transaction_ind();
                        item.TRN_ID      = this.ID;
                        item.INST_ID     = this.INST_ID;
                        //Map Form Data
                        oModelTRN_detail.InjectFrom(item);
                        //Set Field Header
                        oModelTRN_detail.setFIELD_HEADER(this.FIELD_HEADER);
                        //Set DTA_STS
                        oModelTRN_detail.DTA_STS = this.DTA_STS;

                        //Process CRUD
                        db.Transaction_inds.Add(oModelTRN_detail);
                    } //End foreach (var item in poViewModel.DETAIL)
                    //Update database
                    db.SaveChanges();
                }                                                                              //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create_bulk
Exemplo n.º 7
0
        } //End public void SaveNEW

        public void SaveNEW_create(Transaction_indetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    //TRN
                    Transaction_in oModelTRN = new Transaction_in();
                    //Map Form Data
                    oModelTRN.InjectFrom(poViewModel);
                    //Set Field Header
                    oModelTRN.setFIELD_HEADER(this.FIELD_HEADER);
                    //Set DTA_STS
                    oModelTRN.DTA_STS = this.DTA_STS;
                    //Process CRUD
                    db.Transaction_ins.Add(oModelTRN);
                    //Update database
                    db.SaveChanges();
                    this.ID     = oModelTRN.ID;
                    this.TRN_DT = oModelTRN.TRN_DT;

                    //INST
                    Installment_in        oModelINST  = null;
                    List <Installment_in> LIST_INST   = new List <Installment_in>();
                    Installment_in        DETAIL_INST = null;

                    //INST - SPP
                    if (poViewModel.MONTHLY_INST_SPP != null)
                    {
                        poViewModel.MONTHLY_INST = poViewModel.MONTHLY_INST_SPP;
                        //Create
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        {
                            oModelINST = new Installment_in();
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Set TRN_DT
                            oModelINST.INST_DT = this.TRN_DT;
                            //Process CRUD
                            db.Installment_ins.Add(oModelINST);
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        //Update
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        {
                            oModelINST = db.Installment_ins.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.MONTHLY_INST.ID);
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Process CRUD
                            db.Entry(oModelINST).State = EntityState.Modified;
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        //Update database-SPP
                        db.SaveChanges();
                        DETAIL_INST             = new Installment_in();
                        DETAIL_INST.ID          = oModelINST.ID;
                        DETAIL_INST.INST_TYPEID = oModelINST.INST_TYPEID;
                        LIST_INST.Add(DETAIL_INST);
                    } //End if (poViewModel.MONTHLY_INST_SPP != null)

                    //INST - EKSKUL
                    if (poViewModel.MONTHLY_INST_EKSKUL != null)
                    {
                        poViewModel.MONTHLY_INST = poViewModel.MONTHLY_INST_EKSKUL;
                        //Create
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        {
                            oModelINST = new Installment_in();
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Set TRN_DT
                            oModelINST.INST_DT = this.TRN_DT;
                            //Process CRUD
                            db.Installment_ins.Add(oModelINST);
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        //Update
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        {
                            oModelINST = db.Installment_ins.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.MONTHLY_INST.ID);
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Process CRUD
                            db.Entry(oModelINST).State = EntityState.Modified;
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        //Update database-EKSKUL
                        db.SaveChanges();
                        DETAIL_INST             = new Installment_in();
                        DETAIL_INST.ID          = oModelINST.ID;
                        DETAIL_INST.INST_TYPEID = oModelINST.INST_TYPEID;
                        LIST_INST.Add(DETAIL_INST);
                    } //End if (poViewModel.MONTHLY_INST_EKSKUL != null)

                    //INST - SCLUB
                    if (poViewModel.MONTHLY_INST_SCLUB != null)
                    {
                        poViewModel.MONTHLY_INST = poViewModel.MONTHLY_INST_SCLUB;
                        //Create
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        {
                            oModelINST = new Installment_in();
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Set TRN_DT
                            oModelINST.INST_DT = this.TRN_DT;
                            //Process CRUD
                            db.Installment_ins.Add(oModelINST);
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                        //Update
                        if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        {
                            oModelINST = db.Installment_ins.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.MONTHLY_INST.ID);
                            //Map Form Data
                            oModelINST.InjectFrom(poViewModel.MONTHLY_INST);
                            //Set Field Header
                            oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                            //Set DTA_STS : Set in METHOD controller
                            //oModelINST.DTA_STS = this.DTA_STS;
                            //Process CRUD
                            db.Entry(oModelINST).State = EntityState.Modified;
                        } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                        //Update database-SCLUB
                        db.SaveChanges();
                        DETAIL_INST             = new Installment_in();
                        DETAIL_INST.ID          = oModelINST.ID;
                        DETAIL_INST.INST_TYPEID = oModelINST.INST_TYPEID;
                        LIST_INST.Add(DETAIL_INST);
                    } //End if (poViewModel.MONTHLY_INST_SCLUB != null)

                    //INST - RANDOM
                    if (oViewModel.INSTLIST != null)
                    {
                        foreach (var item in oViewModel.INSTLIST)
                        {
                            poViewModel.INST = item;
                            //Create
                            if (poViewModel.INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                            {
                                oModelINST = new Installment_in();
                                //Map Form Data
                                oModelINST.InjectFrom(poViewModel.INST);
                                //Set Field Header
                                oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                                //Set DTA_STS : Set in METHOD controller
                                //oModelINST.DTA_STS = this.DTA_STS;
                                //Set TRN_DT
                                oModelINST.INST_DT = this.TRN_DT;
                                //Process CRUD
                                db.Installment_ins.Add(oModelINST);
                            } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_CREATE)
                            //Update
                            if (poViewModel.INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)
                            {
                                oModelINST = db.Installment_ins.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.INST.ID);
                                //Map Form Data
                                oModelINST.InjectFrom(poViewModel.INST);
                                //Set Field Header
                                oModelINST.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                                //Set DTA_STS : Set in METHOD controller
                                //oModelINST.DTA_STS = this.DTA_STS;
                                //Process CRUD
                                db.Entry(oModelINST).State = EntityState.Modified;
                            } //End if (poViewModel.MONTHLY_INST.DTA_STS == valFLAG.FLAG_DTA_STS_UPDATE)

                            //Save data
                            db.SaveChanges();
                            DETAIL_INST             = new Installment_in();
                            DETAIL_INST.ID          = oModelINST.ID;
                            DETAIL_INST.INST_TYPEID = oModelINST.INST_TYPEID;
                            LIST_INST.Add(DETAIL_INST);
                        } //End foreach (var item in oViewModel.INSTLIST)
                    }     //End if (oViewModel.INSTLIST != null)

                    //TRNDetail
                    Transaction_ind oModelTRN_detail = null;
                    foreach (var item in poViewModel.DETAIL)
                    {
                        oModelTRN_detail = new Transaction_ind();
                        item.TRN_ID      = this.ID;
                        //item.INST_ID = this.INST_ID;
                        if (LIST_INST.Count > 0)
                        {
                            var oData_INST = LIST_INST.Where(fld => fld.INST_TYPEID == item.TRINTYPE_ID).SingleOrDefault();
                            if (oData_INST != null)
                            {
                                item.INST_ID = oData_INST.ID;
                            }
                        } //End if (LIST_INST.Count > 0)


                        //Map Form Data
                        oModelTRN_detail.InjectFrom(item);
                        //Set Field Header
                        oModelTRN_detail.setFIELD_HEADER(this.FIELD_HEADER);
                        //Set DTA_STS
                        oModelTRN_detail.DTA_STS = this.DTA_STS;

                        //Process CRUD
                        db.Transaction_inds.Add(oModelTRN_detail);
                    } //End foreach (var item in poViewModel.DETAIL)
                    //Update database
                    db.SaveChanges();
                }                                                                              //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create_bulk