Example #1
0
        internal string GetCategory(AltKategori a)
        {
            int    categoryId = 0;
            string category   = "";

            Connect();
            command = new SqlCommand("SELECT Kategori_id FROM tbl_AltKategori WHERE AltKategori_ID=" + a.Id + " ", connection);
            command.ExecuteNonQuery();
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                categoryId = Convert.ToInt16(reader["Kategori_id"]);
            }
            reader.Close();
            command = new SqlCommand("SELECT Kategori_Ad FROM tbl_Kategori WHERE Kategori_ID=" + categoryId + "", connection);
            command.ExecuteNonQuery();
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                category = reader["Kategori_Ad"].ToString();
            }
            reader.Close();
            reader.Dispose();
            connection.Close();
            connection.Dispose();
            return(category);
        }
Example #2
0
        protected void DropDownListCategorySelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            AltKategori a = new AltKategori();

            a.KategoriId.Id = Convert.ToInt16(DropDownListCategorySelect.SelectedItem.Value);
            AltKategoriDb db = new AltKategoriDb();

            DropDownListSubCategoryDelete.DataSource     = db.GetSubCategory(a);
            DropDownListSubCategoryDelete.DataTextField  = "AltKategori_Ad";
            DropDownListSubCategoryDelete.DataValueField = "AltKategori_ID";
            DropDownListSubCategoryDelete.DataBind();
        }
Example #3
0
 internal object GetSubCategory(AltKategori a)
 {
     Connect();
     command = new SqlCommand("SELECT * FROM tbl_AltKategori WHERE Kategori_id=" + a.KategoriId.Id + "", connection);
     command.ExecuteNonQuery();
     table   = new DataTable();
     adaptor = new SqlDataAdapter(command);
     adaptor.Fill(table);
     connection.Close();
     connection.Dispose();
     return(table);
 }
Example #4
0
        internal string GetSubCategoryName(AltKategori a)
        {
            string subCategory = "";

            Connect();
            command = new SqlCommand("SELECT * FROM tbl_AltKategori WHERE AltKategori_ID = " + a.Id + "", connection);
            command.ExecuteNonQuery();
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                subCategory = reader["AltKategori_Ad"].ToString();
            }
            reader.Close();
            reader.Dispose();
            connection.Close();
            connection.Dispose();
            return(subCategory);
        }
Example #5
0
        protected void btnSubCategoryDelete_Click(object sender, EventArgs e)
        {
            Label_SubCategoriesDeleteError.Text = "";
            AltKategori a = new AltKategori();

            a.Id = Convert.ToInt16(DropDownListSubCategoryDelete.SelectedItem.Value);
            AltKategoriDb db = new AltKategoriDb();

            try
            {
                db.Delete(a);
            }
            catch (Exception hata)
            {
                Label_SubCategoriesDeleteError.Visible = true;
                Label_SubCategoriesDeleteError.Text    = hata.Message;
            }
            Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }
Example #6
0
        public override void Delete(IEntity entity)
        {
            AltKategori a = (AltKategori)entity;

            Connect();
            command             = new SqlCommand("sp_AltKategoriDelete", connection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@AltKategoriId", a.Id);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (SqlException hata)
            {
                throw new Exception(hata.Message);
            }
            connection.Close();
            connection.Dispose();
        }
Example #7
0
        protected void btnSubCategoryAdd_Click(object sender, EventArgs e)
        {
            Label_SubCategoryError.Text = "";
            AltKategori a = new AltKategori();

            a.Ad            = txtAltKategori.Text;
            a.KategoriId.Id = Convert.ToInt16(DropDownListCategoryforSubCategory.SelectedItem.Value);
            AltKategoriDb db = new AltKategoriDb();

            try
            {
                db.Insert(a);
            }
            catch (Exception hata)
            {
                Label_SubCategoryError.Visible = true;
                Label_SubCategoryError.Text    = hata.Message.ToString();
            }
            txtAltKategori.Text = "";
            Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }
Example #8
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Label_SearchNotFound.Text = "";
            Urun u = new Urun();

            u.Barkod = search = Request.Params["search"] != null ? Request.Params["search"].ToString() : String.Empty;
            UrunDb db          = new UrunDb();
            int    subCategory = 0,
                   category    = 0,
                   personelID  = 0,
                   counter     = 0;

            db.Connect();
            db.command = new SqlCommand("SELECT	* FROM tbl_Urun WHERE	Urun_Barkod LIKE @barcode", db.connection);
            db.command.Parameters.AddWithValue("@barcode", u.Barkod);
            db.command.ExecuteNonQuery();
            db.reader = db.command.ExecuteReader();
            while (db.reader.Read())
            {
                txtCost.Text     = Convert.ToSingle(db.reader["Urun_Fiyat"]).ToString();
                txtStock.Text    = db.reader["Urun_Stok"].ToString();
                txtUrunAd.Text   = db.reader["Urun_Ad"].ToString();
                txtBarkod.Text   = search;
                txtFeatures.Text = db.reader["Urun_Ozellikleri"].ToString();
                subCategory      = Convert.ToInt16(db.reader["AltKategori_id"]);
                personelID       = Convert.ToInt16(db.reader["Personel_id"]);
                counter++;
            }
            db.reader.Close();
            if (counter == 0)
            {
                Label_SearchNotFound.Visible = true;
                Label_SearchNotFound.Text    = "Aradığınız ürün bulunamadı!";
            }
            else
            {
                db.command = new SqlCommand("SELECT * FROM tbl_AltKategori WHERE AltKategori_ID=@subCategory", db.connection);
                db.command.Parameters.AddWithValue("@subCategory", subCategory);
                db.command.ExecuteNonQuery();
                db.reader = db.command.ExecuteReader();
                while (db.reader.Read())
                {
                    category = Convert.ToInt16(db.reader["Kategori_id"]);
                }
                db.reader.Close();
                db.connection.Close();
                db.connection.Dispose();

                Kategori k = new Kategori();
                k.Id = category;
                KategoriDb kdb = new KategoriDb();
                Label_CurrentCategory.Text    = "";
                Label_CurrentCategory.Visible = true;
                Label_CurrentCategory.Text    = kdb.GetCategoryName(k);

                AltKategori ak = new AltKategori();
                ak.Id = subCategory;
                AltKategoriDb akdb = new AltKategoriDb();
                Label_CurrentSubCategory.Text    = "";
                Label_CurrentSubCategory.Visible = true;
                Label_CurrentSubCategory.Text    = akdb.GetSubCategoryName(ak);
                ShowCategory();
                txtBarkod.Enabled = false;
            }
        }