public static int Update(EFirma eFirma)
        {
            SqlCommand sqlCommand   = null;
            int        degistirilen = 0;

            try
            {
                sqlCommand             = new SqlCommand("Firma_Guncelle", Baglan.Con);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                if (sqlCommand.Connection.State != ConnectionState.Open)
                {
                    sqlCommand.Connection.Open();
                }
                sqlCommand.Parameters.AddWithValue("firmaId", eFirma.firmaId);
                sqlCommand.Parameters.AddWithValue("firmaAdi", eFirma.firmaAdi);



                degistirilen = sqlCommand.ExecuteNonQuery();
                MessageBox.Show("Firma güncelleme başarılı");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                degistirilen = -1;
            }
            finally
            {
                sqlCommand.Connection.Close();
            }
            return(degistirilen);
        }
Beispiel #2
0
 public static int Update(EFirma eFirma)
 {
     if (eFirma.firmaAdi != null && eFirma.firmaAdi.Trim().Length > 0)
     {
         return(FFirma.Update(eFirma));
     }
     return(-1);
 }
Beispiel #3
0
 public static int Insert(EFirma eFirma)
 {
     if (eFirma.firmaAdi.Trim().Length > 0)
     {
         return(FFirma.Insert(eFirma));
     }
     return(-1);
 }
Beispiel #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            EFirma eFirma = new EFirma();

            if (textBox1.Text != null && textBox1.Text.Trim().Length > 0)
            {
                eFirma.firmaAdi = textBox1.Text;
                BFirma.Insert(eFirma);
            }
            else
            {
                MessageBox.Show("TextBox'a firma adı girin! ");
            }
        }
        public static List <EFirma> ButunFirmalar()
        {
            List <EFirma> firma      = null;
            SqlCommand    sqlCommand = null;

            try
            {
                sqlCommand             = new SqlCommand("Firmalari_Getir", Baglan.Con);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                if (sqlCommand.Connection.State != ConnectionState.Open)
                {
                    sqlCommand.Connection.Open();
                }
                SqlDataReader rdr = sqlCommand.ExecuteReader();
                if (rdr.HasRows)
                {
                    firma = new List <EFirma>();
                    while (rdr.Read())
                    {
                        EFirma f = new EFirma();
                        f.firmaAdi = rdr["firmaAdi"].ToString();
                        f.firmaId  = Convert.ToInt32(rdr["firmaId"]);

                        firma.Add(f);
                    }
                }
                rdr.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                firma = null;
            }
            finally
            {
                sqlCommand.Connection.Close();
            }

            return(firma);
        }
        public static EFirma BirFirma(int Id)
        {
            EFirma     firma      = null;
            SqlCommand sqlCommand = null;

            try
            {
                sqlCommand             = new SqlCommand("Firma_Getir", Baglan.Con);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                if (sqlCommand.Connection.State != ConnectionState.Open)
                {
                    sqlCommand.Connection.Open();
                }
                sqlCommand.Parameters.AddWithValue("firmaId", Id);
                SqlDataReader rdr = sqlCommand.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        firma          = new EFirma();
                        firma.firmaAdi = rdr["firmaAdi"].ToString();
                    }
                }
                rdr.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                firma = null;
            }
            finally
            {
                sqlCommand.Connection.Close();
            }

            return(firma);
        }