Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to deploy your software (set up) Pin
Richard MacCutchan17-Apr-18 8:45
mveRichard MacCutchan17-Apr-18 8:45 
GeneralRe: how to deploy your software (set up) Pin
ago248617-Apr-18 22:35
ago248617-Apr-18 22:35 
GeneralRe: how to deploy your software (set up) Pin
Richard MacCutchan17-Apr-18 22:38
mveRichard MacCutchan17-Apr-18 22:38 
GeneralRe: how to deploy your software (set up) Pin
ago248617-Apr-18 22:57
ago248617-Apr-18 22:57 
GeneralRe: how to deploy your software (set up) Pin
ago248617-Apr-18 23:48
ago248617-Apr-18 23:48 
GeneralRe: how to deploy your software (set up) Pin
Richard MacCutchan17-Apr-18 23:56
mveRichard MacCutchan17-Apr-18 23:56 
GeneralRe: how to deploy your software (set up) Pin
ago248618-Apr-18 0:00
ago248618-Apr-18 0:00 
GeneralRe: how to deploy your software (set up) Pin
ago248618-Apr-18 0:01
ago248618-Apr-18 0:01 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SQLite;

namespace Acode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
           
        }
        private SQLiteConnection sql_con;
	    private SQLiteCommand sql_cmd;
        private SQLiteDataAdapter DB;
	    private DataSet DS = new DataSet();
	    private DataTable DT = new DataTable();

        private void setConnection()
	    {
            //CONNEXION A LA BASE DE DONNEE
	    sql_con = new SQLiteConnection(@"Data Source=DBcode.db; Version=3;New=;Compress=True;");
	    }

        private void LoadData()
        {
            setConnection();
            sql_con.Open();
            sql_cmd = sql_con.CreateCommand();
            string CommandText = "select * from InfoCode";
            DB = new SQLiteDataAdapter(CommandText, sql_con);
            DS.Reset();
            DB.Fill(DS);
            DT = DS.Tables[0];
            dataGridView1.DataSource = DT;
            sql_con.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadData();

        }

        private void ExecuteQuery(String txtQuery)
	    {
        setConnection();
	    sql_con.Open();
	    sql_cmd = sql_con.CreateCommand();
	    sql_cmd.CommandText = txtQuery;
	    sql_cmd.ExecuteNonQuery();
	    sql_con.Close();
	    }

        public static string randomstring(int length)
        {
            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWYZ0123456789";
            Random random = new Random();
            return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
        }
        private void btnGenerer_Click(object sender, EventArgs e)
        {
           
            lblAffichage.Text = randomstring(4);
            txtAffichPrix.Text = "100";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            lblAffichage.Text = randomstring(5);
            txtAffichPrix.Text = "300";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            lblAffichage.Text = randomstring(6);
            txtAffichPrix.Text = "500";
        }

       
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            if (lblAffichage.Text == "")
            {
                MessageBox.Show("Merci de bien vouloir générer le code");
            }
            else
            {
                using (SQLiteConnection con = new SQLiteConnection(sql_con))
                {
                    try
                    {
                        con.Open();
                        // Insert code to process data.
                        using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO InfoCode (Code, DateCode, PrixCode) VALUES (@Code, @DateCode, @PrixCode)", con))
                        {
                            cmd.Parameters.AddWithValue("@Code", lblAffichage.Text);
                            cmd.Parameters.AddWithValue("@DateCode", dateTimePicker1.Text);
                            cmd.Parameters.AddWithValue("@PrixCode", txtAffichPrix.Text);
                            cmd.ExecuteNonQuery();
                        }
                        LoadData();
                        MessageBox.Show("Enregistrement effectué avec succès");
                        lblAffichage.Text = "";
                        groupBoxGenerer.Enabled = false;
                        btnEnregistrer.Enabled = false;
                        btnImprimer.Enabled = true;
                        this.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Échec de la connexion à la source de données" + ex.Message);
                    }
                    finally
                    {
                        con.Close();
                    }
                    
                    
                }
            }
        }

        private void btnAjouter_Click(object sender, EventArgs e)
        {
            groupBoxGenerer.Enabled = true;
            btnEnregistrer.Enabled = true;
        }

        private void quitterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            FrmAuthentification retour = new FrmAuthentification();
            retour.Show();
        }

        private void codeVenduToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmCodeVendu ventcode = new FrmCodeVendu();
            ventcode.Show();
            this.Hide();
    
        }

        private void pointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmPointJournalier pointQ = new FrmPointJournalier();
            pointQ.Show();
            this.Hide();
        }

        private void btnImprimer_Click(object sender, EventArgs e)
        {
            FrmImprimer imprmer = new FrmImprimer();
            imprmer.Show();
            this.Hide();
        }

        private void imprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmImprimer imprmer = new FrmImprimer();
            imprmer.Show();
            this.Hide();
        }
    }
}

GeneralRe: how to deploy your software (set up) Pin
Richard MacCutchan18-Apr-18 0:13
mveRichard MacCutchan18-Apr-18 0:13 
GeneralRe: how to deploy your software (set up) Pin
ago248618-Apr-18 0:16
ago248618-Apr-18 0:16 
AnswerRe: how to deploy your software (set up) Pin
Gerry Schmitz18-Apr-18 6:24
mveGerry Schmitz18-Apr-18 6:24 
GeneralRe: how to deploy your software (set up) Pin
ago248618-Apr-18 6:52
ago248618-Apr-18 6:52 
GeneralRe: how to deploy your software (set up) Pin
Gerry Schmitz18-Apr-18 9:07
mveGerry Schmitz18-Apr-18 9:07 
GeneralRe: how to deploy your software (set up) Pin
ago248619-Apr-18 21:48
ago248619-Apr-18 21:48 
GeneralRe: how to deploy your software (set up) Pin
Gerry Schmitz20-Apr-18 6:22
mveGerry Schmitz20-Apr-18 6:22 
GeneralRe: how to deploy your software (set up) Pin
ago248620-Apr-18 6:30
ago248620-Apr-18 6:30 
Questionconsolidating four similar classes Pin
Alexander Kindel16-Apr-18 15:23
Alexander Kindel16-Apr-18 15:23 
AnswerRe: consolidating four similar classes Pin
#realJSOP17-Apr-18 2:24
mve#realJSOP17-Apr-18 2:24 
GeneralRe: consolidating four similar classes Pin
Alexander Kindel17-Apr-18 11:34
Alexander Kindel17-Apr-18 11:34 
GeneralRe: consolidating four similar classes Pin
#realJSOP17-Apr-18 12:33
mve#realJSOP17-Apr-18 12:33 
GeneralRe: consolidating four similar classes Pin
Alexander Kindel17-Apr-18 16:53
Alexander Kindel17-Apr-18 16:53 
GeneralRe: consolidating four similar classes Pin
#realJSOP19-Apr-18 2:50
mve#realJSOP19-Apr-18 2:50 
AnswerRe: consolidating four similar classes Pin
Gerry Schmitz18-Apr-18 7:05
mveGerry Schmitz18-Apr-18 7:05 
GeneralRe: consolidating four similar classes Pin
Alexander Kindel18-Apr-18 12:11
Alexander Kindel18-Apr-18 12:11 
GeneralRe: consolidating four similar classes Pin
Gerry Schmitz19-Apr-18 8:50
mveGerry Schmitz19-Apr-18 8:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.