-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrmÜrünler.cs
133 lines (116 loc) · 4.63 KB
/
FrmÜrünler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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.Sql;
using System.Data.SqlClient;
using System.Configuration;
namespace market
{
public partial class FrmÜrünler : baseForm
{
public FrmÜrünler()
{
InitializeComponent();
}
private void FrmÜrünler_MdiChildActivate(object sender, EventArgs e)
{
mainMdiForm frmÜ = new mainMdiForm();
frmÜ.MdiParent = Program.owner;
frmÜ.Show();
}
private void FrmÜrünler_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
gridÜrünList.Visible = false;
gridÜrün.Visible = true;
}
private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.Close();
}
private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ürünListele();
gridÜrünList.Visible = true;
gridÜrün.Visible = false;
}
private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
DataTable tablo = new DataTable();
DBOperationsForSql dbnesne = new DBOperationsForSql();
dbnesne.DBOperationsForSqlServerFromAppConfig(true);
dbnesne.Baglan();
SqlDataAdapter dataAdap = new SqlDataAdapter("SELECT * FROM TST.ürünler", dbnesne.Baglanti);
dataAdap.Fill(tablo);
lblTopÜrün.Text = tablo.Rows.Count.ToString();
lblÜrünTxt.Visible = true;
lblTopÜrün.Visible = true;
}
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
gridÜrünList.Visible = true;
gridÜrün.Visible = false;
ürünListele();
}
public void ürünListele()
{
DataTable tablo = new DataTable();
DBOperationsForSql dbnesne = new DBOperationsForSql();
dbnesne.DBOperationsForSqlServerFromAppConfig(true);
dbnesne.Baglan();
SqlDataAdapter dataAdap = new SqlDataAdapter("SELECT * FROM TST.ürünler", dbnesne.Baglanti);
dataAdap.Fill(tablo);
gridÜrünList.DataSource = tablo;
}
public override void Kaydet()
{
DBOperationsForSql dbnesne = new DBOperationsForSql();
dbnesne.DBOperationsForSqlServerFromAppConfig(true);
dbnesne.Baglan();
ürünler.yeniÜrün nsnÜrün = new ürünler.yeniÜrün();
nsnÜrün.adi = gridView1.GetFocusedRowCellValue("ürünAdi").ToString();
nsnÜrün.kod = gridView1.GetFocusedRowCellValue("ürünKodu").ToString();
nsnÜrün.marka = gridView1.GetFocusedRowCellValue("marka").ToString();
nsnÜrün.adet = gridView1.GetFocusedRowCellValue("adet").ToString();
nsnÜrün.fiyat = gridView1.GetFocusedRowCellValue("fiyat").ToString();
MessageBox.Show("Ürün Eklendi");
ürünler ürün = new ürünler();
ürün.ürünEkle(nsnÜrün);
}
public override void Sil()
{
DBOperationsForSql dbnesne = new DBOperationsForSql();
dbnesne.DBOperationsForSqlServerFromAppConfig(true);
dbnesne.Baglan();
int ürünId = (int)gridView2.GetDataRow(gridView2.FocusedRowHandle)["id"];
string ürünİsim = (string)gridView2.GetDataRow(gridView2.FocusedRowHandle)["ürünAdi"];
string SqlÜrünSil = string.Format("delete from TST.ürünler where id ={0}", ürünId);
string UyariÜrünMsg = "" + ürünİsim + " adlı ürünü silmek istediğinize emin misiniz?";
DialogResult sonuc;
sonuc = MessageBox.Show(UyariÜrünMsg, "Uyarı!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (sonuc == DialogResult.Yes)
{
dbnesne.SqlExecute(SqlÜrünSil);
ürünListele();
}
else return;
dbnesne.BaglantiKes();
}
public override void Cikis()
{
this.Close();
}
private void FrmÜrünler_Activated(object sender, EventArgs e)
{
childForm = this;
}
}
}