Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Partners p = new Partners();

            if (lbladdbewerken.Text == "Change")
            {
                p.mpartner_id = Convert.ToInt32(txtpartnerid.Text);
                p.mname       = txtname.Text;
                p.mstreet     = txtstreet.Text;
                p.mcity_id    = (int)cmbcity.SelectedValue;
                p.memail      = txtemail.Text;
                p.mcallname   = txtcallname.Text;
                partnersDB.updatepartner(p);
                btnSave.Visible     = false;
                lbladdbewerken.Text = "";
            }
            else
            {
                p.mpartner_id = Convert.ToInt32(txtpartnerid.Text);
                p.mname       = txtname.Text;
                p.mstreet     = txtstreet.Text;
                p.mcity_id    = (int)cmbcity.SelectedValue;
                p.memail      = txtemail.Text;
                p.mcallname   = txtcallname.Text;
                partnersDB.Addpartner(p);
                btnSave.Visible     = false;
                lbladdbewerken.Text = "";
                txtpartnerid.Text   = partnersDB.countpartner().ToString();
            }
        }
Exemple #2
0
        public void email_send()
        {
            string body = "Papa" + Environment.NewLine +
                          Environment.NewLine +
                          "Hier is de rekening voor " + txtname.Text + ". Hier zijn de gegevens:" + Environment.NewLine +
                          "Bedrag :" + txtTotal.Text.ToString() + " EUR" + Environment.NewLine +
                          "Rekening: BE91 7350 0468 4276" + Environment.NewLine +
                          Environment.NewLine +
                          "Met vriendelijke groeten" + Environment.NewLine +
                          Environment.NewLine +
                          "Kris Coenen";
            MailMessage mail       = new MailMessage();
            SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress("*****@*****.**");
            Partners p = partnersDB.getpartner(cmbpartner.SelectedIndex);

            mail.To.Add("*****@*****.**");
            mail.Subject = "rekening " + txtname.Text;
            mail.Body    = body;

            System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment(bestand);
            mail.Attachments.Add(attachment);

            SmtpServer.Port        = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "zgtlzvbccmxnsytg");
            SmtpServer.EnableSsl   = true;

            SmtpServer.Send(mail);
        }
Exemple #3
0
        public static void updatepartner(Partners p)
        {
            NpgsqlConnection connection      = accountDB.GetConnection();
            string           updateStatement =
                "UPDATE partners SET " +
                "name = '" + p.mname + "', " +
                "street = '" + p.mstreet + "', " +
                "city_id = '" + p.mcity_id + "', " +
                "email = '" + p.memail + "', " +
                "callname = '" + p.mcallname + "'" +
                " WHERE partner_id = " + p.mpartner_id + ";";
            NpgsqlCommand updateCommand = new NpgsqlCommand(updateStatement, connection);

            try
            {
                connection.Open();
                updateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #4
0
        public static int Addpartner(Partners p)
        {
            NpgsqlConnection connection      = accountDB.GetConnection();
            string           insertStatement =
                "INSERT into partners " +
                "(name,street,city_id,email,callname) " +
                "VALUES ('" + p.mname + "'," + "'" + p.mstreet + "'," + "'" + p.mcity_id + "'," + "'" + p.memail + "'," + "'" + p.mcallname + "') returning partner_id";

            NpgsqlCommand insertCommand = new NpgsqlCommand(insertStatement, connection);

            try
            {
                connection.Open();
                int leerlingID = Convert.ToInt32(insertCommand.ExecuteScalar());
                return(leerlingID);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #5
0
        private void txtpartnerid_TextChanged(object sender, EventArgs e)
        {
            int      id = Convert.ToInt32(txtpartnerid.Text);
            Partners p  = partnersDB.getpartner(id);

            txtname.Text = p.mname;
            Citys c = citysDB.getcity(p.mcity_id);

            LoadComboBoxes();
            cmbcity.SelectedValue = c.mcity_id;
            txtstreet.Text        = p.mstreet;
            txtemail.Text         = p.memail;
            txtcallname.Text      = p.mcallname;
        }
Exemple #6
0
        public static Partners getpartner(int partner_id)
        {
            Partners         p               = new Partners();
            NpgsqlConnection connection      = accountDB.GetConnection();
            string           selectStatement =
                "SELECT *" +
                "FROM partners " +
                "WHERE partner_id = @partner_id";
            NpgsqlCommand selectCommand = new NpgsqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@partner_id", partner_id);
            try
            {
                connection.Open();
                NpgsqlDataReader reader = selectCommand.ExecuteReader();
                if (reader.Read())
                {
                    p.mpartner_id = (int)reader["partner_id"];
                    p.mcity_id    = (int)reader["city_id"];
                    p.mname       = reader["name"].ToString();
                    p.mstreet     = reader["street"].ToString();
                    p.memail      = reader["email"].ToString();
                    p.mcallname   = reader["callname"].ToString();
                }
                else
                {
                    p = null;
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(p);
        }
Exemple #7
0
        public static List <Partners> GetpartnerList()
        {
            List <Partners>  partnerlist     = new List <Partners>();
            NpgsqlConnection connection      = accountDB.GetConnection();
            string           selectStatement =
                "SELECT * " +
                "FROM partners ";
            NpgsqlCommand selectCommand = new NpgsqlCommand(selectStatement, connection);

            try
            {
                connection.Open();
                NpgsqlDataReader reader = selectCommand.ExecuteReader();
                while (reader.Read())
                {
                    Partners p = new Partners();
                    p.mpartner_id = (int)reader["partner_id"];
                    p.mname       = reader["name"].ToString();
                    p.mstreet     = reader["street"].ToString();
                    p.mcity_id    = (int)reader["city_id"];
                    p.memail      = reader["email"].ToString();
                    p.mcallname   = reader["callname"].ToString();
                    partnerlist.Add(p);
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(partnerlist);
        }