SINIF İÇİ UYGULAMA KODLARI ARABA HAREKET ETTİRME 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; namespace WindowsFormsApplication33 public partial class Form1 : Form public Form1() InitializeComponent(); Graphics CizimAlani; Pen Kalem1 = new Pen(System.Drawing.Color.Red, 2); Pen Kalem2 = new Pen(System.Drawing.Color.Gray, 5); private void button1_click(object sender, EventArgs e) timer1.enabled = true; int x=0, y=100; private void timer1_tick(object sender, EventArgs e) picturebox1.refresh(); CizimAlani = picturebox1.creategraphics(); x = x + 1; //CizimAlani.DrawRectangle(Kalem1, x, y, 200, 100); CizimAlani.DrawLine(Kalem1, x+0, y+80, x+0, y+ 40); CizimAlani.DrawLine(Kalem1, x+0,y+ 40, x+40,y+ 0);
CizimAlani.FillEllipse(Brushes.Gray, x + 20, y + 80, 40, 40); CizimAlani.FillEllipse(Brushes.Gray, x + 140, y + 80, 40, 40); /* ÇİZİM PROGRAMI SINIF İÇİ UYGULAMA KODLARI 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; namespace WindowsFormsApplication12 public partial class Form1 : Form public Form1() InitializeComponent(); Graphics grafik; int Sayac; string CizimModu=null; int X1 = 0; int Y1 = 0;
int X2 = 0; int Y2 = 0; Pen Kalem = new Pen(System.Drawing.Color.White, 1); private void Form1_Load(object sender, EventArgs e) grafik = picturebox1.creategraphics(); private void picturebox1_mousemove(object sender, MouseEventArgs e) lblx.text = e.x.tostring(); lbly.text = e.y.tostring(); private void picturebox1_mouseup(object sender, MouseEventArgs e) if (Sayac == 0) X1 = e.x; Y1 = e.y; grafik.drawline(pens.yellow, X1-5, Y1, X1 + 5, Y1); grafik.drawline(pens.yellow, X1, Y1-5, X1, Y1 + 5); Sayac = Sayac + 1; else if (Sayac == 1) X2 = e.x; Y2 = e.y; grafik.drawline(pens.yellow, X2-5, Y2, X2 + 5, Y2); grafik.drawline(pens.yellow, X2, Y2-5, X2, Y2 + 5); if (CizimModu == "Line") grafik.drawline(kalem, X1, Y1, X2, Y2); X1 = X2; Y1 = Y2; else if(cizimmodu == "Rectangle") //Ödevde her yönden dikdörtgen çizimi tamamlanacak. int Genislik = X2 - X1; int Yukseklik = Y2 - Y1; grafik.drawrectangle(kalem, X1, Y1, Genislik, Yukseklik); Sayac =0; else if (CizimModu == "Circle") int R =Convert.ToInt32( Math.Sqrt((X2 - X1) * (X2 - X1) + (Y2 - Y1) * (Y2 - Y1))); X1 = X1 - R; Y1 = Y1 - R; int W = 2 * R; int H = 2 * R; grafik.drawellipse(kalem, X1, Y1, W, H); Sayac = 0;
private void btnline_click(object sender, EventArgs e) CizimModu = "Line"; Sayac = 0; private void btnrectangle_click_1(object sender, EventArgs e) CizimModu = "Rectangle"; Sayac = 0; private void btncircle_click_1(object sender, EventArgs e) CizimModu = "Circle"; Sayac = 0; private void beyaztoolstripmenuitem_click(object sender, EventArgs e) Kalem.Color = Color.White; private void kırmızıtoolstripmenuitem_click(object sender, EventArgs e) Kalem.Color = Color.Red; private void mavitoolstripmenuitem_click(object sender, EventArgs e) Kalem.Color = Color.Blue; <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title>untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:button ID="Button1" runat="server" Height="33px" onclick="button1_click" Text="BİLGİLERİ LİSTELE" Width="234px" /> <asp:gridview ID="GridView1" runat="server" AutoGenerateColumns="False" ShowFooter="True" DataKeyNames="ID" OnRowEditing="DuzenlemeKodlari" OnRowCancelingEdit="IptalKodlari" OnRowUpdating="GuncellemeKomutlari" OnRowDeleting="SilKodlari" OnRowCommand="GenelKodlar" > <Columns> <%-- ID sutunu--%> <asp:boundfield DataField="ID" Visible="false" /> <%-- AD sutunu--%> %>'/> <asp:templatefield HeaderText="İSİM" SortExpression="Ad"> <ItemTemplate> <asp:label ID="Label3" runat="server" Text='<%# Eval("Ad") </ItemTemplate> <FooterTemplate> <asp:textbox ID="txtYeniAd" runat="server" /> </FooterTemplate> </asp:templatefield> <%-- VİZE sutunu--%> <asp:templatefield HeaderText="VİZE" SortExpression="Vize"> <ItemTemplate> <asp:label ID="Label4" runat="server" Text='<%# Eval("Vize") %>'/> </ItemTemplate> <EditItemTemplate> <asp:textbox ID="txtVize" BackColor="Yellow" Width="50" runat="server" Text='<%# Bind("Vize") %>'/> </EditItemTemplate> </asp:templatefield>
<%-- DÜZENLE sutunu--%> <asp:templatefield HeaderText="DÜZENLE" ShowHeader="false"> <ItemTemplate> <asp:linkbutton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Düzenle" /> </ItemTemplate> <EditItemTemplate> <asp:linkbutton ID="LinkButton11" runat="server" CausesValidation="True" CommandName="Update" Text="Güncelle" /> <asp:linkbutton ID="LinkButton22" runat="server" CausesValidation="False" CommandName="Cancel" Text="İptal" /> </EditItemTemplate> <FooterTemplate> <asp:linkbutton ID="LinkButton222" runat="server" CausesValidation="True" CommandName="Kaydet" Text="KAYDET" /> </FooterTemplate> </asp:templatefield> <%-- SİL sutunu--%> <asp:templatefield HeaderText="SİL" ShowHeader="false"> <ItemTemplate> <asp:linkbutton ID="LinkButton111" runat="server" CausesValidation="False" CommandName="Delete" Text="Sil" /> </ItemTemplate> </asp:templatefield> </Columns> </div> </form> </body> </html> </asp:gridview> using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e) BilgileriGetir(); public void BilgileriGetir() //Bağlantı Kurma (Köprü) (Adres Web.config alınıyor) //Sorgu (Emir Listesi) string Sorgu = "SELECT * FROM Tablo1"; //Adapter Nesnesine bilgiler yüklenerek görüntüleme (Şoför) OleDbDataAdapter Adapter1 = new OleDbDataAdapter(Sorgu, Baglanti); //Bilgiler Dataset ile taşınacak (Kamyon) DataSet DataSet1 = new DataSet(); //Bilgiler DataSetin içersindeki tanımladığımız Tablo1 isimli tabloya Adapter tarafından yükleniyor. Adapter1.Fill(DataSet1, "Bilgiler"); //Bilgiler sayfamızdaki hazır nesne tarafından görüntüleniyor. GridView1.DataSource = DataSet1.Tables["Bilgiler"]; GridView1.DataBind(); //EDİT (DÜZELTME) BUTONUNA BASILDIĞINDA ===================== protected void DuzenlemeKodlari(object sender, GridViewEditEventArgs e) GridView1.EditIndex = e.neweditindex; //Tıklanan satırın numarasını alıyor. Tıkladığım satırın hangi satır olduğunu alıyor. BilgileriGetir(); //GÜNCELLEMEYİ İPTAL EDİYOR =============================== protected void IptalKodlari(object sender, GridViewCancelEditEventArgs e) GridView1.EditIndex = -1; //Güncelleme modundan çıkıyor. BilgileriGetir(); //GUNCELLENEN SATIRI KAYDEDIYOR ============================ protected void GuncellemeKomutlari(object sender, GridViewUpdateEventArgs e) int ID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]["ID"].ToString()); TextBox txtvize2 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtVize"); int Vize = Convert.ToInt32( txtvize2.text); BilgileriGuncelle(ID,Vize);
GridView1.EditIndex = -1; //Güncelleme modundan çıkıyor. BilgileriGetir(); //BİLGİLERİ GÜNCELLİYOR ====================================== public void BilgileriGuncelle(int ID, int Vize) //Bağlantı Kurma (Köprü) (Adres Web.config alınıyor) string Sorgu = "UPDATE Tablo1 SET Vize=" + Vize + " WHERE ID=" + ID; OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.ExecuteNonQuery(); Baglanti.Dispose(); //KAYIT SİLİYOR ============================================== protected void SilKodlari(object sender, GridViewDeleteEventArgs e) int ID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]["ID"].ToString()); KayitSil(ID); BilgileriGetir(); public void KayitSil(int ID) //Bağlantı Kurma (Köprü) (Adres Web.config alınıyor) string Sorgu = "DELETE * FROM Tablo1 WHERE ID =" + ID; OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.ExecuteNonQuery(); //YENİ BİLGİLERİ KAYDEDİYOR =================================== protected void GenelKodlar(object sender, GridViewCommandEventArgs e) if (e.commandname.equals("kaydet")) TextBox txtyeniad = (TextBox)GridView1.FooterRow.FindControl("txtYeniAd"); BilgileriKaydet(txtYeniAd.Text); BilgileriGetir();
//BİLGİLERİ KAYDEDİYOR ======================================== public void BilgileriKaydet(string Ad) //Bağlantı Kurma (Köprü) (Adres Web.config alınıyor) string Sorgu = "INSERT INTO Tablo1 (Ad) VALUES ('" + Ad + "')"; OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.ExecuteNonQuery(); VERİTABANINA BİLGİ KAYDEME, DÜZENLEME, LİSTELEME İŞLEMLERİ <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>untitled Page</title>
<style type="text/css">.style1 height: 22px;.style2 height: 22px; width: 104px;.style3 width: 104px; </style> </head> <body> <form id="form1" runat="server"> <div> <asp:button ID="btnLISTELE" runat="server" Height="31px" onclick="btnlistele_click" Text="BİLGİLERİ LİSTELE" Width="217px" /> <asp:gridview ID="GridView1" runat="server"> </asp:gridview> <table style="width: 52%;"> OgrNo <asp:textbox ID="txtOgrNo" runat="server"></asp:textbox> Ad <asp:textbox ID="txtAd" runat="server"></asp:textbox> Soyad <asp:textbox ID="txtSoyad" runat="server"></asp:textbox> <td class="style3"> <td> <asp:button ID="btnKaydet" runat="server" Text="BİLGİLERİ KAYDET" Width="182px" onclick="btnkaydet_click" /> <asp:label ID="lblMesaj" runat="server" ForeColor="#FF3300"></asp:Label> </table> <table style="width: 52%;">
<asp:radiobutton ID="RadioButton1" runat="server" GroupName="Arama" Text="OgrNo" /> <asp:radiobutton ID="RadioButton2" runat="server" GroupName="Arama" Text="Id" /> <asp:textbox ID="txtArama1" runat="server" Width="46px"></asp:TextBox> <asp:button ID="btnBul" runat="server" Height="25px" onclick="btnbul_click" Text="BUL" Width="62px" /> <asp:button ID="btnKayitSil" runat="server" Height="25px" onclick="btnkayitsil_click" Text="KAYIT SİL" Width="84px" /> Ad <asp:textbox ID="txtAd1" runat="server" Enabled="False"></asp:TextBox> Soyad <asp:textbox ID="txtSoyad1" runat="server" Enabled="False"></asp:TextBox> Vize <asp:textbox ID="txtVize1" runat="server" Width="55px"></asp:TextBox> Final <asp:textbox ID="txtFinal1" runat="server" Width="55px"></asp:TextBox> <td class="style3"> <td> <asp:button ID="btnGuncelle" runat="server" Text="BİLGİLERİ GÜNCELLE" Width="182px" onclick="btnguncelle_click" /> <asp:label ID="lblMesaj1" runat="server" ForeColor="#FF3300"></asp:Label> </table> </div> </form>
</body> </html> using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void btnlistele_click(object sender, EventArgs e) //Bağlantı Kurma (Köprü) //Sorgu (Emir Listesi) string Sorgu = "SELECT ID, OgrNo, Ad,Soyad, Vize,Final FROM Tablo1"; //Adapter Nesnesine bilgiler yüklenerek görüntüleme (Şoför) OleDbDataAdapter Adapter1 = new OleDbDataAdapter(Sorgu, Baglanti); //Bilgiler Dataset ile taşınacak (Kamyon) DataSet DataSet1 = new DataSet(); //Bilgiler DataSetin içersindeki tanımladığımız Tablo1 isimli tabloya Adapter tarafından yükleniyor. Adapter1.Fill(DataSet1, "Bilgiler"); //Bilgiler sayfamızdaki hazır nesne tarafından görüntüleniyor. GridView1.DataSource = DataSet1.Tables["Bilgiler"]; GridView1.DataBind(); protected void btnkaydet_click(object sender, EventArgs e) //Bağlantıyı Kur (Köprü)
int OgrNo = Convert.ToInt32( txtarama1.text); string Ad = txtad.text; string Soyad = txtsoyad.text; string Sorgu = "INSERT INTO Tablo1 (OgrNo, Ad, Soyad) VALUES (@OgrNo, @Ad, @Soyad)"; //Komut Nesnesi (Şöför) OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.Parameters.AddWithValue("@OgrNo", OgrNo); Komut.Parameters.AddWithValue("@Ad", Ad); Komut.Parameters.AddWithValue("@Soyad", Soyad); Komut.ExecuteNonQuery(); lblmesaj.text = "Bilgileriniz kaydedilmiştir"; protected void btnbul_click(object sender, EventArgs e) //Bağlantı Kurma (Köprü) int Arama = Convert.ToInt32(txtArama1.Text); Arama; string Sorgu = null; if (RadioButton1.Checked == true) Sorgu = "SELECT Ad,Soyad, Vize, Final FROM Tablo1 WHERE OgrNo= " + else if (RadioButton2.Checked == true) Sorgu = "SELECT Ad,Soyad, Vize, Final FROM Tablo1 WHERE ID= " + Arama; //Sorgu (Emir Listesi) ///Komut Nesnesi (Şöför) OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); //Okuyucu nesnesi (Kamyon) OleDbDataReader Okuyucu = Komut.ExecuteReader(); //Bilgiler Sayfaya yükleniyor while (Okuyucu.Read()) txtad1.text = Okuyucu["Ad"].ToString(); txtsoyad1.text = Okuyucu["Soyad"].ToString(); txtvize1.text = Okuyucu["Vize"].ToString(); txtfinal1.text = Okuyucu["Final"].ToString();
protected void btnguncelle_click(object sender, EventArgs e) //Bağlantıyı Kur (Köprü) int OgrNo = Convert.ToInt32(txtArama1.Text); string Vize = txtvize1.text; string Final = txtfinal1.text; OgrNo; //Sorgu (Emir Listesi) String Sorgu = "UPDATE Tablo1 SET Vize=@Vize, Final=@Final WHERE OgrNo =" + //Komut Nesnesi (Şöför) OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.Parameters.AddWithValue("@Vize", Vize); Komut.Parameters.AddWithValue("@Final", Final); Komut.ExecuteNonQuery(); lblmesaj1.text = "Bilgileriniz Güncellenmiştir"; protected void btnkayitsil_click(object sender, EventArgs e) //Bağlantıyı Kur (Köprü) int Arama = Convert.ToInt32 (txtarama1.text); string Sorgu = null; if (RadioButton1.Checked == true) Sorgu = "DELETE * FROM Tablo1 WHERE OgrNo = @Arama"; // +Arama; else if (RadioButton2.Checked == true) Sorgu = "DELETE * FROM Tablo1 WHERE ID = @Arama "; // +Arama; //Komut Nesnesi (Şöför) OleDbCommand Komut = new OleDbCommand(Sorgu, Baglanti); Komut.Parameters.AddWithValue("@Arama", Arama); Komut.ExecuteNonQuery();
//Sorgu (Emir Listesi) //1.Yöntem** string Sorgu = "INSERT INTO Ogrenciler (OgrenciNo, Ad, Soyad, Vize, Final) VALUES ('123','Mustafa','Karataş', 34, 56)", //2.Yöntem** string Sorgu = "INSERT INTO Ogrenciler (OgrenciNo, Ad, Soyad, Vize, Final) VALUES ('" + OgrenciNo + "','" + Ad + "','" + Soyad + "'," + Vize + "," + Final + ")"; //3.Yöntem** string Sorgu = string.format("insert INTO Ogrenciler (OgrenciNo, Ad, Soyad, Vize, Final) VALUES ('0','1','2',3,4)", OgrenciNo,Ad,Soyad,Vize,Final); //string Sorgu = "INSERT INTO Ogrenciler (OgrenciNo, Ad, Soyad, Vize, Final) VALUES (@OgrenciNo, @Ad, @Soyad, @Vize, @Final)"; //4.Yöntem** Parametre kullanarak kayıt yapma