Ejemplo n.º 1
0
        private void button_Satildi_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_SatisFiyati.Text == "")
                {
                    MessageBox.Show("Araç satış bedeli girilmedi!");
                }
                else if (Convert.ToInt32(textBox_AlisFiyati.Text) > Convert.ToInt32(textBox_SatisFiyati.Text))
                {
                    int    hesapla = Convert.ToInt32(textBox_AlisFiyati.Text) - Convert.ToInt32(textBox_SatisFiyati.Text);
                    string insert  = "update  tbl_Arac set Zarar='" + hesapla + "', Kar='" + 0 + "' where Id = '" + textBox_id.Text + "'";
                    SqlConn.Islemler(insert);

                    string updatesatis = "update tbl_Arac set Satis_Durumu = 1, Satis_Fiyati ='" + textBox_SatisFiyati.Text + "',Satis_Tarihi = '" + dateTime_SatisTarihi.Text + "' where Id = '" + textBox_id.Text + "'";
                    SqlConn.Islemler(updatesatis);
                    MessageBox.Show("Araç satıldı olarak işaretlendi.");
                }
                else if (Convert.ToInt32(textBox_AlisFiyati.Text) < Convert.ToInt32(textBox_SatisFiyati.Text))
                {
                    int    hesapla = Convert.ToInt32(textBox_SatisFiyati.Text) - Convert.ToInt32(textBox_AlisFiyati.Text);
                    string insert  = "update  tbl_Arac set Kar='" + hesapla + "', Zarar='" + 0 + "' where Id = '" + textBox_id.Text + "'";
                    SqlConn.Islemler(insert);

                    string updatesatis = "update tbl_Arac set Satis_Durumu = 1, Satis_Fiyati ='" + textBox_SatisFiyati.Text + "',Satis_Tarihi = '" + dateTime_SatisTarihi.Text + "' where Id = '" + textBox_id.Text + "'";
                    SqlConn.Islemler(updatesatis);
                    MessageBox.Show("Araç satıldı olarak işaretlendi.");
                }
            }
            catch (Exception hata)
            {
                MessageBox.Show(hata.Message);
            }
        }
Ejemplo n.º 2
0
        private void btn_PersonelEkle_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_PersonelParola.Text == textBox_ParolaTekrar.Text)
                {
                    string cinsiyett = "";
                    string yetki     = "";
                    if (checkBox_Erkek.Checked == (true))
                    {
                        cinsiyett = "E";
                    }
                    else if (checkBox_Kadin.Checked == (true))
                    {
                        cinsiyett = "K";
                    }
                    if (checkBox_SatisDep.Checked == (true))
                    {
                        yetki = "SD";
                    }
                    else if (checkBox_AlisDep.Checked == (true))
                    {
                        yetki = "AD";
                    }
                    else if (checkBox_Yonetici.Checked == (true))
                    {
                        yetki = "Y";
                    }
                    if (textBox_Email.Text == "" || textBox_PersonelAd.Text == "" || textBox_PersonelParola.Text == "" || textBox_PersonelSoyad.Text == "" || textBox_TCKN.Text == "")
                    {
                        MessageBox.Show("Alanlar boş olamaz.");
                    }
                    else
                    {
                        string sql = "insert into tbl_Personel(Ad,Soyad,TCKN,Parola,Yetki,Cinsiyet,Email) values('" + textBox_PersonelAd.Text + "','" + textBox_PersonelSoyad.Text + "','" + textBox_TCKN.Text + "','" + textBox_PersonelParola.Text + "','" + yetki + "','" + cinsiyett + "','" + textBox_Email.Text + "')";
                        SqlConn.Islemler(sql);

                        SqlConnection con = new SqlConnection("Data Source=DESKTOP-7L6TOHU;Initial Catalog=OtokondriOtomasyon;Persist Security Info=True;User ID=sa;Password=123456789");
                        con.Open();
                        SqlDataAdapter        adapter = new SqlDataAdapter("Select * from tbl_Personel", con);
                        System.Data.DataTable dtable  = new System.Data.DataTable();
                        adapter.Fill(dtable);
                        dataGridView_PersonelSil.DataSource = dtable;
                        con.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Parolalar Uyuşmuyor!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Hata!");
            }
        }
Ejemplo n.º 3
0
        private void btn_Sil_Click(object sender, EventArgs e)
        {
            DialogResult sil = new DialogResult();

            sil = MessageBox.Show("Silmek istediğinizden emin misiniz ?", "Uyarı",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
            if (sil == DialogResult.Yes)
            {
                string    fotodosyasil = "select Fotograf_Uzanti from tbl_Fotograf where Arac_Id='" + textBox_id.Text + "'";
                DataTable dtbl         = SqlConn.goster(fotodosyasil);

                string hedef = Application.StartupPath + @"\photos\";

                for (int i = 0; i < SqlConn.goster(fotodosyasil).Rows.Count; i++)
                {
                    string uzanti = dtbl.Rows[i]["Fotograf_Uzanti"].ToString();
                    if (System.IO.File.Exists(@hedef + uzanti))
                    {
                        System.IO.File.Delete(@hedef + uzanti);
                    }
                }

                string deletefoto = "delete from tbl_Fotograf WHERE Arac_Id='" + textBox_id.Text + "'";
                SqlConn.Islemler(deletefoto);

                try
                {
                    string deletearac = "delete from tbl_Arac WHERE Id='" + textBox_id.Text + "'";
                    SqlConn.Islemler(deletearac);
                    MessageBox.Show("Araç silindi.");
                }
                catch (Exception)
                {
                    MessageBox.Show("Hata!!");
                }
            }
            else if (sil == DialogResult.No)
            {
                MessageBox.Show("iptal edildi.");
            }
        }
Ejemplo n.º 4
0
        private void button_Kaydet_Click(object sender, EventArgs e)
        {
            string    sorgu = "select Random from ParolaYenile where Personel_Id='" + id + "' and Durum = '" + 'A' + "'";
            DataTable tbl   = SqlConn.goster(sorgu);

            if (textBox_Random.Text == tbl.Rows[0]["Random"].ToString())
            {
                if (textBox_Parola.Text == textBox_ParolaTekrar.Text)
                {
                    //string sorguu = "select Durum from ParolaYenile where Personel_Id='"+id+"' and Durum = '"+'A'+"'";
                    //DataTable dtbl = SqlConn.goster(sorguu);

                    string guncelle = "Update tbl_Personel set  Parola='" + textBox_Parola.Text + "' where Id='" + id + "'";
                    try
                    {
                        SqlConn.Islemler(guncelle);
                        MessageBox.Show("Güncelleme Başarili.");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Hata!!");
                    }

                    string guncelleepsota = "update ParolaYenile set GuncellemeTarihi='" + DateTime.Now.ToShortDateString() + "',Durum ='" + "P" + "' where Personel_Id=" + id;
                    SqlConn.Islemler(guncelleepsota);

                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Şifreler Uyuşmuyor!!");
                }
            }
            else
            {
                MessageBox.Show("Parola yenileme kodu yanlış.");
            }
        }
Ejemplo n.º 5
0
 private void btn_Sil_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult cikis = new DialogResult();
         cikis = MessageBox.Show("Silmek istediğinizden emin misiniz ?", "Uyarı",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (cikis == DialogResult.Yes)
         {
             string a     = textBox_TCKN.Text;
             string komut = "delete from tbl_Personel WHERE TCKN='" + textBox_TCKN.Text + "'";
             SqlConn.Islemler(komut);
         }
         else if (cikis == DialogResult.No)
         {
             MessageBox.Show("iptal edildi.");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Hata!");
     }
 }
Ejemplo n.º 6
0
        private void btn_Guncelle_Click(object sender, EventArgs e)
        {
            try
            {
                string cinsiyett = "";
                string yetkii    = "";
                if (checkBox_Erkek.Checked == (true))
                {
                    cinsiyett = "E";
                }
                else if (checkBox_Kadin.Checked == (true))
                {
                    cinsiyett = "K";
                }

                if (checkBox_SatisDep.Checked == (true))
                {
                    yetkii = "SD";
                }
                else if (checkBox_AlisDep.Checked == (true))
                {
                    yetkii = "AD";
                }
                else if (checkBox_Yonetici.Checked == (true))
                {
                    yetkii = "Y";
                }

                string komut = " UPDATE tbl_Personel SET Ad = '" + textBox_PersonelAd.Text + "', Soyad ='" + textBox_PersonelSoyad.Text + "', TCKN = '" + textBox_TCKN.Text + "', Parola = '" + textBox_PersonelParola.Text + "',Yetki = '" + yetkii + "', Cinsiyet ='" + cinsiyett + "',Email='" + email + "'  WHERE Id = '" + id + "'";
                SqlConn.Islemler(komut);
                MessageBox.Show("Personel bilgileri güncellendi.");
            }
            catch (Exception)
            {
                MessageBox.Show("Hata");
            }
        }
Ejemplo n.º 7
0
        private void btn_SifremiUnuttumGonder_Click(object sender, EventArgs e)
        {
            Random        rastgele = new Random();
            StringBuilder sb       = new StringBuilder();

            for (int i = 0; i < 8; i++)
            {
                int ascii = rastgele.Next(32, 127);
                karakter = Convert.ToChar(ascii);
                sb.Append(karakter);
            }

            Random deneme  = new Random();
            string harfler = "ABCDEFGHIJKLMNOPRSTUVYZabcdefghijklmnoprstuvyz1234567890";
            string uret    = "";

            for (int i = 0; i < 6; i++)
            {
                uret += harfler[deneme.Next(harfler.Length)];
            }


            MailMessage ePosta = new MailMessage();

            ePosta.From = new MailAddress("*****@*****.**");
            ePosta.To.Add(textBox_Eposta.Text);
            ePosta.Subject = "parola yenile";
            ePosta.Body    = "Parola yenileme kodunuz : " + uret.ToString();
            SmtpClient smtp = new SmtpClient();

            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "otokondri123");
            smtp.Port        = 587;
            smtp.Host        = "smtp.gmail.com";
            smtp.EnableSsl   = true;
            object userState = ePosta;
            bool   kontrol   = true;

            try
            {
                smtp.SendAsync(ePosta, (object)ePosta);
                MessageBox.Show("Mail gönderildi.");
            }
            catch (SmtpException ex)
            {
                kontrol = false;
                System.Windows.Forms.MessageBox.Show(ex.Message, "Mail Gönderme Hatasi");
            }



            string islem = "select Id from tbl_Personel where Email = '" + textBox_Eposta.Text + "'";
            string id    = SqlConn.Id_Deger(islem);


            string insrt = "insert into ParolaYenile(Random,Personel_Id)values('" + uret + "','" + id + "')";

            SqlConn.Islemler(insrt);

            SifreYenileme ynl = new SifreYenileme();

            ynl.id = id;

            ynl.Show();
            this.Hide();
        }
Ejemplo n.º 8
0
        private void button_AracEkleme_Click(object sender, EventArgs e)
        {
            try
            {
                string aracinsert = "insert into tbl_Arac(Marka,Model,Detay_Ozellik,Alis_Tarihi,Alis_Fiyati,Plaka) values('" + textBox_Marka.Text + "','" + textBox_Model.Text + "','" + textBox_AracEkleDetay.Text + "','" + dateTime_AlisTarihi.Text + "','" + int.Parse(textBox_AlisFiyati.Text) + "','" + textBox_Plaka.Text + "')SELECT SCOPE_IDENTITY();";
                id = SqlConn.Id_Deger(aracinsert);
                MessageBox.Show("İşlem Başarılı.");
            }
            catch (Exception)
            {
                MessageBox.Show("Hata!!");
            }


            if (textBox_FotoUzanti1.Text != "")
            {
                dosyaismi = Path.GetFileName(dosyayolu1);
                string kaynak = dosyayolu1;
                string hedef  = Application.StartupPath + @"\photos\";
                yeniad = textBox_Plaka.Text + "_1.jpg";

                string fotografinsert = "insert into tbl_Fotograf(Fotograf_Uzanti,Arac_Id,Sira,ProfilFotograf) values('" + yeniad + "','" + id + "','" + 1 + "','" + 1 + "')";
                SqlConn.Islemler(fotografinsert);
                File.Copy(kaynak, hedef + yeniad);
            }


            if (textBox_FotoUzanti2.Text != "")
            {
                dosyaismi = Path.GetFileName(dosyayolu2);
                string kaynak = dosyayolu2;
                string hedef  = Application.StartupPath + @"\photos\";
                yeniad = textBox_Plaka.Text + "_2.jpg";

                string fotografinsert = "insert into tbl_Fotograf(Fotograf_Uzanti,Arac_Id,Sira) values('" + yeniad + "','" + id + "','" + 2 + "')";
                SqlConn.Islemler(fotografinsert);
                File.Copy(kaynak, hedef + yeniad);
            }

            if (textBox_FotoUzanti3.Text != "")
            {
                dosyaismi = Path.GetFileName(dosyayolu3);
                string kaynak = dosyayolu3;
                string hedef  = Application.StartupPath + @"\photos\";
                yeniad = textBox_Plaka.Text + "_3.jpg";

                string fotografinsert = "insert into tbl_Fotograf(Fotograf_Uzanti,Arac_Id,Sira) values('" + yeniad + "','" + id + "','" + 3 + "')";
                SqlConn.Islemler(fotografinsert);
                File.Copy(kaynak, hedef + yeniad);
            }

            if (textBox_FotoUzanti4.Text != "")
            {
                dosyaismi = Path.GetFileName(dosyayolu4);
                string kaynak = dosyayolu4;
                string hedef  = Application.StartupPath + @"\photos\";
                yeniad = textBox_Plaka.Text + "_4.jpg";

                string fotografinsert = "insert into tbl_Fotograf(Fotograf_Uzanti,Arac_Id,Sira) values('" + yeniad + "','" + id + "','" + 4 + "')";
                SqlConn.Islemler(fotografinsert);
                File.Copy(kaynak, hedef + yeniad);
            }

            SqlConnection con = new SqlConnection("Data Source=DESKTOP-7L6TOHU;Initial Catalog=OtokondriOtomasyon;Persist Security Info=True;User ID=sa;Password=123456789");

            con.Open();
            SqlDataAdapter adapter = new SqlDataAdapter("Select Marka, Model,Detay_Ozellik,Alis_Tarihi,Alis_Fiyati,Satis_Tarihi,Satis_Fiyati from tbl_Arac", con);
            DataTable      dtable  = new DataTable();

            adapter.Fill(dtable);
            dataGridView_AracSilListe.DataSource = dtable;
            con.Close();
        }
Ejemplo n.º 9
0
        private void btn_Guncelle_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_FotoUzanti1.Text != uzanti1)
                {
                    //sildik
                    string hedef = Application.StartupPath + @"\photos\";
                    if (System.IO.File.Exists(@hedef + uzanti1))
                    {
                        System.IO.File.Delete(@hedef + uzanti1);
                    }
                    //ekledik
                    dosyaismi = Path.GetFileName(dosyayolu1);
                    string kaynak = dosyayolu1;
                    yeniad = textBox_Plaka.Text.ToString() + "_1.jpg";
                    string deneme = textBox_Plaka.Text;


                    string fotografinsert = "update tbl_Fotograf set Fotograf_Uzanti='" + yeniad + "',Arac_Id='" + textBox_id.Text + "',Sira='" + 1 + "',ProfilFotograf='" + 1 + "' where Sira='" + 1 + "'";
                    SqlConn.Islemler(fotografinsert);
                    File.Copy(kaynak, hedef + yeniad);
                }
                //***************************************************************************************
                if (textBox_FotoUzanti2.Text != uzanti2)
                {
                    //sildik
                    string hedef = Application.StartupPath + @"\photos\";
                    if (System.IO.File.Exists(@hedef + uzanti2))
                    {
                        System.IO.File.Delete(@hedef + uzanti2);
                    }
                    //ekledik
                    dosyaismi = Path.GetFileName(dosyayolu2);
                    string kaynak = dosyayolu2;
                    yeniad = textBox_Plaka.Text + "_2.jpg";

                    string fotografinsert = "update tbl_Fotograf set Fotograf_Uzanti='" + yeniad + "',Arac_Id='" + textBox_id.Text + "',Sira='" + 2 + "' where Sira='" + 2 + "'";
                    SqlConn.Islemler(fotografinsert);
                    File.Copy(kaynak, hedef + yeniad);
                }
                //***************************************************************************************
                if (textBox_FotoUzanti3.Text != uzanti3)
                {
                    //sildik
                    string hedef = Application.StartupPath + @"\photos\";
                    if (System.IO.File.Exists(@hedef + uzanti3))
                    {
                        System.IO.File.Delete(@hedef + uzanti3);
                    }


                    //ekledik
                    dosyaismi = Path.GetFileName(dosyayolu3);
                    string kaynak = dosyayolu3;
                    yeniad = textBox_Plaka.Text + "_3.jpg";

                    string fotografinsert = "update tbl_Fotograf set Fotograf_Uzanti='" + yeniad + "',Arac_Id='" + textBox_id.Text + "',Sira='" + 3 + "' where Sira='" + 3 + "'";
                    SqlConn.Islemler(fotografinsert);
                    File.Copy(kaynak, hedef + yeniad);
                }
                //***************************************************************************************
                if (textBox_FotoUzanti4.Text != uzanti4)
                {
                    //sildik
                    string hedef = Application.StartupPath + @"\photos\";
                    if (System.IO.File.Exists(@hedef + uzanti4))
                    {
                        System.IO.File.Delete(@hedef + uzanti4);
                    }
                    //ekledik
                    dosyaismi = Path.GetFileName(dosyayolu4);
                    string kaynak = dosyayolu4;
                    yeniad = textBox_Plaka.Text + "_4.jpg";

                    string fotografinsert = "update tbl_Fotograf set Fotograf_Uzanti='" + yeniad + "',Arac_Id='" + textBox_id.Text + "',Sira='" + 4 + "' where where Sira='" + 4 + "'";
                    SqlConn.Islemler(fotografinsert);
                    File.Copy(kaynak, hedef + yeniad);
                }

                string komut = " UPDATE tbl_Arac SET Marka = '" + textBox_Marka.Text + "', Model ='" + textBox_Model.Text + "', Detay_Ozellik = '" + textBox_Detay.Text + "', Alis_Fiyati = '" + textBox_AlisFiyati.Text + "',Satis_Fiyati = '" + textBox_SatisFiyati.Text + "',Alis_Tarihi = '" + dateTime_AlisTarihi.Text + "',Satis_Tarihi = '" + dateTime_SatisTarihi.Text + "',Plaka ='" + textBox_Plaka.Text + "' WHERE Id = '" + textBox_id.Text + "'";
                SqlConn.Islemler(komut);
                MessageBox.Show("Güncelleme başarılı.");
            }
            catch (Exception)
            {
                MessageBox.Show("Hata!!");
            }
        }