示例#1
0
        public Article GetSingleById(int id)
        {
            Article  article;
            Serreurs erreur = new Serreurs("Erreur sur lecture des articles.", "ArticleList.getClients()");

            try
            {
                string    sql       = "SELECT * FROM articles WHERE no_article = " + id;
                DataTable dataTable = DBInterface.Lecture(sql, erreur);
                DataRow   dataRow   = dataTable.Rows[0];
                article = new Article(
                    int.Parse(dataRow["no_article"].ToString()),
                    dataRow["lib_article"].ToString(),
                    int.Parse(dataRow["qte_dispo"].ToString()),
                    dataRow["ville_art"].ToString(),
                    float.Parse(dataRow["prix_art"].ToString()),
                    dataRow["interrompu"].ToString()
                    );
                dataTable.Dispose();
                return(article);
            }
            catch (MonException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
        }
示例#2
0
        public static DataTable obtener(string nombre, int habilitado)
        {
            List <SqlParameter> parametros = new List <SqlParameter>();

            string sql = "SELECT rol_id, nombre, habilitado FROM WHERE_EN_EL_DELETE_FROM.Roles WHERE nombre<>'Guest'";

            SqlParameter parametro;

            if (nombre.Length > 0)
            {
                parametro        = new SqlParameter("@nombre", "%" + nombre + "%");
                parametro.DbType = DbType.String;
                parametros.Add(parametro);

                sql = String.Concat(sql, " AND nombre like @nombre");
            }

            if (habilitado != -1)
            {
                parametro        = new SqlParameter("@habilitado", habilitado);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                sql = String.Concat(sql, " AND habilitado=@habilitado");
            }

            DataTable dt = DBInterface.seleccionar(sql, parametros);

            return(dt);
        }
示例#3
0
        /// <summary>
        /// mise à jour d'un client sur son ID
        /// </summary>
        /// <param name="numCli">N° de l'utilisateur à lire</param>
        public static void UpdateClient(Clientel unCli)
        {
            Serreurs er      = new Serreurs("Erreur sur l'écriture d'un client.", "Client.update()");
            String   requete = "UPDATE Clientel SET " +
                               "SOCIETE = '" + unCli.Societe + "'" +
                               ", NOM_CL = '" + unCli.NomCl + "'" +
                               ", PRENOM_CL = '" + unCli.PrenomCl + "'" +
                               ", ADRESSE_CL = '" + unCli.AdresseCl + "'" +
                               ", VILLE_CL = '" + unCli.VilleCl + "'" +
                               ", CODE_POST_CL = '" + unCli.CodePostCl + "'" +
                               " WHERE NO_CLIENT LIKE '" + unCli.NuClient + "'";

            try
            {
                DBInterface.Insertion_Donnees(requete);
            }
            catch (MonException erreur)
            {
                throw erreur;
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#4
0
        public static IEnumerable <String> GetNuVendeurs()
        {
            IEnumerable <String> nuVendeurs = new List <String>();
            DataTable            dt;
            Serreurs             er = new Serreurs("Erreur sur lecture des vendeurs.", "VendeurDao.getNuVendeurs()");

            try
            {
                String mysql = "SELECT NO_VENDEUR FROM vendeur ORDER BY NO_VENDEUR";

                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    ((List <String>)nuVendeurs).Add(dataRow[0].ToString());
                }

                return(nuVendeurs);
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#5
0
        public DataTable GetSupervisorList(int ByID)
        {
            DBInterface  di = new DBInterface();
            SqlParameter p1 = new SqlParameter("@ByID", ByID);

            return(di.RunSPReturnDataTable("dbo.up_GetSupervisorsList", new SqlParameter[] { p1 }));
        }
示例#6
0
        public static Vendeur getVendeurById(string id)
        {
            String    sql = "SELECT * FROM vendeur WHERE NO_VENDEUR='" + id + "'";
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'une commande.", "Commandes.RechercheUneCommande()");

            try
            {
                dt = DBInterface.Lecture(sql, er);
                System.Console.WriteLine(sql);
                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Vendeur leVendeur = new Vendeur();
                    DataRow dataRow   = dt.Rows[0];
                    leVendeur.NoVendeur  = id;
                    leVendeur.NomVendeur = dataRow[2].ToString();

                    return(leVendeur);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#7
0
        public DataTable UpdateCatUserTracks(int PgID, int ObjID, string Reg, string Loc, string Species, string Thick, string Grade, string Len, string Color, string fSort, string Milling, string NoPrint, string Prod, string Desc,
                                             int ShowWks, int HideComments, int Excl0s, int FontSize, string Status, string CustCode, string VendorCode, string SupCode, string ItemCode, string ItemName, int Sort, int PgNbr, int PgSize, int ByID)
        {
            DBInterface  di  = new DBInterface();
            SqlParameter p1  = new SqlParameter("@UserID", ByID);
            SqlParameter p2  = new SqlParameter("@PgID", PgID);
            SqlParameter p3  = new SqlParameter("@ObjID", ObjID);
            SqlParameter p4  = new SqlParameter("@PgNbr", PgNbr);
            SqlParameter p5  = new SqlParameter("@PgSize", PgSize);
            SqlParameter p6  = new SqlParameter("@StatusCode", Status);
            SqlParameter p7  = new SqlParameter("@Product", Prod);
            SqlParameter p8  = new SqlParameter("@Reg", Reg);
            SqlParameter p9  = new SqlParameter("@Location", Loc);
            SqlParameter p10 = new SqlParameter("@Species", Species);
            SqlParameter p11 = new SqlParameter("@Thickness", Thick);
            SqlParameter p12 = new SqlParameter("@Grade", Grade);
            SqlParameter p13 = new SqlParameter("@Len", Len);
            SqlParameter p14 = new SqlParameter("@Color", Color);
            SqlParameter p15 = new SqlParameter("@fSort", fSort);
            SqlParameter p16 = new SqlParameter("@Milling", Milling);
            SqlParameter p17 = new SqlParameter("@NoPrint", NoPrint);
            SqlParameter p18 = new SqlParameter("@CustCode", CustCode);
            SqlParameter p19 = new SqlParameter("@VendorCode", VendorCode);
            SqlParameter p20 = new SqlParameter("@SupplierCode", SupCode);
            SqlParameter p21 = new SqlParameter("@ShowWks", ShowWks);
            SqlParameter p22 = new SqlParameter("@HideComments", HideComments);
            SqlParameter p23 = new SqlParameter("@Excl0s", Excl0s);
            SqlParameter p24 = new SqlParameter("@Sort", Sort);
            SqlParameter p25 = new SqlParameter("@FontSz", FontSize);
            SqlParameter p26 = new SqlParameter("@ItemCode", ItemCode);
            SqlParameter p27 = new SqlParameter("@ItemName", ItemName);
            SqlParameter p28 = new SqlParameter("@ItemDesc", Desc);

            return(di.RunSPReturnDataTableNWB("web.usp_UpdateCatUserTracks", new SqlParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28 }));
        }
示例#8
0
        public Empleado(int empleadoId)
        {
            if (empleadoId > 0)
            {
                List <SqlParameter> parametros = new List <SqlParameter>();

                SqlParameter parametro = new SqlParameter("@empleadoId", empleadoId);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                string    sql  = "SELECT empleado_id, usuario_id, mail, nombre, apellido, documento_tipo, documento_nro, telefono, direccion_calle, direccion_nro, direccion_piso, direccion_depto, direccion_localidad, direccion_pais FROM WHERE_EN_EL_DELETE_FROM.empleados WHERE empleado_id=@empleadoId";
                DataTable data = DBInterface.seleccionar(sql, parametros);

                if (data.Rows.Count == 1)
                {
                    this.empleado_id         = Convert.ToInt32(data.Rows[0][0]);
                    this.usuario_id          = Convert.ToInt32(data.Rows[0][1]);
                    this.email               = data.Rows[0][2].ToString();
                    this.nombre              = data.Rows[0][3].ToString();
                    this.apellido            = data.Rows[0][4].ToString();
                    this.documento_tipo      = data.Rows[0][5].ToString();
                    this.documento_numero    = data.Rows[0][6].ToString();
                    this.telefono            = data.Rows[0][7].ToString();
                    this.direccion_calle     = data.Rows[0][8].ToString();
                    this.direccion_nro       = data.Rows[0][9].ToString();
                    this.direccion_piso      = data.Rows[0][10].ToString();
                    this.direccion_depto     = data.Rows[0][11].ToString();
                    this.direccion_localidad = data.Rows[0][12].ToString();
                    this.direccion_pais      = data.Rows[0][13].ToString();
                }
            }
        }
示例#9
0
        public DataTable SelectRequestListALL(string DocTypeCode, int CreditRpID, int SalesRpID, string Cust, int OrdNbr, string Reason, string Status, string Loc, string sBDt, string sEDt, int Sort, int PgNbr, int PgSize, int ByID)
        {
            DateTime?sdate = null;
            DateTime?edate = null;

            if (sBDt.Length > 0)
            {
                sdate = Convert.ToDateTime(sBDt);
            }
            if (sEDt.Length > 0)
            {
                edate = Convert.ToDateTime(sEDt);
            }
            DBInterface  di  = new DBInterface();
            SqlParameter p1  = new SqlParameter("@DocTypeCode", DocTypeCode);
            SqlParameter p2  = new SqlParameter("@CreditRepID", CreditRpID);
            SqlParameter p3  = new SqlParameter("@SalesRepID", SalesRpID);
            SqlParameter p4  = new SqlParameter("@Cust", Cust);
            SqlParameter p5  = new SqlParameter("@OrdNbr", Sort);
            SqlParameter p6  = new SqlParameter("@Reason", Reason);
            SqlParameter p7  = new SqlParameter("@Status", Status);
            SqlParameter p8  = new SqlParameter("@Loc", Loc);
            SqlParameter p9  = new SqlParameter("@BDate", sdate);
            SqlParameter p10 = new SqlParameter("@EDate", edate);
            SqlParameter p11 = new SqlParameter("@Sort", Sort);
            SqlParameter p12 = new SqlParameter("@PgNbr", PgNbr);
            SqlParameter p13 = new SqlParameter("@PgSzie", PgSize);
            SqlParameter p14 = new SqlParameter("@ByID", ByID);

            return(di.RunSPReturnDataTableNWB("web.usp_SelectRequestListALL", new SqlParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 }));
        }
示例#10
0
        public DataTable UpdateCatToolProductData(int ID, string Region, string Product, string ProdID, string Desc, double Price, string Comments, string Specie, string Thickness, string Grade, string Len,
                                                  string Color, string Sort, string Milling, string NoPrint, int NbrAttach, int Mngd, int Track, int ByID)
        {
            DBInterface  di = new DBInterface();
            SqlParameter p1 = new SqlParameter("@CatDataID", ID);
            SqlParameter p2 = new SqlParameter("@Region", Region);
            //SqlParameter p3 = new SqlParameter("@RegionID", RegID);
            SqlParameter p3  = new SqlParameter("@Product", Product);
            SqlParameter p4  = new SqlParameter("@ProdID", ProdID);
            SqlParameter p5  = new SqlParameter("@ProdDesc", Desc);
            SqlParameter p6  = new SqlParameter("@Price", Price);
            SqlParameter p7  = new SqlParameter("@Comments", Comments);
            SqlParameter p8  = new SqlParameter("@Specie", Specie);
            SqlParameter p9  = new SqlParameter("@Thickness", Thickness);
            SqlParameter p10 = new SqlParameter("@Grade", Grade);
            SqlParameter p11 = new SqlParameter("@Length", Len);
            SqlParameter p12 = new SqlParameter("@Color", Color);
            SqlParameter p13 = new SqlParameter("@Sort", Sort);
            SqlParameter p14 = new SqlParameter("@Milling", Milling);
            SqlParameter p15 = new SqlParameter("@NoPrint", NoPrint);
            SqlParameter p16 = new SqlParameter("@NbrAttach", NbrAttach);
            SqlParameter p17 = new SqlParameter("@Managed", Mngd);
            SqlParameter p18 = new SqlParameter("@Tracked", Track);
            SqlParameter p19 = new SqlParameter("@ByID", ByID);

            return(di.RunSPReturnDataTableNWB("web.usp_UpdateCatProduct", new SqlParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19 }));
        }
示例#11
0
        public void Load()
        {
            if (ID != -1)
            {
                IDBInterface db = DBInterface.CreatePointer();

                db.StoredProcedure("mile_card_status_select_by_id");
                db.AddParameter("@inIdMileCardStatus", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);
                db.AddOutParameter("@outStatus", MySql.Data.MySqlClient.MySqlDbType.String);
                db.AddOutParameter("@outMinMiles", MySql.Data.MySqlClient.MySqlDbType.Int32);
                db.AddOutParameter("@outMaxMiles", MySql.Data.MySqlClient.MySqlDbType.Int32);
                db.AddOutParameter("@outIdAviaCompanyUnion", MySql.Data.MySqlClient.MySqlDbType.Int32);
                db.AddOutParameter("@outIdAviaCompany", MySql.Data.MySqlClient.MySqlDbType.Int32);
                db.AddOutParameter("@outNote", MySql.Data.MySqlClient.MySqlDbType.String);

                db.Execute();

                Name   = db.GetOutParameterStr("@outStatus");
                MinVal = db.GetOutParameterInt("@outMinMiles");
                MaxVal = db.GetOutParameterInt("@outMaxMiles");

                Note = db.GetOutParameterStr("@outNote");

                AviaCompanyID      = db.GetOutParameterInt("@outIdAviaCompany");
                AviaCompanyUnionID = db.GetOutParameterInt("@outIdAviaCompanyUnion");

                Changed = false;
            }
        }
示例#12
0
        public override void Load()
        {
            Clear();
            DBInterface.CommandText = "SELECT * FROM sellcontroller.milecardstatus;";

            DataTable tab = DBInterface.ExecuteSelection();

            foreach (DataRow row in tab.Rows)
            {
                MileCardStatus mcs = new MileCardStatus();

                mcs.ID     = Convert.ToInt32(row["idMileCardStatus"]);
                mcs.Name   = row["status"].ToString();
                mcs.MinVal = Convert.ToInt32(row["minMiles"]);
                mcs.MaxVal = Convert.ToInt32(row["maxMiles"]);

                if (row["idAviaCompanyUnion"] != DBNull.Value)
                {
                    mcs.AviaCompanyUnionID = Convert.ToInt32(row["idAviaCompanyUnion"]);
                }

                if (row["idAviaCompany"] != DBNull.Value)
                {
                    mcs.AviaCompanyID = Convert.ToInt32(row["idAviaCompany"]);
                }

                mcs.Note = row["note"].ToString();

                this.Add(mcs);
            }
        }
示例#13
0
        /// <summary>
        /// mise à jour d'un vendeur sur son ID
        /// </summary>
        /// <param name="uneCom">Vendeur à mettre à jour</param>
        public static void updateCommande(Commande uneCom)
        {
            Serreurs er      = new Serreurs("Erreur sur l'écriture d'une commande.", "Commande.update()");
            String   requete = "UPDATE commandes SET " +
                               "NO_VENDEUR = " + uneCom.noVendeur +
                               ", NO_CLIENT = " + uneCom.noClient +
                               ", DATE_CDE = '" + uneCom.dateCde.ToString("yyyy-MM-dd") + "'" +
                               ", FACTURE = '" + uneCom.facture + "'" +
                               " WHERE NO_COMMAND = " + uneCom.noCommande;

            try
            {
                DBInterface.Insertion_Donnees(requete);
            }
            catch (MonException erreur)
            {
                throw erreur;
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }

            // TODO Ajouter la modification/insertion/suppression éventuelle des articles qu'elle contient
        }
示例#14
0
        public static List <ArticleCommande> getArticlesFromCommande(int noCom)
        {
            List <ArticleCommande> articles = new List <ArticleCommande>();
            DataTable       dt;
            ArticleCommande article;
            Serreurs        er = new Serreurs("Erreur sur lecture des articles de la commande.", "ArticlesList.getArticles()");

            try
            {
                String mysql = "SELECT NO_ARTICLE, QTE_CDEE, LIVREE FROM detail_cde " +
                               "WHERE NO_COMMAND = " + noCom + " ORDER BY NO_ARTICLE";

                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    article = new ArticleCommande();
                    article.QuantiteCommandee = int.Parse(dataRow[1].ToString());
                    article.Livree            = dataRow[2].ToString();
                    article.Article           = Article.getArticle(int.Parse(dataRow[0].ToString()));

                    ((List <ArticleCommande>)articles).Add(article);
                }

                return(articles);
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#15
0
        // depreciated
        public DataTable UpdateSalesProductTrackItem(int id, int Type, string Region, string Prod, string ProdDesc, double Price, string Specie, string Thickness, string Grade, string Len, string Color, string Sort,
                                                     string Milling, string NoPrint, string ProdType, string ExpPrgID, int Tracked, int Mngd, string Comments, int ByID)
        {
            DBInterface  di  = new DBInterface();
            SqlParameter p1  = new SqlParameter("@ProdMngdID", id);
            SqlParameter p2  = new SqlParameter("@ProdType", ProdType);
            SqlParameter p3  = new SqlParameter("@ProdCode", Prod);
            SqlParameter p4  = new SqlParameter("@ProdDesc", ProdDesc);
            SqlParameter p5  = new SqlParameter("@Price", Price);
            SqlParameter p6  = new SqlParameter("@Region", Region);
            SqlParameter p7  = new SqlParameter("@Specie", Specie);
            SqlParameter p8  = new SqlParameter("@Thickness", Thickness);
            SqlParameter p9  = new SqlParameter("@Grade", Grade);
            SqlParameter p10 = new SqlParameter("@Len", Len);
            SqlParameter p11 = new SqlParameter("@Color", Color);
            SqlParameter p12 = new SqlParameter("@Sort", Sort);
            SqlParameter p13 = new SqlParameter("@Milling", Milling);
            SqlParameter p14 = new SqlParameter("@NoPrint", NoPrint);
            SqlParameter p15 = new SqlParameter("@ExpPrgID", ExpPrgID);
            SqlParameter p16 = new SqlParameter("@Comments", Comments);
            SqlParameter p17 = new SqlParameter("@Track", Tracked);
            SqlParameter p18 = new SqlParameter("@Managed", Mngd);
            SqlParameter p19 = new SqlParameter("@Type", Type);
            SqlParameter p20 = new SqlParameter("@ByID", ByID);

            return(di.RunSPReturnDataTableNWB("web.usp_UpdateSalesProductTrackingItem", new SqlParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20 }));
        }
        public static Scenariste GetScenaristeByName(String nom_scenariste)
        {
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur lecture des Scenaristes.", "Scenariste.getScenariste()");

            try
            {
                String mysql = "Select  * ";
                mysql += " from scenariste WHERE nom_scenariste = '" + nom_scenariste + "'";
                dt     = DBInterface.Lecture(mysql, er);
                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    DataRow    dataRow = dt.Rows[0];
                    Scenariste s       = new Scenariste(int.Parse(dataRow[0].ToString()), dataRow[1].ToString(), dataRow[2].ToString());
                    return(s);
                }
                else
                {
                    return(new Scenariste(-1, "", "")); //-1 spécifie que le scénariste n'est pas dans la base de donné
                }
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#17
0
        public DataTable GetCatToolGridDataSvc(string Region, string LocID, string Product, string SpecID, string Thickness, string GradeID, string Len, string Color, string fSort, string Milling, string NoPrint,
                                               string Desc, int Excl0, int Sort, int Active, int ShowLoc, string ColsOn, int PgNbr, int PgSize, int ByID)
        {
            DBInterface  di  = new DBInterface();
            SqlParameter p1  = new SqlParameter("@Region", Region);
            SqlParameter p2  = new SqlParameter("@LocID", LocID);
            SqlParameter p3  = new SqlParameter("@Product", Product);
            SqlParameter p4  = new SqlParameter("@SpeciesID", SpecID);
            SqlParameter p5  = new SqlParameter("@Thickness", Thickness);
            SqlParameter p6  = new SqlParameter("@GradeID", GradeID);
            SqlParameter p7  = new SqlParameter("@Length", Len);
            SqlParameter p8  = new SqlParameter("@Color", Color);
            SqlParameter p9  = new SqlParameter("@fSort", fSort);
            SqlParameter p10 = new SqlParameter("@Milling", Milling);
            SqlParameter p11 = new SqlParameter("@NoPrint", NoPrint);
            SqlParameter p12 = new SqlParameter("@Desc", Desc);
            SqlParameter p13 = new SqlParameter("@Exclude0", Excl0);
            SqlParameter p14 = new SqlParameter("@Sort", Sort);
            SqlParameter p15 = new SqlParameter("@Active", Active);
            SqlParameter p16 = new SqlParameter("@ShowLoc", ShowLoc);
            SqlParameter p17 = new SqlParameter("@ColsOn", ColsOn);
            SqlParameter p18 = new SqlParameter("@PgNbr", PgNbr);
            SqlParameter p19 = new SqlParameter("@PgSize", PgSize);
            SqlParameter p20 = new SqlParameter("@ByID", ByID);

            return(di.RunSPReturnDataTableNWB("web.usp_SelectCatToolGridDataSvc", new SqlParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20 }));
        }
示例#18
0
        private void LoadEventTypes()
        {
            try
            {
                //Get database connection information
                string server   = ConfigurationManager.AppSettings["Server"];
                string database = ConfigurationManager.AppSettings["Database"];
                string username = ConfigurationManager.AppSettings["UserName"];
                string password = ConfigurationManager.AppSettings["Password"];

                //Initalise database class
                DBInterface dbi = new DBInterface(server, database, username, password);

                //Get EventTypes from database
                DataTable dt = dbi.GetEventTypes();

                //Create default event type
                DataRow row = dt.NewRow();
                row["ID"]        = 0;
                row["EventType"] = "All";

                //Insert into datatable
                dt.Rows.InsertAt(row, 0);

                //Get EventType column from datatable and load into combo box
                cbEventType.ItemsSource = dt.AsEnumerable().Select(r => r.Field <string>("EventType"));

                //Set default value
                cbEventType.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                //System.Diagnostics.EventLog.WriteEntry can cause errors if the event type is not there, TODO: find new way to log errors
            }
        }
        public List <KeyValuePair <string, string> > guardar()
        {
            List <KeyValuePair <string, string> > errores = this.validar();

            if (errores.Count == 0)
            {
                List <SqlParameter> parametros = new List <SqlParameter>();

                SqlParameter parametro = new SqlParameter("@rolId", this.rol_id);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                parametro        = new SqlParameter("@permisoId", this.permiso_id);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                string    sql = "SELECT rol_id FROM WHERE_EN_EL_DELETE_FROM.roles_permisos WHERE rol_id=@rolId AND permiso_id = @permisoId";
                DataTable dt  = DBInterface.seleccionar(sql, parametros);

                if (dt.Rows.Count == 0)
                {
                    errores = errores.Concat(this.insertar()).ToList();
                }
                else
                {
                    errores.Add(new KeyValuePair <string, string>("general", "El permiso '" + this.Permiso.Nombre + "' ya esta asociado al rol '" + this.Rol.Nombre + "'."));
                }
            }

            return(errores);
        }
示例#20
0
        public void Load()
        {
            Changed = false;

            DBInterface.CommandText = "select ownerName, ownerSurname, number, idCitizen, idCountry, expireDate, note, isActive from passport where idPassport = @id;";
            DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);

            DataTable tab = DBInterface.ExecuteSelection();

            if ((tab != null) && (tab.Rows.Count == 1))
            {
                PersonName    = tab.Rows[0]["ownerName"].ToString();
                PersonSurname = tab.Rows[0]["ownerSurname"].ToString();
                SerialNumber  = tab.Rows[0]["number"].ToString();
                ValidTill     = Convert.ToDateTime(tab.Rows[0]["expireDate"]);
                Description   = tab.Rows[0]["note"].ToString();

                int idCountry = Convert.ToInt32(tab.Rows[0]["idCountry"]);
                CountryOfEmmitation    = new Country();
                CountryOfEmmitation.ID = idCountry;
                CountryOfEmmitation.Load();

                int idCitizen = Convert.ToInt32(tab.Rows[0]["idCitizen"]);
                Citizen    = new Country();
                Citizen.ID = idCountry;
                Citizen.Load();

                vizaList = null;
            }
        }
        public List <KeyValuePair <string, string> > eliminar()
        {
            List <KeyValuePair <string, string> > errores = new List <KeyValuePair <string, string> >();

            List <SqlParameter> parametros = new List <SqlParameter>();

            SqlParameter parametro = new SqlParameter("@rolId", this.rol_id);

            parametro.DbType = DbType.Int32;
            parametros.Add(parametro);

            parametro        = new SqlParameter("@permisoId", this.permiso_id);
            parametro.DbType = DbType.Int32;
            parametros.Add(parametro);

            string sql       = "DELETE FROM WHERE_EN_EL_DELETE_FROM.roles_permisos WHERE rol_id=@rolId AND permiso_id = @permisoId";
            int    eliminado = DBInterface.borrar(sql, parametros);

            if (eliminado != 1)
            {
                errores.Add(new KeyValuePair <string, string>("general", "No se pudo eliminar el permiso."));
            }

            return(errores);
        }
示例#22
0
        public static IEnumerable <Vendeur> getVendeurs()
        {
            IEnumerable <Vendeur> vendeurs = new List <Vendeur>();
            DataTable             dt;
            Vendeur  vendeur;
            Serreurs er = new Serreurs("Erreur sur recherche d'un vendeur.", "vendeur.RechercheDesVendeurs()");

            try
            {
                String mysql = "SELECT NO_VENDEUR ";
                mysql += "FROM vendeur";

                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    vendeur           = new Vendeur();
                    vendeur.NoVendeur = dataRow[0].ToString();

                    ((List <Vendeur>)vendeurs).Add(vendeur);
                }
                return(vendeurs);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
        private List <KeyValuePair <string, string> > insertar()
        {
            List <KeyValuePair <string, string> > errores = new List <KeyValuePair <string, string> >();

            try
            {
                List <SqlParameter> parametros = new List <SqlParameter>();

                SqlParameter parametro = new SqlParameter("@rolId", this.rol_id);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                parametro        = new SqlParameter("@permisoId", this.permiso_id);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);


                string sql       = "INSERT INTO WHERE_EN_EL_DELETE_FROM.roles_permisos (rol_id, permiso_id) VALUES (@rolId, @permisoId)";
                int    insertado = DBInterface.insertar(sql, parametros);

                if (insertado != 1)
                {
                    errores.Add(new KeyValuePair <string, string>("general", "El permiso no pudo ser guardado."));
                }
            }
            catch (Exception e)
            {
                errores.Add(new KeyValuePair <string, string>("general", e.Message));
            }

            return(errores);
        }
示例#24
0
        public static List <String> GetNuClients()
        {
            /// <summary>
            /// Lister les clients de la base
            /// </summary>
            /// <returns>Liste de numéros de clients</returns>
            List <String> mesNumeros = new List <String>();
            DataTable     dt;
            Serreurs      er = new Serreurs("Erreur sur lecture des clients.", "Client.LectureNuClient()");

            try
            {
                String mysql = "SELECT DISTINCT NO_CLIENT FROM clientel ORDER BY NO_CLIENT";
                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    mesNumeros.Add(dataRow[0].ToString());
                }

                return(mesNumeros);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#25
0
        public IEnumerable <Vendeur> GetAll()
        {
            IEnumerable <Vendeur> vendeurs = new List <Vendeur>();
            Serreurs erreur = new Serreurs("Erreur sur lecture des vendeur.", "ClientsList.getClients()");

            try
            {
                string    sql       = "SELECT * FROM vendeur ORDER BY no_vendeur";
                DataTable dataTable = DBInterface.Lecture(sql, erreur);
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ((List <Vendeur>)vendeurs).Add(new Vendeur(
                                                       dataRow["no_vendeur"].ToString(),
                                                       null,
                                                       dataRow["nom_vend"].ToString(),
                                                       dataRow["prenom_vend"].ToString(),
                                                       dataRow["date_embau"].ToString(),
                                                       dataRow["ville_vend"].ToString(),
                                                       float.Parse(dataRow["salaire_vend"].ToString()),
                                                       float.Parse(dataRow["commission"].ToString())
                                                       ));
                }
                dataTable.Dispose();
                return(vendeurs);
            }
            catch (MonException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
        }
示例#26
0
        public IEnumerable <Article> GetAll()
        {
            IEnumerable <Article> articles = new List <Article>();
            Serreurs erreur = new Serreurs("Erreur sur lecture des articles.", "ArticleList.getClients()");

            try
            {
                string    sql       = "SELECT * FROM article ORDER BY no_article";
                DataTable dataTable = DBInterface.Lecture(sql, erreur);
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ((List <Article>)articles).Add(new Article(
                                                       int.Parse(dataRow["no_article"].ToString()),
                                                       dataRow["lib_article"].ToString(),
                                                       int.Parse(dataRow["qte_dispo"].ToString()),
                                                       dataRow["ville_art"].ToString(),
                                                       float.Parse(dataRow["prix_art"].ToString()),
                                                       dataRow["interrompu"].ToString()
                                                       ));
                }
                dataTable.Dispose();
                return(articles);
            }
            catch (MonException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
        }
示例#27
0
        public Vendeur GetSingleById(int id)
        {
            Vendeur  vendeur;
            Serreurs erreur = new Serreurs("Erreur sur lecture des clients.", "ClientsList.getClients()");

            try
            {
                string    sql       = "SELECT * FROM vendeur WHERE no_vendeur = " + id;
                DataTable dataTable = DBInterface.Lecture(sql, erreur);
                DataRow   dataRow   = dataTable.Rows[0];
                vendeur = new Vendeur(
                    dataRow["no_vendeur"].ToString(),
                    null,
                    dataRow["nom_vend"].ToString(),
                    dataRow["prenom_vend"].ToString(),
                    dataRow["date_embau"].ToString(),
                    dataRow["ville_vend"].ToString(),
                    float.Parse(dataRow["salaire_vend"].ToString()),
                    float.Parse(dataRow["commission"].ToString())
                    );
                return(vendeur);
            }
            catch (MonException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(erreur.MessageUtilisateur(), erreur.MessageApplication(), e.Message);
            }
        }
        public static List <KeyValuePair <string, string> > actualizarPermisos(Rol rol)
        {
            List <KeyValuePair <string, string> > errores = new List <KeyValuePair <string, string> >();

            if (rol.RolId > 0)
            {
                List <SqlParameter> parametros = new List <SqlParameter>();

                SqlParameter parametro = new SqlParameter("@rolId", rol.RolId);
                parametro.DbType = DbType.Int32;
                parametros.Add(parametro);

                string sql = "DELETE FROM WHERE_EN_EL_DELETE_FROM.roles_permisos WHERE rol_id=@rolId";
                DBInterface.borrar(sql, parametros);

                foreach (Permiso permiso in rol.PermisosDados)
                {
                    if (permiso.PermisoId > 0)
                    {
                        RolPermiso rolpermiso = new RolPermiso(rol.RolId, permiso.PermisoId);
                        errores = errores.Concat(rolpermiso.guardar()).ToList();
                    }
                    else
                    {
                        errores.Add(new KeyValuePair <string, string>("general", "El permiso '" + permiso.Nombre + "' no es valido"));
                    }
                }
            }
            else
            {
                errores.Add(new KeyValuePair <string, string>("general", "El rol '" + rol.Nombre + "' no es valido"));
            }

            return(errores);
        }
示例#29
0
        public static Clientel getClientById(String id)
        {
            String    sql = "SELECT * FROM clientel WHERE NO_CLIENT='" + id + "'";
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'une commande.", "Commandes.RechercheUneCommande()");

            try
            {
                dt = DBInterface.Lecture(sql, er);
                System.Console.WriteLine(sql);
                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Clientel leClient = new Clientel();
                    DataRow  dataRow  = dt.Rows[0];
                    leClient.NoClient   = id;
                    leClient.Societe    = dataRow[1].ToString();
                    leClient.NomCl      = dataRow[2].ToString();
                    leClient.PrenomCl   = dataRow[3].ToString();
                    leClient.AdresseCl  = dataRow[4].ToString();
                    leClient.VilleCl    = dataRow[5].ToString();
                    leClient.CodePostCl = dataRow[6].ToString();
                    return(leClient);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
示例#30
0
        public override void Load()
        {
            Clear();

            DBInterface.CommandText = "select " +
                                      "contact.idContact, " +
                                      "typecontact.nameContact, " +
                                      "contact.value, " +
                                      "contact.description " +
                                      "from contact " +
                                      "left join person " +
                                      "on contact.idPerson = person.idPerson " +
                                      "left join typecontact " +
                                      "on contact.idTypeContact = typecontact.idTypeContact " +
                                      "where " +
                                      "person.idPerson = @id;";

            DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, person.ID);

            DataTable tab = DBInterface.ExecuteSelection();

            foreach (DataRow row in tab.Rows)
            {
                Contact item = Contact.Create(Convert.ToString(row["nameContact"]));
                item.ID          = Convert.ToInt32(row["idContact"]);
                item.Content     = Convert.ToString(row["value"]);
                item.Description = Convert.ToString(row["description"]);
                Add(item);
            }
        }
示例#31
0
 public object Post(object value)
 {
     //Dictionary<string, List<Dictionary<string, string>>>
     //return value;
     var js = new JsonSerializer();
     DBInterface dbo = new DBInterface();
     DBInterface.parseJSON(value.ToString()); 
    
     string test =
         "{\"reportInformation\":\"Database 1: Employees, Sales | Database 2: Products, Testing\",\"date\":\"Date Generated\",\"columns\":[\"Id\",\"ItemName\",\"Description\",\"Stock\",\"ItemId\",\"Lifetime\",\"Notes\"],\"rows\":[{\"Id\":\"123\",\"ItemName\":\"Lens\",\"Description\":\"A lens to see.\",\"Stock\":\"150\",\"ItemId\":\"5679435\",\"Lifetime\":\"400000\",\"Notes\":\"Needs reordering\"},{\"Id\":\"234\",\"ItemName\":\"Frame\",\"Description\":\"A frame for a lens.\",\"Stock\":\"15\",\"ItemId\":\"1534723\",\"Lifetime\":\"300000\",\"Notes\":\"In Stock\"}]}";
               
     return test; 
 }