Example #1
0
 //Adding items in menu from DB
 public RibbonSample()
     : base(Globals.Factory.GetRibbonFactory())
 {
     InitializeComponent();
     try
     {
         System.Data.DataTable dt = new DataAcces().GetData();
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 RibbonButton Field = this.Factory.CreateRibbonButton();
                 Field.Label       = dt.Rows[i][1].ToString();
                 Field.Tag         = i;
                 Field.ControlSize =
                     Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
                 Field.Click += Field_Click;
                 menu1.Items.Add(Field);
             }
         }
         else
         {
             System.Windows.Forms.MessageBox.Show("No Fields are available in database");
         }
     }
     catch (Exception exception)
     {
         //thrw exception
     }
 }
Example #2
0
        // Récupère le choix du votant lorsque le sondage est à choix unique
        public ActionResult RecuperationVoteChoixUnique(int idSondage, string resultatchoix, int numeroSecurite)
        {
            if (TestSondagevote(Request.Cookies, idSondage))
            {
                return(RedirectToAction("PageDejaVoter", new { IdSondage = idSondage, NumeroSecurite = numeroSecurite }));
            }
            ClassResultat Vote = new ClassResultat(0, 0, 0, 0, idSondage);

            switch (resultatchoix)
            {
            case "Choix1":
                Vote.ResultatChoix1 = 1;
                break;

            case "Choix2":
                Vote.ResultatChoix2 = 1;
                break;

            case "Choix3":
                Vote.ResultatChoix3 = 1;
                break;

            case "Choix4":
                Vote.ResultatChoix4 = 1;
                break;
            }


            DataAcces.InsererResultatEnBDD(idSondage, Vote.ResultatChoix1, Vote.ResultatChoix2, Vote.ResultatChoix3, Vote.ResultatChoix4);
            SauvegardeDesCookie(idSondage);
            return(RedirectToAction("PageResultat", new { IdSondage = idSondage }));
        }
Example #3
0
        public async Task OnGetAsync()
        {
            ApplicationUser = await UserManager.GetUserAsync(User);

            Order        = DataAcces.GetLastOrder(ApplicationUser.Id);
            ShoppingCart = new ShoppingCart(Order.Items.Split(";").ToList(), DataAcces);
        }
Example #4
0
        public ActionResult Resultat(int idsondageCourant)
        {
            ClasseSondage sondage = DataAcces.RecupererSondageEnBDD(idsondageCourant);


            return(View(sondage));
        }
Example #5
0
 private void Save()
 {
     try
     {
         if (Admin.ComponentesMensajes.Validar(Title, "Title") == false)
         {
             return;
         }
         if (Admin.ComponentesMensajes.Validar(Client, "Client") == false)
         {
             return;
         }
         if (Admin.ComponentesMensajes.Validar(Description, "Description") == false)
         {
             return;
         }
         Title               = this.Title;
         Client              = this.Client;
         DeliveryDate        = this.DeliveryDate;
         DeliveryInformation = this.DeliveryInformation;
         Description         = this.Description;
         IsDelivered         = false;
         using (var datos = new DataAcces())
         {
             datos.insert(new[] { this });
             Admin.ComponentesMensajes.Insert("OrderCreated");
             Admin.navigationService.Navigate("MainPage");
         };
     }
     catch (Exception e)
     {
         Admin.ComponentesMensajes.Error("Error", e);
     }
 }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataAcces dataAcces = new DataAcces();
                string    tempID;
                string    description = productoTxt.Text;
                int       price       = int.Parse(precioTxt.Text);



                Product product = new Product(description, price);

                foreach (DataGridViewRow row in dataGridView1.SelectedRows)
                {
                    tempID     = row.Cells[0].Value.ToString();
                    product.Id = int.Parse(tempID);
                }
                dataAcces.UpdateProduct(product);
                dataAcces.displayProducts(dataGridView1);
                productoTxt.Clear();
                precioTxt.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex);
            }
        }
Example #7
0
        private void SaveOrderBTN_Click(object sender, EventArgs e)
        {
            DataAcces access      = new DataAcces();
            int       idClient    = Convert.ToInt16(CDGTXT.Text);
            DateTime  orderDate   = DateTime.Now;
            DateTime  requireDate = ReleaseDate_Picker.Value;
            int       total       = Convert.ToInt32(Total_TXT.Text);

            if (requireDate.Equals(orderDate) || requireDate < orderDate)
            {
                MessageBox.Show("La fecha de entrega debe ser mayor a la fecha actual");
                return;
            }
            Order order = new Order(idClient, orderDate, requireDate, total);

            access.saveOrder(order);


            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                int     id       = (int)row.Cells[0].Value;
                int     quantity = Convert.ToInt32(row.Cells[2].Value);
                int     price    = (int)row.Cells[3].Value;
                Product product  = new Product(id, price, quantity);
                access.saveOrderProducts(product);
            }
            formulario.RefreshDatagrid();
            dataGridView1.Rows.Clear();
            CDGTXT.Clear();
            Total_TXT.Clear();
            NOMTXT.Clear();
            APTXT.Clear();
        }
Example #8
0
    private void colorMaxAndMin()
    {
        Boolean minFlag = false;
        Boolean maxFlag = false;
        string  minMax  = new DataAcces("colorMaxAndMin @min out,@max out", CommandType.StoredProcedure, null, Enums.ExecuteType.NonQuery).ResultScalar;  //ToString();

        string[] str = minMax.Split(' ');
        string   min = str[0];
        string   max = str[1];

        //Response.Write("<script>alert('" + GridView1.Rows.Count() + "');</script>");
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            string[] sales       = GridView1.Rows[i].Cells[6].Text.Split('.');
            string   salesIntger = sales[0];
            if (salesIntger == min && minFlag == false)
            {
                GridView1.Rows[i].Cells[6].BackColor = System.Drawing.Color.Red;
                minFlag = true;
            }
            if (salesIntger == max && maxFlag == false)
            {
                GridView1.Rows[i].Cells[6].BackColor = System.Drawing.Color.Green;
                maxFlag = true;
            }
            if (minFlag == true && maxFlag == true)
            {
                break;
            }
        }
    }
Example #9
0
        // GET api/values/5
        public string Get(int id)
        {
            var dataAccess = new DataAcces();

            var product = dataAccess.GetProductById(1);

            return(product.Name);
        }
Example #10
0
        private void New_Click(object sender, EventArgs e)
        {
            DataAcces.GetData();
            KIzunaAI.Decide();
            DataEditor editor = new DataEditor();

            editor.Show();
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedLocation = (sender as ComboBox).SelectedItem as string;

            images = DataAcces.GetImages(locations.Find(x => x.Localitate == selectedLocation).Id);

            comboBox2.Items.Clear();
            comboBox2.Items.AddRange(images.ToArray());
        }
        public async static Task OperationsCSV()
        {
            try
            {
                Console.WriteLine("Se esta leyendo el archivo CSV");
                string fileUri = Constants.urlCSV;

                using (var context = new DataAcces())
                {
                    await context.TruncateAsync <Importer>(typeof(Importer), default);
                }

                List <Importer> importers = new List <Importer>();

                WebClient    client     = new WebClient();
                Stream       stream     = client.OpenRead(fileUri);
                StreamReader readerFile = new StreamReader(stream);

                var config = new CsvConfiguration(CultureInfo.CurrentCulture)
                {
                    Delimiter = ";",
                };
                using (var memory = new MemoryStream())
                    using (var reader = readerFile)
                        using (var csv = new CsvReader(reader, config))
                        {
                            memory.Position = 0;
                            csv.Context.RegisterClassMap <ImporterMapper>();
                            await csv.ReadAsync();

                            csv.ReadHeader();
                            int flag = 0;
                            while (await csv.ReadAsync())
                            {
                                flag++;
                                var importer = csv.GetRecord <Importer>();
                                importers.Add(importer);
                                if (flag == 1000)
                                {
                                    await Insert(importers);

                                    importers = new List <Importer>();
                                    flag      = 0;
                                }
                            }
                            if (flag > 0)
                            {
                                Console.WriteLine("Se han insertado los datos en la BD", "/n", "Numero de registros insertados {importe}");
                            }
                        }
            }
            catch (Exception ex)
            {
                var sss = ex.Message;
                throw;
            }
        }
Example #13
0
        public VeiwAllEmployee()
        {
            InitializeComponent();

            DataAcces da = new DataAcces();

            System.Data.DataTable dt = da.VeiwAllEmployees();
            datagridView.ItemsSource = dt.DefaultView;
        }
        public VeiwAllCategory()
        {
            InitializeComponent();

            DataAcces da = new DataAcces();

            DataTable dt = da.VewAllCategory();

            datagridView.ItemsSource = dt.DefaultView;
        }
Example #15
0
        // Récupère en base de donnée les résultats et les affiches dans le view résultat
        public ActionResult PageResultat(int idSondage)
        {
            ClassResultat Sondage = DataAcces.RecupererResultatEnBdd(idSondage);

            Sondage.PoucentageChoix1 = ClassResultat.PourcentageVote(Sondage.ResultatChoix1, Sondage.NombreDevotant);
            Sondage.PoucentageChoix2 = ClassResultat.PourcentageVote(Sondage.ResultatChoix2, Sondage.NombreDevotant);
            Sondage.PoucentageChoix3 = ClassResultat.PourcentageVote(Sondage.ResultatChoix3, Sondage.NombreDevotant);
            Sondage.PoucentageChoix4 = ClassResultat.PourcentageVote(Sondage.ResultatChoix4, Sondage.NombreDevotant);
            return(View(Sondage));
        }
Example #16
0
        // Récupère les choix du votant lorsque le sondage est à choix multiple
        public ActionResult RecuperationVoteChoixMultiple(int idSondage, string ResultatChoix1, string ResultatChoix2, string ResultatChoix3, string ResultatChoix4, int numeroSecurite)
        {
            if (TestSondagevote(Request.Cookies, idSondage))
            {
                return(RedirectToAction("PageDejaVoter", new { IdSondage = idSondage, NumeroSecurite = numeroSecurite }));
            }

            DataAcces.InsererResultatEnBDD(idSondage, ClassResultat.ValeurDuCHoix(ResultatChoix1), ClassResultat.ValeurDuCHoix(ResultatChoix2), ClassResultat.ValeurDuCHoix(ResultatChoix3), ClassResultat.ValeurDuCHoix(ResultatChoix4));
            SauvegardeDesCookie(idSondage);
            return(RedirectToAction("PageResultat", new { IdSondage = idSondage }));
        }
Example #17
0
        public ActionResult SondageLiensDeGestion(int id, string Clef)
        {
            ClasseSondage classeSondage = DataAcces.RecupererSondageEnBDD(id);

            if (classeSondage.ClefDeSupression == Clef)
            {
                return(View(classeSondage));
            }

            return(View());
        }
        public GenereazaPostare(string connectionString)
        {
            InitializeComponent();
            MaximizeBox = false;
            MinimizeBox = false;

            this.connectionString = connectionString;

            locations = DataAcces.GetLocations();
            comboBox1.Items.AddRange(locations.Select(x => x.Localitate).ToArray());
        }
Example #19
0
        public ActionResult EnregistrerVote(List <string> Idliste, int IDsondageCourant)
        {
            //DataAcces.InsertionResultaDuVote();
            List <string> liste = FonctionUtiles.GetlisteDeReponses(Idliste);

            DataAcces.InsertionResultatDuVote(IDsondageCourant, liste);

            Response.Cookies.Add(FonctionUtiles.CreationCookiesUtilisateur(IDsondageCourant));

            return(RedirectToAction("Resultat", new { idsondageCourant = IDsondageCourant }));
        }
Example #20
0
        public async Task SearchPeople()
        {
            var items = await DataAcces.GetPeople();

            foreach (var item in items)
            {
                People.Add(item);
            }

            Console.WriteLine("Done conversion");
        }
Example #21
0
        public ActionResult Suppression(int id, string Clef)
        {
            ClasseSondage classeSondage = DataAcces.RecupererSondageEnBDD(id);

            if (classeSondage.ClefDeSupression == Clef)
            {
                DataAcces.DesactivationSondage(id);
                return(RedirectToAction("VoteDesactiver", new { idsondageCourant = id }));
            }

            return(View());
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DataAcces.SaveData(connectionString, filePath);
         MessageBox.Show("Baza de date initializata cu succes!");
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Eroare initializare");
     }
 }
Example #23
0
        // Enregiste sondage en base de donnée lorsqu'il est crée
        public ActionResult CreationSondage(string Question, string Choix1, string Choix2, string Choix3, string Choix4, bool?ChoixMultiplePeutEtreNull)
        {
            bool         choixMultiple = ChoixMultiplePeutEtreNull.GetValueOrDefault(false);
            Random       aleatoire     = new Random();
            int          cleSecurite   = aleatoire.Next(1000, 100000);
            ClassSondage sondage       = new ClassSondage(0, Question, Choix1, Choix2, Choix3, Choix4, choixMultiple, false, cleSecurite);

            int idSondageCree = DataAcces.InsererEnBDD(sondage);


            return(RedirectToAction("PageChoix", new { idSondage = idSondageCree }));
        }
Example #24
0
        private async Task Search_Action()
        {
            people = await DataAcces.GetPeople() as List <PersonModel>;

            //people = db.GetPeople();

            foreach (PersonModel person in people)
            {
                PersonView personView = new PersonView(parent, person);
                //peopleView.Add(personView);
            }
        }
Example #25
0
        public async Task <IActionResult> OnPostAsync()
        {
            Delivery delivery;
            Payment  payment;

            if (Delivery == "delivery1")
            {
                delivery = Models.Delivery.Fast;
            }
            else if (Delivery == "delivery2")
            {
                delivery = Models.Delivery.Cheap;
            }
            else
            {
                delivery = Models.Delivery.Free;
            }

            if (Payment == "payment1")
            {
                payment = Models.Payment.Card;
            }
            else
            {
                payment = Models.Payment.Paypal;
            }

            ApplicationUser = await UserManager.GetUserAsync(User);

            ShoppingCart shoppingCart = new ShoppingCart(ApplicationUser.GetItems(), DataAcces);
            Order        order        = new Order(
                ApplicationUser.Id,
                shoppingCart,
                delivery,
                payment,
                ApplicationUser.UserName,
                ApplicationUser.Email,
                ApplicationUser.PhoneNumber,
                ApplicationUser.FirstName,
                ApplicationUser.SecondName,
                ApplicationUser.AddressStreet,
                ApplicationUser.AddressHouseNumber,
                ApplicationUser.AddressCity,
                ApplicationUser.AddressCountry,
                ApplicationUser.AddressZip);

            ApplicationUser.Items = "";
            await UserManager.UpdateAsync(ApplicationUser);

            DataAcces.AddOrder(order);
            return(RedirectToPage("OrderSummary"));
        }
Example #26
0
 public IActionResult OnGet(int id)
 {
     Order = DataAcces.GetOrder(id);
     if (Order == null)
     {
         return(NotFound());
     }
     else
     {
         ShoppingCart = new ShoppingCart(Order.Items.Split(";").ToList(), DataAcces);
         return(Page());
     }
 }
Example #27
0
        // Page ou on vote avec vérification si vote pas désactivé
        public ActionResult PageVoter(int idSondage, int numeroSecurite)
        {
            ClassSondage sondage = DataAcces.RecupererSondagePourDesactiver(idSondage, numeroSecurite);

            if (sondage.EtatDuSondage == false)
            {
                return(View(DataAcces.RecupererSondagePourDesactiver(idSondage, numeroSecurite)));
            }
            else
            {
                return(RedirectToAction("PageDejaSupprimer", new { IdSondage = idSondage, NumeroSecurite = numeroSecurite }));
            }
        }
Example #28
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            string    producto = textBox1.Text;
            DataAcces acceso   = new DataAcces();

            if (CodigoRB.Checked == true)
            {
                acceso.searchProductById(producto, dataGridView1);
            }
            else if (ProductoRB.Checked == true)
            {
                acceso.searchProductByName(producto, dataGridView1);
            }
        }
Example #29
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            DataAcces dataAcces = new DataAcces();
            string    buscar    = buscarTxt.Text;

            if (radioButton1.Checked == true)
            {
                dataAcces.searchProductById(buscar, dataGridView1);
            }
            else
            {
                dataAcces.searchProductByName(buscar, dataGridView1);
            }
        }
Example #30
0
    private void SortGridView(string sortExpression, string direction)
    {
        SearchResTbl = null;
        SearchResTbl = new DataAcces("sp_topProducts", CommandType.StoredProcedure, null, Enums.ExecuteType.DataTable).ResultDataTable;

        DataView dv = new DataView(SearchResTbl);

        dv.Sort = sortExpression + direction;

        GridView1.DataSource = dv;
        GridView1.DataBind();
        getDropList();
        colorMaxAndMin();
    }
Example #31
0
        static void Main(string[] args)
        {
            Postcode postal = new Postcode(1, 2620, "Hemiksem");
            DataAcces da = new DataAcces("postal");

            List<object> pcs = new List<object>();
            pcs.Add(postal);
            pcs.Add(postal);
            pcs.Add(postal);

            da.AddAll(pcs);

            Console.Read();

        }