//Fonksiyonlar
 #region
 public void FormDoldur(CariUnvan_Firma firma)
 {
     textBoxAdres.Text        = firma.CariUnvan_FirmaAdres;
     textBoxEmail.Text        = firma.CariUnvan_FirmaEmail;
     textBoxFirmaAd.Text      = firma.CariUnvan_FirmaAd;
     textBoxMersisNo.Text     = firma.CariUnvan_FirmaMarsisNo;
     textBoxTelefon.Text      = firma.CariUnvan_FirmaTelefon;
     textBoxVergiDairesi.Text = firma.CariUnvan_FirmaVergiDairesi;
     textBoxVergiNo.Text      = firma.CariUnvan_FirmaVergiNo;
     textBoxIl.Text           = firma.Il;
     textBoxIlce.Text         = firma.Ilce;
     if (firma.CariUnvan_FirmaTip == 0)
     {
         textBoxTC.Enabled             = true;
         textBoxAdSoyad.Enabled        = true;
         textBoxSoyad.Enabled          = true;
         ıconPictureBoxSahis.IconChar  = FontAwesome.Sharp.IconChar.CheckSquare;
         ıconPictureBoxSahis.IconColor = System.Drawing.Color.DarkGreen;
         textBoxAdSoyad.Text           = firma.CariUnvan_SahisAd;
         textBoxSoyad.Text             = firma.CariUnvan_SahisSoyad;
         textBoxTC.Text = firma.CariUnvan_FirmaTC;
     }
     else
     {
         textBoxTC.Enabled             = false;
         textBoxAdSoyad.Enabled        = false;
         textBoxSoyad.Enabled          = false;
         ıconPictureBoxSahis.IconChar  = FontAwesome.Sharp.IconChar.Square;
         ıconPictureBoxSahis.IconColor = System.Drawing.SystemColors.ControlText;
         textBoxAdSoyad.Text           = null;
         textBoxSoyad.Text             = null;
         textBoxTC.Text = null;
     }
 }
        //Eventler
        #region
        private void BtnKaydet_Click(object sender, EventArgs e)
        {
            if (textBoxVergiNo.Text == "")
            {
                mesaj.Mesaj("Vergi No Boş Geçilemez ", FontAwesome.Sharp.IconChar.ExclamationTriangle, System.Drawing.Color.Yellow);
                return;
            }
            else if (ıconPictureBoxSahis.IconChar == FontAwesome.Sharp.IconChar.CheckSquare && textBoxTC.Text == "")
            {
                mesaj.Mesaj("TC Boş Geçilemez ", FontAwesome.Sharp.IconChar.ExclamationTriangle, System.Drawing.Color.Yellow);
                return;
            }
            else
            {
                CariUnvan_Firma firma = null;
                if (comboBoxFirma.Enabled == true)
                {
                    firma = db.CariUnvan_Firma.FirstOrDefault(c => c.CariUnvan_FirmaVergiNo == textBoxVergiNo.Text);
                }
                else
                {
                    firma = db.CariUnvan_Firma.FirstOrDefault(c => c.CariUnvan_FirmaVergiNo == textBoxVergiNo.Text);
                    if (firma != null)
                    {
                        mesaj.Mesaj("Böyle Bir Firma Zaten '" + firma.CariUnvan_FirmaAd + "'Olarak Kayıtlı Aktif Ediniz", FontAwesome.Sharp.IconChar.ExclamationTriangle, System.Drawing.Color.Yellow);
                        return;
                    }
                }

                if (firma == null)
                {
                    try
                    {
                        CariUnvan_Firma instance = new CariUnvan_Firma();
                        instance.CariUnvan_FirmaAd           = Validate(textBoxFirmaAd.Text);
                        instance.CariUnvan_FirmaAdres        = Validate(textBoxAdres.Text);
                        instance.CariUnvan_FirmaEmail        = Validate(textBoxEmail.Text);
                        instance.CariUnvan_FirmaMarsisNo     = Validate(textBoxMersisNo.Text);
                        instance.CariUnvan_FirmaTelefon      = Validate(textBoxTelefon.Text);
                        instance.CariUnvan_FirmaVergiDairesi = Validate(textBoxVergiDairesi.Text);
                        instance.CariUnvan_FirmaVergiNo      = Validate(textBoxVergiNo.Text);
                        instance.Il   = Validate(textBoxIl.Text);
                        instance.Ilce = Validate(textBoxIlce.Text);
                        if (ıconPictureBoxSahis.IconChar != FontAwesome.Sharp.IconChar.Square)
                        {
                            instance.CariUnvan_FirmaTC      = Validate(textBoxTC.Text);
                            instance.CariUnvan_SahisAdSoyad = Validate(textBoxAdSoyad.Text) + " " + Validate(textBoxSoyad.Text);
                            instance.CariUnvan_SahisAd      = Validate(textBoxAdSoyad.Text);
                            instance.CariUnvan_SahisSoyad   = Validate(textBoxSoyad.Text);
                            instance.CariUnvan_FirmaAd      = Validate(textBoxAdSoyad.Text) + " " + Validate(textBoxSoyad.Text);
                            instance.CariUnvan_FirmaTip     = 0;
                        }
                        else
                        {
                            instance.CariUnvan_FirmaTip = 1;

                            instance.CariUnvan_FirmaTC      = null;
                            instance.CariUnvan_SahisAdSoyad = null;
                            instance.CariUnvan_SahisAd      = null;
                            instance.CariUnvan_SahisSoyad   = null;
                        }
                        instance.Arsiv = false;
                        db.CariUnvan_Firma.Add(instance);
                        db.SaveChanges();
                        Global.sonfirma = instance;
                        if (mesaj.Mesaj("İşlem Başarılı", FontAwesome.Sharp.IconChar.Check, System.Drawing.Color.DarkGreen))
                        {
                            FormTemizle();
                        }
                    }
                    catch (Exception ex)
                    {
                        mesaj.Mesaj(ex.Message, FontAwesome.Sharp.IconChar.Times, System.Drawing.Color.DarkRed);
                    }
                }
                else
                {
                    firma.CariUnvan_FirmaAd           = Validate(textBoxFirmaAd.Text);
                    firma.CariUnvan_FirmaAdres        = Validate(textBoxAdres.Text);
                    firma.CariUnvan_FirmaEmail        = Validate(textBoxEmail.Text);
                    firma.CariUnvan_FirmaMarsisNo     = Validate(textBoxMersisNo.Text);
                    firma.CariUnvan_FirmaTelefon      = Validate(textBoxTelefon.Text);
                    firma.CariUnvan_FirmaVergiDairesi = Validate(textBoxVergiDairesi.Text);
                    firma.CariUnvan_FirmaVergiNo      = Validate(textBoxVergiNo.Text);
                    firma.Il   = Validate(textBoxIl.Text);
                    firma.Ilce = Validate(textBoxIlce.Text);
                    if (ıconPictureBoxSahis.IconChar != FontAwesome.Sharp.IconChar.Square)
                    {
                        firma.CariUnvan_FirmaTC      = Validate(textBoxTC.Text);
                        firma.CariUnvan_SahisAdSoyad = Validate(textBoxAdSoyad.Text) + " " + Validate(textBoxSoyad.Text);
                        firma.CariUnvan_SahisAd      = Validate(textBoxAdSoyad.Text);
                        firma.CariUnvan_SahisSoyad   = Validate(textBoxSoyad.Text);
                        firma.CariUnvan_FirmaAd      = Validate(textBoxAdSoyad.Text) + " " + Validate(textBoxSoyad.Text);
                        firma.CariUnvan_FirmaTip     = 0;
                    }
                    else
                    {
                        firma.CariUnvan_FirmaTip     = 1;
                        firma.CariUnvan_FirmaTC      = null;
                        firma.CariUnvan_SahisAdSoyad = null;
                        firma.CariUnvan_SahisAd      = null;
                        firma.CariUnvan_SahisSoyad   = null;
                    }

                    firma.Arsiv           = false;
                    db.Entry(firma).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    Global.sonfirma = firma;
                    if (mesaj.Mesaj("İşlem Başarılı", FontAwesome.Sharp.IconChar.Check, System.Drawing.Color.DarkGreen))
                    {
                        FormTemizle();
                        comboBoxFirma.Enabled = false;
                        BtnSil.Enabled        = false;
                    }
                }
                ComboboxGuncelle();
                comboBoxFirma.Enabled            = false;
                BtnSil.Enabled                   = false;
                ıconPictureBoxGuncelle.IconChar  = FontAwesome.Sharp.IconChar.Square;
                ıconPictureBoxGuncelle.IconColor = System.Drawing.SystemColors.ControlText;
                FormTemizle();
            }
        }