Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            sinifsatis                  = new SinifSatis();
            sinifsatis.msatis           = new ModelSatis();
            sinifsatis.msatis.MusteriId = "";
            sinifsatis.msatis.FirmaId   = "";
            if (radioButton1.Checked == true)
            {
                sinifsatis.msatis.FirmaId = comboBox1.SelectedValue.ToString();
                //cbi = (ComboBoxItem)comboBox1.SelectedItem;
                //sinifsatis.msatis.FirmaId = cbi.Value.ToString();
            }
            else
            {
                sinifsatis.msatis.FirmaId = "0";
            }

            if (radioButton2.Checked == true)
            {
                sinifsatis.msatis.MusteriId = comboBox1.SelectedValue.ToString();
                //cbi = (ComboBoxItem)comboBox1.SelectedItem;
                //sinifsatis.msatis.MusteriId = cbi.Value.ToString();
            }
            else
            {
                sinifsatis.msatis.MusteriId = "0";
            }
            cbi = (ComboBoxItem)comboBox2.SelectedItem;
            sinifsatis.msatis.UrunId = cbi.Value.ToString();

            sinifsatis.msatis.Tarih    = dateTimePicker1.Value.ToString("dd/MM/yyyy");
            sinifsatis.msatis.Adet     = txtAdet.Text;
            sinifsatis.msatis.Tutar    = textBox1.Text = Convert.ToString(double.Parse(sinifsatis.msatis.Adet) * birimfiyat);
            sinifsatis.msatis.Aciklama = richTextBox1.Text;

            if (txtKontrol())
            {
                MessageBox.Show("Alanları Doldurunuz");
                return;
            }


            if (button1.Text == "GÜNCELLE")
            {
                sinifsatis.msatis.SatisId = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                sinifsatis.Guncelle();
                MessageBox.Show("Satışınız Guncellenmiştir");
                new AracSatis().SatisDataGrid(dataGridView1);
                groupBox1.Text = "PERSONEL EKLE";
                button1.Text   = "KAYDET";
                Temizle();
            }
            else
            {
                sinifsatis.Ekle();
            }
            new AracSatis().SatisDataGrid(dataGridView1);
            Temizle();
        }
Example #2
0
        private void dataGridView1_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            sinifsatis = new SinifSatis();
            if (e.ColumnIndex == dataGridView1.Columns.Count - 1)
            {
                sinifsatis.msatis         = new ModelSatis();
                sinifsatis.msatis.SatisId = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                if (sinifsatis.Sil())
                {
                    MessageBox.Show("Satışınız Silinmiştir");
                    new AracSatis().SatisDataGrid(dataGridView1);
                }
            }
            else if (e.ColumnIndex == dataGridView1.Columns.Count - 2)
            {
                sinifsatis.msatis         = new ModelSatis();
                sinifsatis.msatis.SatisId = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                sinifsatis.msatis.UrunId  = dataGridView1.CurrentRow.Cells[1].Value.ToString();


                sinifsatis.msatis.Adet      = txtAdet.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
                sinifsatis.msatis.Tutar     = textBox1.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
                sinifsatis.msatis.Aciklama  = richTextBox1.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
                sinifsatis.msatis.MusteriId = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                sinifsatis.msatis.FirmaId   = dataGridView1.CurrentRow.Cells[3].Value.ToString();
                if (sinifsatis.msatis.MusteriId == "0")
                {
                    radioButton1.Enabled = true;
                    radioButton2.Checked = false;
                    radioButton2.Enabled = false;
                    radioButton1.Checked = true;
                }
                else if (sinifsatis.msatis.FirmaId == "0")
                {
                    radioButton2.Enabled = true;
                    radioButton2.Checked = true;
                    radioButton1.Checked = false;
                    radioButton1.Enabled = false;
                }

                for (int i = 0; i < comboBox2.Items.Count; i++)
                {
                    cbi = (ComboBoxItem)comboBox2.Items[i];
                    if (cbi.Value.ToString() == sinifsatis.msatis.UrunId)
                    {
                        comboBox2.SelectedIndex = i;
                    }
                }
                comboBox2.Enabled = false;
                comboBox1.Enabled = false;
                button1.Text      = "GÜNCELLE";
                groupBox1.Text    = "SATIŞ GÜNCELLE";
            }
        }