Beispiel #1
0
        private void Connecter_Click(object sender, EventArgs e)
        {
            SqlDataReader sdr = DatabaseOperations.LoginIsCorrect(Tb_login.Text, Tb_mdp.Text);

            if (sdr.Read())
            {
                if (sdr[0].ToString() == "admin")
                {
                    string Nom = sdr[1].ToString(), Prenom = sdr[2].ToString();
                    sdr.Close();
                    MainAdmin mainAdmin = new MainAdmin(Nom, Prenom);
                    mainAdmin.Show();
                    Hide();
                }
                else
                {
                    if (sdr[0].ToString() == "agent")
                    {
                        string Nom = sdr[1].ToString(), Prenom = sdr[2].ToString();
                        sdr.Close();
                        MainAgent mainAgent = new MainAgent(Nom, Prenom);
                        mainAgent.Show();
                        Hide();
                    }
                    else
                    {
                        if (sdr[0].ToString() == "caissier")
                        {
                            string Nom = sdr[1].ToString(), Prenom = sdr[2].ToString();
                            sdr.Close();
                            MainCaissier mainCaissier = new MainCaissier(Nom, Prenom);
                            mainCaissier.Show();
                            Hide();
                        }
                        else
                        {
                            MessageBox.Show("Votre Login est inccorect");
                            sdr.Close();
                        }
                    }
                }
            }


            DatabaseOperations.closeCon();
        }
        internal void ajouterCommande_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                TB_total.Enabled = false;

                TB_facture_N.Text = "F2019-" + DatabaseOperations.maxId();
                display_data();
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select reference from produit";
                cmd.ExecuteNonQuery();
                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                foreach (DataRow dr in dt.Rows)
                {
                    CB_reference.Items.Add(dr["reference"].ToString());
                }
                connection.Close();
            }
        }