Untitled
Transkript
Form1
using System;
using System.Collections.Generic;
using System.ComponentModel; using
System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace stokTakip
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = vt.dtGetir("select* from stok order by
stokadi"); for (int i = 0; i < dt.Rows.Count; i++)
{
int stok = Convert.ToInt32(dt.Rows[i]["stokId"].ToString());
dgStok.Rows.Add(dt.Rows[i]["stokId"].ToString(), dt.Rows[i]["stokadi"].ToString(),
dt.Rows[i]["model"].ToString(), dt.Rows[i]["seri_no"].ToString(),
dt.Rows[i]["miktar"].ToString(), dt.Rows[i]["tarih"].ToString());
getir();
}
}
public void getir()
{
DataTable dt = vt.dtGetir("select* from stok order by stokadi");
dgStok.Rows.Clear();
for (int i = 0; i < dt.Rows.Count; i++)
{
int stok = Convert.ToInt32(dt.Rows[i]["stokId"].ToString());
dgStok.Rows.Add(dt.Rows[i]["stokId"].ToString(), dt.Rows[i]["stokadi"].ToString(),
dt.Rows[i]["model"].ToString(), dt.Rows[i]["seri_no"].ToString(),
dt.Rows[i]["miktar"].ToString(), dt.Rows[i]["tarih"].ToString());
}
}
private void dgStok_CellClick_1(object sender, DataGridViewCellEventArgs e)
{
txtId.Text = dgStok.CurrentRow.Cells[0].Value.ToString();
txtAdi.Text = dgStok.CurrentRow.Cells[1].Value.ToString();
txtModel.Text = dgStok.CurrentRow.Cells[2].Value.ToString();
txtSeriNo.Text = dgStok.CurrentRow.Cells[3].Value.ToString();
txtAdet.Text = dgStok.CurrentRow.Cells[4].Value.ToString();
dtTarih.Text = dgStok.CurrentRow.Cells[5].Value.ToString();
}
private void btnCikti_Click_1(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application excel = new
Microsoft.Office.Interop.Excel.Application();
excel.Workbooks.Add();
excel.Visible = true;
excel.Cells[1,
excel.Cells[1,
excel.Cells[1,
excel.Cells[1,
excel.Cells[1,
excel.Cells[1,
1].value
2].value
3].value
4].value
5].value
6].value
=
=
=
=
=
=
"ID";
"Stok Adı";
"Stok Modeli";
"Seri No";
"Stok Adedi";
"Tarih";
for (int i = 0; i < dgStok.RowCount; i++)
{
excel.Cells[i
excel.Cells[i
excel.Cells[i
excel.Cells[i
excel.Cells[i
excel.Cells[i
+ 2, 1].value
+ 2, 2].value
+ 2, 3].value
+ 2, 4].value
+ 2, 5].value
+ 2, 6].value =
= dgStok.Rows[i].Cells[0].Value;
= dgStok.Rows[i].Cells[1].Value;
= dgStok.Rows[i].Cells[2].Value;
= dgStok.Rows[i].Cells[3].Value;
= dgStok.Rows[i].Cells[4].Value;
dgStok.Rows[i].Cells[5].Value;
}
}
private void btnStokEkle_Click_1(object sender, EventArgs e)
{
if (txtAdi.Text == "" || txtModel.Text == "" || txtSeriNo.Text == "" || txtAdet.Text
== "" || dtTarih.Text == "")
{
MessageBox.Show("Lütfen Tüm Alanları Doldurunuz", "Hata",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
vt.sqlCalistir("insert into stok (stokadi,model,seri_no,miktar,tarih) values ('" +
txtAdi.Text + "','" + txtModel.Text + "','" + txtSeriNo.Text + "','" + txtAdet.Text + "','" +
dtTarih.Text + "')");
MessageBox.Show("Stok ve Ürün Kaydı Yapıldı", "İşlem Tamam", MessageBoxButtons.OK,
MessageBoxIcon.Information);
getir();
txtId.Clear();
txtAdi.Clear();
txtModel.Clear();
txtSeriNo.Clear();
txtAdet.Clear();
}
private void btnStokGuncelle_Click_1(object sender, EventArgs e)
{
if (txtAdi.Text == "" || txtModel.Text == "" || txtSeriNo.Text == "" || txtAdet.Text
== "" || dtTarih.Text == "" )
{
MessageBox.Show("Lütfen Tüm Alanları Doldurunuz", "Hata",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
vt.sqlCalistir("update stok set stokadi='" + txtAdi.Text + "',model='" + txtModel.Text
+ "',seri_no='" + txtSeriNo.Text + "',miktar='" + txtAdet.Text + "',tarih='" + dtTarih.Text +"'
where stokId=" + txtId.Text + "");
MessageBox.Show("Kayıt Güncellendi", "İşlem Tamam", MessageBoxButtons.OK,
MessageBoxIcon.Information);
getir();
txtId.Clear();
txtAdi.Clear();
txtModel.Clear();
txtSeriNo.Clear();
txtAdet.Clear();
}
private void btnStokSil_Click_1(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtId.Text))
{
MessageBox.Show("Lütfen Silinecek Kaydı Seçiniz!", "Hata", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
if (MessageBox.Show("Kayıt Silinecek Onaylıyor musunuz?", "İşlem Onayı",
MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
vt.sqlCalistir("delete from stok where stokId=" +
Convert.ToInt32(txtId.Text)); Convert.ToInt32(txtId.Text);
MessageBox.Show("Kayıt Silindi", "İşlem Tamam",
MessageBoxButtons.OK, MessageBoxIcon.Information);
getir();
txtId.Clear();
txtAdi.Clear();
txtModel.Clear();
txtSeriNo.Clear();
txtAdet.Clear();
}
private void btnCikis_Click_1(object sender, EventArgs e)
{
this.Close();
}
}
}
Vt Class Dosyası
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace stokTakip
{
class vt
{
public static OleDbConnection Baglan()
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" + Application.StartupPath + "/stok.mdb");
baglanti.Open();
return baglanti;
}
public static DataTable dtGetir(string sql)
{
OleDbConnection baglanti = Baglan();
OleDbCommand cmd = new
OleDbCommand(); cmd.Connection =
baglanti; cmd.CommandText = sql;
DataTable dt = new DataTable();
OleDbDataAdapter adp = new
OleDbDataAdapter(); adp.SelectCommand = cmd;
adp.Fill(dt);
cmd.Connection.Close();
baglanti.Close();
adp.Dispose();
cmd.Dispose();
return dt;
}
public static bool sqlCalistir(string sql)
{
OleDbConnection baglanti = Baglan();
OleDbCommand cmd = new
OleDbCommand(); cmd.Connection =
baglanti; cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cmd.Connection.Close();
baglanti.Close();
cmd.Dispose();
return true;
}
public static int kayitSayisi(string sql)
{
OleDbConnection baglanti = Baglan();
OleDbCommand cmd = new
OleDbCommand(); cmd.Connection =
baglanti; cmd.CommandText = sql;
DataTable dt = new DataTable();
OleDbDataAdapter adp = new
OleDbDataAdapter(); adp.SelectCommand = cmd;
adp.Fill(dt);
return dt.Rows.Count;
cmd.Connection.Close();
baglanti.Close();
adp.Dispose();
cmd.Dispose();
}
}
}
Benzer belgeler
Form1 Form2 Form3 Form4
MessageBox.Show("Kayıt Silindi", "İşlem Tamam",
MessageBoxButtons.OK, MessageBoxIcon.Information);
txtGider.Clear();
txtMiktar.Clear();
txtAciklama.Clear();
Goster();
c# ile seri port, grafik, excel işlemleri
chart1.Series[0].Points.AddXY(t, Convert.ToDouble(veri));
dataGridView1.Rows[str].Cells[0].Value = DateTime.Now.ToLongDateString();
dataGridView1.Rows[str].Cells[1].Value = DateTime.Now.ToLongTimeS...
klemsan f yat l stes
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
1 29 Mart 2012 / Perşembe Yeni bir site açıyoruz. Vt.mdb veri
using
using
using
using
using
using
using
using
toplama_donguler_ile_03_10_2015
Form1
using System;
using System.Collections.Generic;
using System.ComponentModel; using
System.Data;