Beispiel #1
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            satis satis = new satis();

            satis.idyiBulVeGetir = int.Parse(listView1.SelectedItems[0].SubItems[0].Text);
            satis.adiBulVeGetir  = listView1.SelectedItems[0].SubItems[1].Text;
            this.Close();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            satis   satis  = (satis)Application.OpenForms["satis"];
            decimal tfiyat = 0;

            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                int     id             = Convert.ToInt32(dataGridView2.Rows[i].Cells[0].Value);
                int     musterikodu    = Convert.ToInt32(dataGridView2.Rows[i].Cells[1].Value);
                string  barkod         = dataGridView2.Rows[i].Cells[2].Value.ToString();
                string  urunAciklamasi = dataGridView2.Rows[i].Cells[3].Value.ToString();
                decimal fiyat          = Convert.ToDecimal(dataGridView2.Rows[i].Cells[4].Value.ToString());
                tfiyat = tfiyat + fiyat;
                string   odemeSekli = dataGridView2.Rows[i].Cells[5].Value.ToString();
                DateTime tarih      = Convert.ToDateTime(dataGridView2.Rows[i].Cells[6].Value);
                satis.groupBoxdegisim.Visible = true;
                satis.dataGridView2.Rows.Add(id, musterikodu, barkod, urunAciklamasi, fiyat, odemeSekli, tarih);
            }
            satis.degisecekurunfiyati.Text = tfiyat.ToString();
            decimal odenecektutar = Convert.ToDecimal(satis.lblFiyat.Text) - tfiyat;

            satis.odenecektutar.Text = odenecektutar.ToString();
            this.Close();
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            OleDbConnection baglan = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=veritabani.xlsx; Extended Properties='Excel 12.0 xml;HDR=YES;'");

            if (groupBoxdegisim.Visible == false)
            {
                if (txtMusteri_adi.Text != "" && textMusteriID.Text != "")
                {
                    string odemesekli = "";
                    string kartturu   = "";
                    if (radioButton1.Checked)
                    {
                        odemesekli = "kk";
                        kartturu   = comboBox1.Text;
                        odemesekli = odemesekli + " " + kartturu;
                    }
                    else if (radioButton2.Checked)
                    {
                        odemesekli = "n";
                    }
                    else
                    {
                        odemesekli = "";
                    }
                    if (odemesekli != "")
                    {
                        try
                        {
                            progressBar1.Visible = true;
                            progressBar1.Value  += 15;
                            baglan.Open();
                            OleDbDataAdapter idbul = new OleDbDataAdapter("Select MAX(ID) AS ID From [satış$]", baglan);
                            DataTable        id    = new DataTable();
                            idbul.Fill(id);
                            int ID = Convert.ToInt32(id.Rows[0]["ID"].ToString());
                            ID++;
                            progressBar1.Value += 15;
                            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                            {
                                ID++;
                                Int64        BarkodNOO = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                                int          musteriID = Convert.ToInt32(textMusteriID.Text);
                                decimal      Fiyati    = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value);
                                DateTime     zaman     = DateTime.Now;
                                string       saat      = DateTime.Now.ToShortTimeString();
                                OleDbCommand komut     = new OleDbCommand("INSERT INTO [satış$] (ID, BARKOD_NO, MÜŞTERİ_ID, FİYAT, ÖDEME_ŞEKLİ , TARİH) VALUES(@ID, @BarkodNOO, @musteriID, '" + Fiyati + "', @odemesekli, @zaman)", baglan);
                                komut.Parameters.AddWithValue("@ID", ID);
                                komut.Parameters.AddWithValue("@BarkodNOO", BarkodNOO);
                                komut.Parameters.AddWithValue("@musteriID", musteriID);
                                komut.Parameters.AddWithValue("@odemesekli", odemesekli);
                                komut.Parameters.AddWithValue("@zaman", GetDateWithoutMilliseconds(DateTime.Now));
                                komut.ExecuteNonQuery();
                            }
                            progressBar1.Value += 60;
                            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                            {
                                Int64            BarkodNOO = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                                OleDbDataAdapter da        = new OleDbDataAdapter("SELECT ADET FROM [normal$] WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                DataTable        dtable    = new DataTable();
                                da.Fill(dtable);
                                if (dtable.Rows.Count == 1)
                                {
                                    int adet = Convert.ToInt32(dtable.Rows[0]["ADET"].ToString());
                                    adet = adet - 1;
                                    OleDbCommand komut3 = new OleDbCommand("UPDATE [normal$] SET ADET =" + adet + " WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                    komut3.ExecuteNonQuery();
                                }
                                else if (dtable.Rows.Count == 0)
                                {
                                    OleDbDataAdapter daa     = new OleDbDataAdapter("SELECT ADET FROM [indirimli$] WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                    DataTable        dttable = new DataTable();
                                    daa.Fill(dttable);
                                    int adet = Convert.ToInt32(dttable.Rows[0]["ADET"].ToString());
                                    adet = adet - 1;
                                    OleDbCommand komut3 = new OleDbCommand("UPDATE [indirimli$] SET ADET =" + adet + " WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                    komut3.ExecuteNonQuery();
                                }
                            }
                            progressBar1.Value += 10;
                            MessageBox.Show("Başarılı");
                        }
                        catch (Exception hata)
                        {
                            MessageBox.Show("Kayıt edilmedi " + hata.Message);
                        }
                        finally
                        {
                            progressBar1.Visible = false;
                            progressBar1.Value   = 0;
                            baglan.Close();
                        }
                        this.Hide();
                        yeniSatisform              = new satis();
                        yeniSatisform.FormClosing += yeniSatisform_FormClosing;
                        yeniSatisform.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("ÖDEME ŞEKLİ BOŞ OLAMAZ", "ÖDEME ŞEKLİ");
                    }
                }
                else
                {
                    MessageBox.Show("Müşteri Girilmedi", "Hata");
                }
            }
            else//değişim
            {
                string odemesekli = "";
                string kartturu   = "";
                if (radioButton1.Checked)
                {
                    odemesekli = "kk";
                    kartturu   = comboBox1.Text;
                    odemesekli = odemesekli + " " + kartturu;
                }
                else if (radioButton2.Checked)
                {
                    odemesekli = "n";
                }
                else
                {
                    odemesekli = "";
                }
                if (odemesekli != "")
                {
                    try
                    {
                        baglan.Open();
                        OleDbDataAdapter idbul = new OleDbDataAdapter("Select MAX(ID) AS ID From [satış$]", baglan);
                        DataTable        id    = new DataTable();
                        idbul.Fill(id);
                        int ID = Convert.ToInt32(id.Rows[0]["ID"].ToString());
                        ID++;
                        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                        {
                            ID++;
                            Int64        BarkodNOO = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                            int          musteriID = Convert.ToInt32(textMusteriID.Text);
                            decimal      Fiyati    = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value);
                            DateTime     zaman     = DateTime.Now;
                            string       saat      = DateTime.Now.ToShortTimeString();
                            OleDbCommand komut     = new OleDbCommand("INSERT INTO [satış$] (ID, BARKOD_NO, MÜŞTERİ_ID, FİYAT, ÖDEME_ŞEKLİ , TARİH) VALUES(@ID, @BarkodNOO, @musteriID, '" + Fiyati + "', @odemesekli, @zaman)", baglan);
                            komut.Parameters.AddWithValue("@ID", ID);
                            komut.Parameters.AddWithValue("@BarkodNOO", BarkodNOO);
                            komut.Parameters.AddWithValue("@musteriID", musteriID);
                            komut.Parameters.AddWithValue("@odemesekli", odemesekli);
                            komut.Parameters.AddWithValue("@zaman", GetDateWithoutMilliseconds(DateTime.Now));
                            komut.ExecuteNonQuery();
                        }
                        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                        {
                            Int64            BarkodNOO = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                            OleDbDataAdapter da        = new OleDbDataAdapter("SELECT ADET FROM [normal$] WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                            DataTable        dtable    = new DataTable();
                            da.Fill(dtable);
                            if (dtable.Rows.Count == 1)
                            {
                                int adet = Convert.ToInt32(dtable.Rows[0]["ADET"].ToString());
                                adet = adet - 1;
                                OleDbCommand komut3 = new OleDbCommand("UPDATE [normal$] SET ADET =" + adet + " WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                komut3.ExecuteNonQuery();
                            }
                            else if (dtable.Rows.Count == 0)
                            {
                                OleDbDataAdapter daa     = new OleDbDataAdapter("SELECT ADET FROM [indirimli$] WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                DataTable        dttable = new DataTable();
                                daa.Fill(dttable);
                                int adet = Convert.ToInt32(dttable.Rows[0]["ADET"].ToString());
                                adet = adet - 1;
                                OleDbCommand komut3 = new OleDbCommand("UPDATE [indirimli$] SET ADET =" + adet + " WHERE BARKOD_NO=" + BarkodNOO + "", baglan);
                                komut3.ExecuteNonQuery();
                            }
                        }
                        //normal işlemler bitiş
                        //eski ürünlere stok ekleme
                        for (int i = 0; i < dataGridView2.Rows.Count; i++)
                        {
                            Int64        barkodnumarasi = Convert.ToInt64(dataGridView2.Rows[i].Cells[2].Value);
                            OleDbCommand komutsil       = new OleDbCommand("UPDATE [satış$] SET FİYAT = 0 WHERE BARKOD_NO='" + barkodnumarasi + "'", baglan);//fiyatı silme
                            komutsil.ExecuteNonQuery();

                            OleDbDataAdapter da     = new OleDbDataAdapter("SELECT ADET FROM [normal$] WHERE BARKOD_NO=" + barkodnumarasi + "", baglan);
                            DataTable        dtable = new DataTable();
                            da.Fill(dtable);
                            if (dtable.Rows.Count == 1)
                            {
                                int adet = Convert.ToInt32(dtable.Rows[0]["ADET"].ToString());
                                adet = adet + 1;
                                OleDbCommand komut3 = new OleDbCommand("UPDATE [normal$] SET ADET =" + adet + " WHERE BARKOD_NO=" + barkodnumarasi + "", baglan);
                                komut3.ExecuteNonQuery();
                            }
                            else if (dtable.Rows.Count == 0)
                            {
                                OleDbDataAdapter daa     = new OleDbDataAdapter("SELECT ADET FROM [indirimli$] WHERE BARKOD_NO=" + barkodnumarasi + "", baglan);
                                DataTable        dttable = new DataTable();
                                daa.Fill(dttable);
                                int adet = Convert.ToInt32(dttable.Rows[0]["ADET"].ToString());
                                adet = adet + 1;
                                OleDbCommand komut3 = new OleDbCommand("UPDATE [indirimli$] SET ADET =" + adet + " WHERE BARKOD_NO=" + barkodnumarasi + "", baglan);
                                komut3.ExecuteNonQuery();
                            }
                        }
                        MessageBox.Show("Başarılı");
                        this.Hide();
                        yeniSatisform              = new satis();
                        yeniSatisform.FormClosing += yeniSatisform_FormClosing;
                        yeniSatisform.ShowDialog();
                    }
                    catch (Exception hata)
                    {
                        MessageBox.Show("Kayıt edilmedi" + hata.Message);
                    }
                    finally
                    {
                        baglan.Close();
                    }
                }
                else
                {
                    MessageBox.Show("ÖDEME ŞEKLİ BOŞ OLAMAZ", "ÖDEME ŞEKLİ");
                }
            }
        }