Beispiel #1
0
        public bool BireyselKirala(cKira bk)
        {
            int a = 0;
            SqlConnection conn = new SqlConnection(cGenel.connStr);
            SqlCommand comm3 = new SqlCommand("select KiraDetayID from KiraDetay", conn);
            if (conn.State == ConnectionState.Closed) conn.Open();
            SqlDataReader dr;
            try
            {
                dr = comm3.ExecuteReader();
                while (dr.Read())
                {
                    a = Convert.ToInt32(dr[0]);
                }

            }
            catch (SqlException ex)
            {
                string hata = ex.Message;
            }
            conn.Close();
            a++;

            SqlCommand comm1 = new SqlCommand("Insert into KiraDetay (ToplamTutar,KiraDetayID) values(@ToplamTutar,@KiraDetayID)", conn);
            comm1.Parameters.Add("@ToplamTutar", SqlDbType.Int).Value = bk._tutar;
            comm1.Parameters.Add("@KiraDetayID", SqlDbType.Int).Value = a;
            if (conn.State == ConnectionState.Closed) conn.Open();
            comm1.ExecuteNonQuery();
            conn.Close();
            SqlCommand comm2 = new SqlCommand("select KiraDetayID from KiraDetay", conn);
            if (conn.State == ConnectionState.Closed) conn.Open();
            SqlDataReader dr1;
            try
            {
                dr1 = comm2.ExecuteReader();
                while (dr1.Read())
                {
                    bk._kiraDetayID = Convert.ToInt32(dr1[0]);
                }

            }
            catch (SqlException ex)
            {
                string hata = ex.Message;
            }
            conn.Close();

            SqlCommand comm = new SqlCommand("Insert into Kiralama (MusteriNo,AracNo,KirayaGidisTarihi,KiradanDonusTarihi,Tutar,KiraDetayID) values(@MusteriNo,@AracNo,@KirayaGidisTarihi,@KiradanDonusTarihi,@Tutar,@KiraDetayID)", conn);
            comm.Parameters.Add("@MusteriNo", SqlDbType.Int).Value = bk._musteriNo;
            comm.Parameters.Add("@AracNo", SqlDbType.Int).Value = bk._aracNo;
            comm.Parameters.Add("@KirayaGidisTarihi", SqlDbType.DateTime).Value = bk._kirayaGidisTarihi;
            comm.Parameters.Add("@KiradanDonusTarihi", SqlDbType.DateTime).Value = bk._kiradanDonusTarihi;
            comm.Parameters.Add("@Tutar", SqlDbType.Int).Value = bk._tutar;
            comm.Parameters.Add("@KiraDetayID", SqlDbType.Int).Value = bk._kiraDetayID;

            if (conn.State == ConnectionState.Closed) conn.Open();
            bool Sonuc = Convert.ToBoolean(comm.ExecuteNonQuery());
            conn.Close();
            return Sonuc;
        }
        private void dgvKiralama_DoubleClick(object sender, EventArgs e)
        {
            cArac a = new cArac();
            cKira b = new cKira();
            btnSonlandir.Enabled = true;

            if (rbBireysel.Checked == true)
            {

                a.AracGetirKiraSonlandir(dgvKiralama, a);
                txtAracID1.Text = a.AracID.ToString();

            }

            if (rbKurumsal.Checked == true)
            {
                int i = 1;
                List<cKira> list = new List<cKira>();
                b.AracDetayIDGetir(dgvKiralama, b);
                txtKiraDetayID.Text = b.KiraDetayID.ToString();
                list = b.KiralananGetirKurumsalByKiraDetayID(b);
                foreach (var item in list)
                {
                    if(i==1)
                    (txtAracID1).Text = item.AracNo.ToString();
                    if(i==2)
                    (txtAracID2).Text = item.AracNo.ToString();
                    if(i==3)
                    (txtAracID3).Text = item.AracNo.ToString();

                    i++;
                }
            }
        }
        private void btnSonlandir_Click(object sender, EventArgs e)
        {
            cArac a = new cArac();
            cKira b = new cKira();

            if (rbBireysel.Checked == true)
            {
                a.AracGuncelleKiralanabilir(a.AracID);
            }
            else if (rbKurumsal.Checked == true)
            {
                a.AracGuncelleKiralanabilir(Convert.ToInt32(txtAracID1.Text));
                if (txtAracID2.Text != "")
                {
                    a.AracGuncelleKiralanabilir(Convert.ToInt32(txtAracID2.Text));
                }
                if (txtAracID3.Text != "")
                {
                    a.AracGuncelleKiralanabilir(Convert.ToInt32(txtAracID3.Text));
                }
            }
        }
Beispiel #4
0
 public void AracDetayIDGetir(DataGridView dgv, cKira k)
 {
     k._kiraDetayID = Convert.ToInt32(dgv.SelectedRows[0].Cells[7].Value);
 }
Beispiel #5
0
        public void KurumsalKirala(cKira kk)
        {
            SqlConnection conn = new SqlConnection(cGenel.connStr);
            SqlCommand comm1 = new SqlCommand("Insert into KiraDetay (ToplamTutar,KiraDetayID) values(@ToplamTutar,@KiraDetayID)", conn);

            comm1.Parameters.Add("@ToplamTutar", SqlDbType.Int).Value = kk._tutar;
            comm1.Parameters.Add("@KiraDetayID", SqlDbType.Int).Value = cGenel.KiraDetayKurumsal;

            if (conn.State == ConnectionState.Closed) conn.Open();
            comm1.ExecuteNonQuery();
            conn.Close();

            SqlCommand comm2 = new SqlCommand();

            comm2.Connection = conn;
            comm2.CommandText = "Insert into Kiralama (FirmaNo,AracNo,KirayaGidisTarihi,KiradanDonusTarihi,Tutar,KiraDetayID) values (@FirmaNo,@AracNo,@KirayaGidisTarihi,@KiradanDonusTarihi,@Tutar,@KiraDetayID)";

            comm2.Parameters.Add("@FirmaNo", SqlDbType.Int).Value = kk._firmaNo;
            comm2.Parameters.Add("@AracNo", SqlDbType.Int).Value = kk._aracNo;
            comm2.Parameters.Add("@KirayaGidisTarihi", SqlDbType.DateTime).Value = kk._kirayaGidisTarihi;
            comm2.Parameters.Add("@KiradanDonusTarihi", SqlDbType.DateTime).Value = kk._kiradanDonusTarihi;
            comm2.Parameters.Add("@Tutar", SqlDbType.Int).Value = kk._tutar;
            comm2.Parameters.Add("@KiraDetayID", SqlDbType.Int).Value = cGenel.KiraDetayKurumsal;
            if (conn.State == ConnectionState.Closed) conn.Open();
            comm2.ExecuteNonQuery();
            conn.Close();
        }
Beispiel #6
0
        public List<cKira> KiralananGetirKurumsalByKiraDetayID(cKira k)
        {
            List<cKira> list = new List<cKira>();
            SqlConnection conn = new SqlConnection(cGenel.connStr);
            SqlCommand comm = new SqlCommand("Select * from Kiralama where KiraDetayID=@KiraDetayID and FirmaNo not like 'NULL'", conn);
            comm.Parameters.Add("@KiraDetayID", SqlDbType.Int).Value = k._kiraDetayID;
            if (conn.State == ConnectionState.Closed) conn.Open();
            SqlDataReader dr;
            try
            {
                dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    cKira a = new cKira();
                    a._aracNo = Convert.ToInt32(dr["AracNo"]);
                    list.Add(a);
                }

            }
            catch (SqlException ex)
            {
                string hata = ex.Message;
            }
            return list;
        }
Beispiel #7
0
        public List<cKira> KiralananGetirKurumsal()
        {
            List<cKira> list = new List<cKira>();
            SqlConnection conn = new SqlConnection(cGenel.connStr);
            SqlCommand comm = new SqlCommand("Select * from Kiralama where Silindi=0 and FirmaNo not like 'NULL'", conn);
            if (conn.State == ConnectionState.Closed) conn.Open();
            SqlDataReader dr;
            try
            {
                dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    cKira a = new cKira();
                    a._kiraID = Convert.ToInt32(dr["KiraID"]);
                    a._firmaNo = Convert.ToInt32(dr["FirmaNo"]);
                    a._aracNo = Convert.ToInt32(dr["AracNo"]);
                    a._kirayaGidisTarihi = Convert.ToDateTime(dr["KirayaGidisTarihi"]);
                    a._kiradanDonusTarihi = Convert.ToDateTime(dr["KiradanDonusTarihi"]);
                    a._tutar = Convert.ToInt32(dr["Tutar"]);
                    a._kiraDetayID = Convert.ToInt32(dr["KiraDetayID"]);
                    list.Add(a);
                }
                for (int i = 0; i < cGenel.AracEkle; i++)
                {

                }

            }
            catch (SqlException ex)
            {
                string hata = ex.Message;
            }
            return list;
        }
 private void rbBireysel_CheckedChanged(object sender, EventArgs e)
 {
     if (rbBireysel.Checked == true)
     {
         cKira k = new cKira();
         dgvKiralama.DataSource = k.KiralananGetirBireysel();
         dgvKiralama.Columns["FirmaNo"].Visible = false;
         dgvKiralama.Columns["MusteriNo"].Visible = true;
     }
 }
 private void rbKurumsal_CheckedChanged(object sender, EventArgs e)
 {
     if (rbKurumsal.Checked == true)
     {
         cKira k = new cKira();
         List<cKira> list = new List<cKira>();
         list= k.KiralananGetirKurumsal();
         dgvKiralama.DataSource = list;
         dgvKiralama.Columns["MusteriNo"].Visible = false;
         dgvKiralama.Columns["FirmaNo"].Visible = true;
     }
 }
        private void btnKirala_Click(object sender, EventArgs e)
        {
            cArac a = new cArac();
            if (cbMusteriTipi.SelectedIndex == 0)
            {
                cKira k = new cKira();
                List<cArac> list1 = new List<cArac>();
                list1 = a.AraclariGetirByAracID(Convert.ToInt32(txtAracID.Text), a);

                foreach (var item in list1)
                {
                    lvAraclar.Items.Add(txtAracID.Text);
                    lvAraclar.Items[i].SubItems.Add(a.Marka);
                    lvAraclar.Items[i].SubItems.Add(a.Model);
                    lvAraclar.Items[i].SubItems.Add(a.Yil.ToString());
                    lvAraclar.Items[i].SubItems.Add(a.GunlukUcret.ToString());
                    lvAraclar.Items[i].SubItems.Add(a.Km.ToString());
                    lvAraclar.Items[i].SubItems.Add(txtGidis.Text);
                    lvAraclar.Items[i].SubItems.Add(txtDonus.Text);
                    lvAraclar.Items[i].SubItems.Add(txtTutar.Text);
                    i++;
                }

                try
                {
                    k.MusteriNo = Convert.ToInt32(txtMusteriID.Text);
                    k.AracNo = Convert.ToInt32(txtAracID.Text);
                    k.KirayaGidisTarihi = Convert.ToDateTime(txtGidis.Text);
                    k.KiradanDonusTarihi = Convert.ToDateTime(txtDonus.Text);
                    k.KiraDetayID = cGenel.KiraDetayKurumsal - 1;
                    k.Tutar = Convert.ToInt32(txtTutar.Text);

                    k.BireyselKirala(k);
                    a.AracGuncelleKiralanamaz(k.AracNo);
                    dgvKiralama.DataSource = k.KiralananGetirBireysel();
                    dgvKiralama.Columns["FirmaNo"].Visible = false;
                    MessageBox.Show("Kiralama Bilgileri Kayıt Edildi.");
                    if (MessageBox.Show(txtMusteriAd.Text + " adlı/ünvanlı müşteri için fatura dökümü istiyor musunuz?", "FATURA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        Yazdir();
                    }
                    else this.Close();
                }
                catch (Exception)
                {

                    frmAracKiralama.ActiveForm.Activate();
                    MessageBox.Show("Eksik Bilgi Var, Tekrar Kontrol Edin ");
                    btnYazdir.Enabled = false;
                }

            }
            else if (cbMusteriTipi.SelectedIndex == 1)
            {
                cGenel.KiraDetayKurumsal = k.KiraDetayIDGetir();
                try
                {
                    for (int i = 0; i < lvAraclar.Items.Count; i++)
                    {
                        k.FirmaNo = Convert.ToInt32(txtMusteriID.Text);
                        k.AracNo = Convert.ToInt32(lvAraclar.Items[i].Text);
                        k.KirayaGidisTarihi = Convert.ToDateTime(lvAraclar.Items[i].SubItems[6].Text);
                        k.KiradanDonusTarihi = Convert.ToDateTime(lvAraclar.Items[i].SubItems[7].Text);
                        k.Tutar = Convert.ToInt32(lvAraclar.Items[i].SubItems[8].Text);
                        k.KiraDetayID = cGenel.KiraDetayKurumsal;
                        k.KurumsalKirala(k);
                        a.AracGuncelleKiralanamaz(k.AracNo);
                    }

                    dgvKiralama.DataSource = k.KiralananGetirKurumsal();
                    dgvKiralama.Columns["MusteriNo"].Visible = false;
                    MessageBox.Show("Kiralama Bilgileri Kayıt Edildi.");
                    if (MessageBox.Show(txtMusteriAd.Text + " adlı/ünvanlı müşteri için fatura dökümü istiyor musunuz?", "FATURA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        Yazdir();
                    }
                    else this.Close();
                }
                catch (Exception)
                {
                    frmAracKiralama.ActiveForm.Activate();
                    MessageBox.Show("Eksik Bilgi Var, Tekrar Kontrol Edin ");
                    btnYazdir.Enabled = false;
                }
            }

            cGenel.aracid[1] = 0;
            cGenel.aracid[2] = 0;
            cGenel.aracid[3] = 0;
            cGenel.aracid[4] = 0;
            cGenel.aracid[5] = 0;
            cGenel.aracid[6] = 0;
        }