public int getirKullanicilarID(Entities.KULLANICILAR kullanicilar)
        {
            SqlConnection cnn = new SqlConnection();

            cnn.ConnectionString = Settings.connectionString;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cnn;
            cmd.CommandText = "select KullanicilarID from KULLANICILAR where KullaniciAdi=@KullaniciAdi and Sifre=@Sifre";
            cmd.Parameters.Add("@KullaniciAdi", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@Sifre", SqlDbType.VarChar, 50);

            cmd.Parameters["@KullaniciAdi"].Value = kullanicilar.KullaniciAdi;
            cmd.Parameters["@Sifre"].Value        = kullanicilar.Sifre;

            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }

            int a = Convert.ToInt32(cmd.ExecuteScalar());//Sorgudan dönen değeri alır

            if (cnn.State == ConnectionState.Open)
            {
                cnn.Close();
            }

            return(a);
        }
예제 #2
0
        private void btnGiris_Click(object sender, EventArgs e)
        {
            DataLogic.KULLANICILAR kullanicilar = new DataLogic.KULLANICILAR();
            Entities.KULLANICILAR  d            = new Entities.KULLANICILAR();

            d.KullaniciAdi = textBox1.Text;
            d.Sifre        = textBox2.Text;

            int a = -1;

            a = kullanicilar.getirKullanicilarID(d);

            if (a == 0)
            {
                MessageBox.Show("Kullanıcı adı veya şifre yanlış.", "Satış Programı", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                AnaEkran f = new AnaEkran();
                f.kullaniciAdi = textBox1.Text;
                f.sorumluID    = a;
                f.Show();
                this.Hide();
                //MessageBox.Show("Başarılı.", "Satış Programı", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            DataLogic.KULLANICILAR kullanicilar = new DataLogic.KULLANICILAR();
            Entities.KULLANICILAR  d            = new Entities.KULLANICILAR();

            d.AdSoyad      = textBox1.Text;
            d.KullaniciAdi = textBox2.Text;
            d.Sifre        = textBox3.Text;

            if (comboBox1.SelectedIndex == 0)
            {
                d.KullaniciTuru = true;
            }
            else
            {
                d.KullaniciTuru = false;
            }

            int a = -1;

            if (textBoxID.Text != "") //ID nin tutulduğu textBox
            {
                d.KullanicilarID = Convert.ToInt32(textBoxID.Text);
                a = kullanicilar.guncelleKullanicilar(d);
            }
            else
            {
                a = kullanicilar.kaydetKullanicilar(d);
            }

            if (a == 2 || a == 3)
            {
                MessageBox.Show("İşleminiz Gerçekleştirildi", "Satış Programı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                temizle();
            }
            else
            {
                MessageBox.Show("İşleminiz Yapılamadı", "Satış Programı", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            tabloyuDoldur();
        }
        public int kaydetKullanicilar(Entities.KULLANICILAR kullanicilar)
        {
            SqlConnection cnn = new SqlConnection();

            cnn.ConnectionString = Settings.connectionString;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = cnn;
            //cmd.CommandText = "INSERT INTO KULLANICILAR(KullaniciAdi,Sifre,AdSoyad, KullaniciTuru) values (@KullaniciAdi,@Sifre,@AdSoyad,@KullaniciTuru)";
            cmd.CommandText = "SP_KullaniciEkle";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@KullaniciAdi", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@Sifre", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@AdSoyad", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@KullaniciTuru", SqlDbType.Bit);

            cmd.Parameters["@KullaniciAdi"].Value  = kullanicilar.KullaniciAdi;
            cmd.Parameters["@Sifre"].Value         = kullanicilar.Sifre;
            cmd.Parameters["@AdSoyad"].Value       = kullanicilar.AdSoyad;
            cmd.Parameters["@KullaniciTuru"].Value = kullanicilar.KullaniciTuru;

            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }

            int a = cmd.ExecuteNonQuery();

            if (cnn.State == ConnectionState.Open)
            {
                cnn.Close();
            }

            return(a);
        }
        public int guncelleKullanicilar(Entities.KULLANICILAR kullanicilar)
        {
            SqlConnection cnn = new SqlConnection();

            cnn.ConnectionString = Settings.connectionString;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cnn;
            cmd.CommandText = "update KULLANICILAR set KullaniciAdi=@KullaniciAdi, Sifre=@Sifre, AdSoyad=@AdSoyad, KullaniciTuru=@KullaniciTuru where KullanicilarID=@ID";
            cmd.Parameters.Add("@KullaniciAdi", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@Sifre", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@AdSoyad", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@ID", SqlDbType.Int);
            cmd.Parameters.Add("@KullaniciTuru", SqlDbType.Bit);

            cmd.Parameters["@KullaniciAdi"].Value  = kullanicilar.KullaniciAdi;
            cmd.Parameters["@Sifre"].Value         = kullanicilar.Sifre;
            cmd.Parameters["@AdSoyad"].Value       = kullanicilar.AdSoyad;
            cmd.Parameters["@ID"].Value            = kullanicilar.KullanicilarID;
            cmd.Parameters["@KullaniciTuru"].Value = kullanicilar.KullaniciTuru;

            if (cnn.State == ConnectionState.Closed)
            {
                cnn.Open();
            }

            int a = cmd.ExecuteNonQuery();

            if (cnn.State == ConnectionState.Open)
            {
                cnn.Close();
            }

            return(a);
        }