C# Emlak Takip Programı

C# Emlak Takip Programı

</pre>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication1
{
 public partial class Form1 : Form
 {
 public Form1()
 {
 InitializeComponent();
 }

private void button4_Click(object sender, EventArgs e)
 {
 Form3 frm = new Form3();
 frm.Show();
 }

private void Form1_Load(object sender, EventArgs e)
 {

}

private void button2_Click(object sender, EventArgs e)
 {
 Form2 frm = new Form2();
 frm.Show();
 }

 }
}
<pre>

Form2 (Emlak Ekle)

</pre>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication1
{
 public partial class Form2 : Form
 {
 public Form2()
 {
 InitializeComponent();
 }
 OleDbConnection baglan = new OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source= emlak.accdb");
 void temizle()
 {
 textBox1.Clear();
 textBox2.Clear();
 textBox3.Clear();
 textBox4.Clear();
 textBox5.Clear();
 textBox6.Clear();
 //WHERE (durum like '%satılık%'and durum like '%kiralık%')
 }
 void goster()
{
 OleDbDataAdapter getir = new OleDbDataAdapter("SELECT * FROM emlak", baglan);
 baglan.Open();
DataSet goster = new DataSet();
getir.Fill(goster, "emlak");
 dataGridView1.DataSource = goster.Tables["emlak"];
getir.Dispose();
 baglan.Close();
}

private void Form2_Load(object sender, EventArgs e)
 {
 label11.Hide();
 label12.Hide();
 label13.Hide();
 label14.Hide();
 label15.Hide();
 label16.Hide();
 label17.Hide();
 label18.Hide();
 label19.Hide();
 label20.Hide();
 label21.Hide();

 label9.Hide();
 textBox6.Hide();

 goster();
 /* */
 }

private void label2_Click(object sender, EventArgs e)
 {

}

int a=0;
 private void button1_Click(object sender, EventArgs e)
 {
 label21.Visible = false;
 label20.Visible = false;
 label19.Visible = false;
 label18.Visible = false;
 label17.Visible = false;
 label16.Visible = false;
 label15.Visible = false;
 label14.Visible = false;
 label13.Visible = false;
 label12.Visible = false;
 if (pictureBox1.ImageLocation == null){label21.Visible = true; a++;}
 if (textBox5.Text == "") { label20.Visible = true;a++; }
 if (comboBox2.Text == "") { label19.Visible = true;a++; }
 if (textBox4.Text == "") { label18.Visible = true;a++; }
 if (textBox3.Text == "") { label17.Visible = true; a++;}
 if (comboBox4.Text == "") { label16.Visible = true; a++;}
 if (comboBox3.Text == "") { label15.Visible = true; a++;}
 if (textBox2.Text == "") { label14.Visible = true; a++;}
 if (textBox1.Text == "") { label13.Visible = true; a++;}
 if (comboBox1.Text == "") { label12.Visible = true; a++;}

 else if (a==0)
 {
 baglan.Open();
 OleDbCommand kaydet = new OleDbCommand("INSERT INTO emlak([tür],[madsoyad],[adres],[tel],[fiyat],[durum],[not],[resim])Values(@tür,@madsoyad,@adres,@tel,@fiyat,@durum,@not,@resim)", baglan);

kaydet.Parameters.AddWithValue("@tür", comboBox1.Text);
 kaydet.Parameters.AddWithValue("@madsoyad", textBox1.Text);
 kaydet.Parameters.AddWithValue("@adres", comboBox3.Text + " " + comboBox4.Text + " " + textBox2.Text);
 kaydet.Parameters.AddWithValue("@tel", textBox3.Text);
 kaydet.Parameters.AddWithValue("@fiyat", textBox4.Text);
 kaydet.Parameters.AddWithValue("@durum", comboBox2.Text);
 kaydet.Parameters.AddWithValue("@not", textBox5.Text);

kaydet.Parameters.AddWithValue("@resim", pictureBox1.ImageLocation);
 pictureBox1.Image.Save("Resimler/" + textBox3.Text.ToString() + ".jpg");

kaydet.ExecuteNonQuery();
 baglan.Close();
 MessageBox.Show("Kayıt Başarıyla Gerçekleşti");
 goster();
 temizle();

 }
 a = 0;

}

private void button2_Click(object sender, EventArgs e)
 {
 baglan.Open();
 OleDbCommand sil = new OleDbCommand("delete From emlak Where [emlakno]=@emlakno", baglan);
 sil.Parameters.AddWithValue("@emlakno", textBox6.Text);
 sil.ExecuteNonQuery();
 MessageBox.Show("Kayıt Silindi");
 baglan.Close();
 goster();
 temizle();

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {

}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 comboBox4.Enabled = false;
 comboBox3.Enabled = false;
 int stırno = dataGridView1.SelectedCells[0].RowIndex;
 textBox6.Text = dataGridView1.Rows[stırno].Cells[0].Value.ToString();
 comboBox1.Text = dataGridView1.Rows[stırno].Cells[1].Value.ToString();
 textBox1.Text = dataGridView1.Rows[stırno].Cells[2].Value.ToString();
 textBox2.Text = dataGridView1.Rows[stırno].Cells[3].Value.ToString();
 textBox3.Text = dataGridView1.Rows[stırno].Cells[4].Value.ToString();
 textBox4.Text = dataGridView1.Rows[stırno].Cells[5].Value.ToString();
 comboBox2.Text = dataGridView1.Rows[stırno].Cells[6].Value.ToString();
 textBox5.Text = dataGridView1.Rows[stırno].Cells[7].Value.ToString();
 pictureBox1.ImageLocation = "Resimler/" + dataGridView1.Rows[stırno].Cells[4].Value.ToString() + ".jpg";
 }

private void pictureBox1_Click(object sender, EventArgs e)
 {

}

private void button4_Click(object sender, EventArgs e)
 {

 if (openFileDialog1.ShowDialog() == DialogResult.OK)
 {
 pictureBox1.ImageLocation = openFileDialog1.FileName;
 }
 }

private void button3_Click(object sender, EventArgs e)
 {
 baglan.Open();
 OleDbCommand guncelle = new OleDbCommand("UPDATE emlak SET [emlakno]=@emlakno,[tür]=@tür,[madsoyad]=@madsoyad,[adres]=@adres,[tel]=@tel,[fiyat]=@fiyat,[durum]=@durum,[not]=@not,[resim]=@resim WHERE [emlakno]=@emlakno", baglan);
 guncelle.Parameters.AddWithValue("@emlakno", textBox6.Text);
 guncelle.Parameters.AddWithValue("@tür", comboBox1.Text);
 guncelle.Parameters.AddWithValue("@madsoyad", textBox1.Text);
 guncelle.Parameters.AddWithValue("@adres", textBox2.Text);
 guncelle.Parameters.AddWithValue("@tel", textBox3.Text);
 guncelle.Parameters.AddWithValue("@fiyat", textBox4.Text);
 guncelle.Parameters.AddWithValue("@durum", comboBox2.Text);
 guncelle.Parameters.AddWithValue("@not", textBox5.Text);
 guncelle.Parameters.AddWithValue("@resim", pictureBox1.ImageLocation);
 pictureBox1.Image.Save("Resimler/" + textBox3.Text.ToString() + ".jpg");
 guncelle.ExecuteNonQuery();
 MessageBox.Show("Kayıt Güncellendi");
 baglan.Close();
 goster();
 temizle();
 }

&nbsp;

private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
 {

 }

private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
 {
 comboBox4.Items.Clear();
 if (comboBox3.Text == "Konya")
 {

 comboBox4.Items.Add("meram");
 comboBox4.Items.Add("selçuklu");
 comboBox4.Items.Add("çumra");
 comboBox4.Items.Add("karatay");
 comboBox4.Items.Add("bozkır");
 comboBox4.Items.Add("hadim");

}
 else if (comboBox3.Text == "Adana")
 {

 comboBox4.Items.Add("seyhan");
 comboBox4.Items.Add("ceyhan");
 comboBox4.Items.Add("kozan");
 comboBox4.Items.Add("karataş");
 comboBox4.Items.Add("sarıçam");
 comboBox4.Items.Add("tufanbeyli");

}
 else if (comboBox3.Text == "Ankara")
 {

 comboBox4.Items.Add("akyurt");
 comboBox4.Items.Add("altındağ");
 comboBox4.Items.Add("bala");
 comboBox4.Items.Add("çubuk");
 comboBox4.Items.Add("polatlı");
 comboBox4.Items.Add("mamak");

}
 }

&nbsp;

private void button5_Click(object sender, EventArgs e)
 {
 }

private void textBox6_TextChanged(object sender, EventArgs e)
 {

}

private void button5_Click_1(object sender, EventArgs e)
 {
 comboBox1.Enabled = true;
 comboBox2.Enabled = true;
 comboBox3.Enabled = true;
 comboBox4.Enabled = true;
 pictureBox1.ImageLocation = null;
 temizle();

 }
 }
}
<pre>

Form3(Emlak)

1.466 defa okundu.

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir