예제 #1
0
        public SendMail.Model.BackEndRefCode GetById(decimal id)
        {
            BackEndRefCode entity = null;

            try
            {
                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = selectByID;
                    oCmd.Parameters.Add("pId", id);
                    ICollection <BackEndRefCode> find = DaoOracleDbHelper <BackEndRefCode> .ExecSelectCommand(oCmd, DaoOracleDbHelper.MapToBackEndRefCode);

                    if (find.Count > 0)
                    {
                        return(find.First());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            //TODO:Exception Handling
            catch (Exception e0)
            {
                //Allineamento log - Ciro
                if (e0.GetType() != typeof(ManagedException))
                {
                    ManagedException me  = new ManagedException(e0.Message, "ORA_ERR002", string.Empty, string.Empty, e0);
                    ErrorLogInfo     err = new ErrorLogInfo(me);
                    log.Error(err);
                }
                return(null);
            }
        }
예제 #2
0
        public SendMail.Model.BackEndRefCode GetById(decimal id)
        {
            BackEndRefCode entity = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    RUBR_BACKEND b = dbcontext.RUBR_BACKEND.Where(x => x.ID_BACKEND == id).First();
                    if (b != null && b.ID_BACKEND != 0)
                    {
                        entity = AutoMapperConfiguration.FromRubrBackendToSingleModel(b);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e0)
            {
                if (e0.GetType() != typeof(ManagedException))
                {
                    ManagedException me  = new ManagedException(e0.Message, "ORA_ERR002", string.Empty, string.Empty, e0);
                    ErrorLogInfo     err = new ErrorLogInfo(me);
                    log.Error(err);
                }
                return(null);
            }
            return(entity);
        }
예제 #3
0
        public BackEndRefCode GetByCode(string backendCode)
        {
            BackEndRefCode entity = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    RUBR_BACKEND b = dbcontext.RUBR_BACKEND.Where(x => x.BACKEND_CODE.ToUpper() == backendCode.ToUpper()).First();
                    if (b != null && b.ID_BACKEND != 0)
                    {
                        entity = AutoMapperConfiguration.FromRubrBackendToSingleModel(b);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch
            {
                return(null);
            }
            return(entity);
        }
예제 #4
0
        internal static BackEndRefCode MapToBackEndRefCode(IDataRecord dr)
        {
            BackEndRefCode st = new BackEndRefCode();

            st.Id          = dr.GetDecimal("ID_BACKEND");
            st.Codice      = dr.GetString("BACKEND_CODE");
            st.Descrizione = dr.GetString("BACKEND_DESCR");
            st.Categoria   = dr.GetString("CATEGORY");
            return(st);
        }
예제 #5
0
        private OracleParameter[] MapObjectToParams(BackEndRefCode r, bool isInsert)
        {
            OracleParameter[] oparams = new OracleParameter[4];

            oparams[0] = new OracleParameter("pCODE", OracleDbType.Varchar2, 15, r.Codice, ParameterDirection.Input);
            oparams[1] = new OracleParameter("pDESCR", OracleDbType.Varchar2, 100, r.Descrizione, ParameterDirection.Input);
            oparams[2] = new OracleParameter("pCAT", OracleDbType.Varchar2, 40, r.Categoria, ParameterDirection.Input);

            if (isInsert)
            {
                oparams[3] = new OracleParameter("pID", OracleDbType.Decimal, r.Id, ParameterDirection.Output);
            }
            else
            {
                oparams[3] = new OracleParameter("pID", OracleDbType.Decimal, r.Id, ParameterDirection.Input);
            }

            return(oparams);
        }
예제 #6
0
 public void Insert(BackEndRefCode entity)
 {
     using (IBackEndCodeDao dao = this.getDaoContext().DaoImpl.BackEndCodeDao)
         dao.Insert(entity);
 }
예제 #7
0
        //funzione per visualizzare i dati dell'ente ricercato
        private void GetGridResult()
        {
            BackEndDictionaryService s = new BackEndDictionaryService();

            if ((codiceback.Text.Length == 0) && (descrizioneback.Text.Length == 0))
            {
                this.info.AddMessage("Attenzione: Immettere Codice Backend o la Descrizione", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                griBackend.Visible      = false;
                AccessoView.Visible     = false;
                pnlGrid.Visible         = false;
                PanelInsDettRic.Visible = false;
                //PanelRicerca.Visible = false;
                return;
            }

            if ((codiceback.Text.Length > 0) && (descrizioneback.Text.Length > 0))
            {
                griBackend.Visible      = false;
                AccessoView.Visible     = false;
                pnlGrid.Visible         = false;
                PanelInsDettRic.Visible = false;
                // PanelRicerca.Visible = false;
                this.info.AddMessage("Attenzione: Immettere Codice Backend o la Descrizione", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                return;
            }

            if (codiceback.Text.Length > 0)
            {
                AccessoView.Visible = false;
                //  Session["Accessopag"] = null;
                codeBk   = new List <BackEndRefCode>();
                appoggio = s.GetByCode(codiceback.Text);
                if (appoggio == null)
                {
                    this.info.AddMessage("Attenzione: Codice non presente", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    griBackend.Visible  = false;
                    pnlGrid.Visible     = false;
                    AccessoView.Visible = false;
                    return;
                }
                codeBk.Add(appoggio);
                griBackend.Visible    = true;
                griBackend.DataSource = codeBk;
                Session["Accesso"]    = codeBk;
                griBackend.DataBind();
                griBackend.Visible = true;
            }
            else
            {
                codeBk = null;
            }

            if (descrizioneback.Text.Length > 0)
            {
                AccessoView.Visible = false;
                listadescr          = s.GetByDescr(descrizioneback.Text);
                if (listadescr == null)
                {
                    this.info.AddMessage("Attenzione: Descrizione non presente", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    griBackend.Visible  = false;
                    pnlGrid.Visible     = false;
                    AccessoView.Visible = false;
                    return;
                }

                griBackend.DataSource = listadescr;
                Session["Accesso"]    = listadescr;
                griBackend.DataBind();
                griBackend.Visible = true;
                OnAccessoPagerIndexChanged("", 0);
                if (listadescr.Count <= PagerSize)
                {
                    griBackend.BottomPagerRow.Visible = false;
                }
                //  Session["Accessopag"] = null;
            }
            else if (codiceback.Text.Length == 0)
            {
                listadescr = null;
            }
        }
예제 #8
0
        protected void AccessoView_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Insert"))
            {
                BackEndRefCode           entity = new BackEndRefCode();
                BackEndDictionaryService s      = new BackEndDictionaryService();
                try
                {
                    if ((((TextBox)AccessoView.FindControl("TextCode")).Text != null) && (((TextBox)AccessoView.FindControl("TextCode")).Text != ""))
                    {
                        codInser = s.GetByCode(((TextBox)AccessoView.FindControl("TextCode")).Text);
                        if (codInser != null)
                        {
                            this.info.AddMessage("Attenzione: codice backend e' legato ad un altro accesso", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                            return;
                        }

                        entity.Codice = ((TextBox)AccessoView.FindControl("TextCode")).Text;
                    }
                    else
                    {
                        this.info.AddMessage("Attenzione: codice backend e' obbligatorio", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                        return;
                    }

                    entity.Descrizione     = ((TextBox)AccessoView.FindControl("TextDescrizione")).Text;
                    entity.Categoria       = ((TextBox)AccessoView.FindControl("TextCategoria")).Text;
                    entity.DescrizionePlus = ((TextBox)AccessoView.FindControl("TextDescrizionePlus")).Text;
                }

                catch
                {
                    this.info.AddMessage("Attenzione: si è verificato un errore", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }

                if (entity.Descrizione == "")
                {
                    entity.Descrizione = null;
                }
                if (entity.Categoria == "")
                {
                    entity.Categoria = null;
                }
                if (entity.DescrizionePlus == "")
                {
                    entity.DescrizionePlus = null;
                }

                try
                {
                    s.Insert(entity);
                    if (descrizioneback.Text.Length > 0)
                    {
                        listadescr = s.GetByDescr(descrizioneback.Text);
                        if (listadescr != null)
                        {
                            Session["Accesso"] = listadescr;
                            if (listadescr.Count > 0)
                            {
                                int index = listadescr.IndexOf(listadescr.First(x => x.Codice == entity.Codice));
                                OnAccessoPagerIndexChanged("", index / PagerSize);

                                // OnAccessoPagerIndexChanged("", 0);
                                if (listadescr.Count <= PagerSize)
                                {
                                    griBackend.BottomPagerRow.Visible = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        griBackend.Visible = false;
                        pnlGrid.Visible    = false;
                    }
                }
                catch (Exception ex)
                {
                    this.info.AddMessage("Inserimento non riuscito: Errore in banca dati dettagli " + ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                    return;
                }
                this.info.AddMessage("Accesso inserito", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                //  griBackend.Visible = false;
                //  AccessoView.Visible = false;
                this.AccessoView.DataSource = null;
                this.AccessoView.DataBind();
            }
            else
            {
                // BackEndRefCode entity = (BackEndRefCode)Session["AccessoId"];

                entity = (BackEndRefCode)Session["AccessoId"];

                int idCnt = Int32.Parse(((HiddenField)AccessoView.FindControl("hfIdAccesso")).Value);

                if (entity == null)
                {
                    return;
                }

                if (entity.Id == idCnt)
                {
                    if (e.CommandName.Equals("Update"))
                    {
                        try
                        {
                            AccessoView.ChangeMode(FormViewMode.Edit);

                            //((TextBox)AccessoView.FindControl("TextCode"));
                            if ((((TextBox)AccessoView.FindControl("TextCode")).Text != null) && (((TextBox)AccessoView.FindControl("TextCode")).Text != ""))
                            {
                                codInser = s.GetByCode(((TextBox)AccessoView.FindControl("TextCode")).Text);
                                if ((codInser != null) && (entity.Id != codInser.Id))
                                {
                                    this.info.AddMessage("Attenzione: codice backend e' legato ad un altro accesso", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                                    return;
                                }

                                entity.Codice = ((TextBox)AccessoView.FindControl("TextCode")).Text;
                            }
                            else
                            {
                                this.info.AddMessage("Attenzione: codice backend e' obbligatorio", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                                return;
                            }

                            entity.Descrizione     = ((TextBox)AccessoView.FindControl("TextDescrizione")).Text;
                            entity.Categoria       = ((TextBox)AccessoView.FindControl("TextCategoria")).Text;
                            entity.DescrizionePlus = ((TextBox)AccessoView.FindControl("TextDescrizionePlus")).Text;

                            List <BackEndRefCode> bkEnt = (List <BackEndRefCode>)Session["Accesso"];
                            int index = bkEnt.IndexOf(bkEnt.First(x => x.Id == idCnt));
                            OnAccessoPagerIndexChanged("", index / PagerSize);

                            if (bkEnt.Count <= PagerSize)
                            {
                                griBackend.BottomPagerRow.Visible = false;
                            }
                        }
                        catch
                        {
                            this.info.AddMessage("Attenzione: si è verificato un errore", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                            return;
                        }
                    }

                    if (e.CommandName.Equals("Delete"))
                    {
                        try
                        {
                            //metodo per l'update
                            s.Delete(idCnt);
                            if (descrizioneback.Text.Length > 0)
                            {
                                listadescr = s.GetByDescr(descrizioneback.Text);
                                if (listadescr != null)
                                {
                                    Session["Accesso"] = listadescr;
                                    OnAccessoPagerIndexChanged("", 0);
                                    if (listadescr.Count <= PagerSize)
                                    {
                                        griBackend.BottomPagerRow.Visible = false;
                                    }
                                }
                            }
                            else
                            {
                                griBackend.Visible = false;
                                pnlGrid.Visible    = false;
                            }
                        }
                        catch (Exception)
                        {
                            this.info.AddMessage("Cancellazione non riuscita: Errore in banca dati", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                            return;
                        }
                        this.info.AddMessage("Accesso cancellato", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);
                        PanelInsDettRic.Visible = false;
                        // griBackend.Visible = false;
                        AccessoView.Visible = false;
                    }
                }

                if (e.CommandName.Equals("Update"))
                {
                    if (entity.Descrizione == "")
                    {
                        entity.Descrizione = null;
                    }
                    if (entity.Categoria == "")
                    {
                        entity.Categoria = null;
                    }
                    if (entity.DescrizionePlus == "")
                    {
                        entity.DescrizionePlus = null;
                    }

                    try
                    {
                        //metodo per l'update
                        s.Update(entity);
                    }
                    catch (Exception)
                    {
                        this.info.AddMessage("Aggiornamento non riuscito: Errore in banca dati", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR);
                        return;
                    }
                    this.info.AddMessage("Accesso modificato", Com.Delta.Messaging.MapperMessages.LivelloMessaggio.INFO);

                    //   griBackend.Visible = true;
                    //   griBackend.DataSource = listadescrupd;
                    //   griBackend.DataBind();
                    PanelInsDettRic.Visible = false;
                    AccessoView.Visible     = false;
                }
            }
        }
 public void Insert(BackEndRefCode entity)
 {
     using (BackEndCodeSQLDb dao = new BackEndCodeSQLDb())
         dao.Insert(entity);
 }