using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PerfektiveEntegrasyonWindowsForms.PerfektiveWebServis;

namespace PerfektiveEntegrasyonWindowsForms
{
    public partial class PerfektiveIntegrationForm : Form
    {
        public PerfektiveIntegrationForm()
        {
            InitializeComponent();
        }

        private void PerfektiveIntegrationForm_Load(object sender, EventArgs e)
        {

        }

        private void btnHazirVerilerdenGonder_Click(object sender, EventArgs e)
        {
            String endPoint = txtSoapURI.Text;
            String username = txtUsername.Text;
            String password = txtPassword.Text;

            WebServisSiniflari webServisSiniflari = new WebServisSiniflari(endPoint, username, password);

            try
            {
                EntegrasyonResponseType entegrasyonResponseType = webServisSiniflari.sonuclar();

                SonuclariGoster(entegrasyonResponseType);
            }
            catch (Exception ex)
            {
                lblUyarilar.ForeColor = Color.Red;
                lblUyarilar.Text = ex.Message;
            }
        }
   
        private void SonuclariGoster(EntegrasyonResponseType entegrasyonResponseType)
        {
            lblGuncellenenKayit.Text = entegrasyonResponseType.Sonuclar[0].GuncellenenKayitSayisi;
            lblEklenenKayitSayisi.Text = entegrasyonResponseType.Sonuclar[0].YeniKaydedilenKayitSayisi;
            String[] uyarilar = entegrasyonResponseType.Uyarilar;
            lblUyarilar.Text = "İşlem başarıyla gerçekleşti";
            lblUyarilar.ForeColor = Color.Green;
            if (uyarilar != null)
            {
                String tumUyarilar = "";
                foreach (var uyari in uyarilar)
                {
                    tumUyarilar += uyari + "\n\r";
                }
                lblUyarilar.Text = tumUyarilar;
                lblUyarilar.ForeColor = Color.Red;
            }

        }

    }
}
