public static int AddItemss(ItemDetail objItemdetail)
 {
     if (objItemdetail.Tags != "")
     {
         int Result=0;
         var temp=objItemdetail.Tags.Split(',');
         for (int i = 0; i < temp.Length; i++)
         {
             if (temp[i].IndexOf("✓") != -1)
             {
                 Result = AddItemTagData(temp[i].Replace("✓", ""), temp[i].Replace("✓", "").Replace(" ", "_").ToLower());
                 objItemdetail.Tags = objItemdetail.Tags.Replace(temp[i], temp[i].Replace("✓", "").Replace(" ", "_").ToLower());
             }
         }
     }
     return AddItems(objItemdetail);
 }
 public static int AddItems(ItemDetail objItemDetail)
 {
     string strConnectionStrings = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
     SqlParameter[] oParam = new SqlParameter[10];
     oParam[0] = DBHelper.GetParam("@Id", SqlDbType.BigInt, 8, ParameterDirection.Input, objItemDetail.ItemID);
     oParam[1] = DBHelper.GetParam("@Vendors", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.VendorAlias);
     oParam[2] = DBHelper.GetParam("@ItemCategory", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.CategotyAlias);
     oParam[3] = DBHelper.GetParam("@Name", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.ItemName);
     oParam[4] = DBHelper.GetParam("@Alias", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.UrlAlias);
     oParam[5] = DBHelper.GetParam("@Desc", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.Description);
     oParam[6] = DBHelper.GetParam("@Price", SqlDbType.BigInt, 4, ParameterDirection.Input, objItemDetail.Price);
     oParam[7] = DBHelper.GetParam("@Tags", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.Tags);
     oParam[8] = DBHelper.GetParam("@IsRecommended", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.IsRecommendItem?1:0);
     oParam[9] = DBHelper.GetParam("@ImageUrl", SqlDbType.VarChar, 100, ParameterDirection.Input, objItemDetail.ItemImageUrl);
     SqlHelper.ExecuteNonQuery(strConnectionStrings, CommandType.StoredProcedure, "USP_AddUpdateItems", oParam);
     return 1;
 }
        public static ItemDetail GetItemData(int ItemId)
        {
            string imagefolder = "/img/";

            ItemDetail objItemDetail = new ItemDetail();
            Items objItem = new Items();
            DataTable objmainDT = new DataTable();
            DataRow[] objMainRow = null;
            if (ItemId != 0)
            {
                objmainDT = (DataTable)HttpContext.Current.Session["ItemData"];
                objMainRow = objmainDT.Select("menu_id_generator='" + ItemId + "'");
            }

            DataTable dtVendors = new DataTable();
            dtVendors = SQL.BLL.GetVendorsList(1, 1000, "", "id", 1);
            DataRow newRowVendor = dtVendors.NewRow();
            newRowVendor["id_vendors_generator"] = "-1";
            newRowVendor["nama_vendors"] = "-Select Vendor-";
            dtVendors.Rows.InsertAt(newRowVendor, 0);
            dtVendors.AcceptChanges();
            objItemDetail.Vendor = new CommonObjects[dtVendors.Rows.Count];
            int intCount = 0;
            foreach (DataRow drw in dtVendors.Rows)
            {
                objItemDetail.Vendor[intCount] = new CommonObjects();
                objItemDetail.Vendor[intCount].Value = drw["id_vendors_generator"].ToString();
                objItemDetail.Vendor[intCount].Text = drw["nama_vendors"].ToString();
                objItemDetail.Vendor[intCount].DefaultValue = ItemId != 0 ? objMainRow[0]["alias_vendors"].ToString() : objItemDetail.Vendor[0].Value;
                intCount++;
            }

            DataTable dtItemCategory = new DataTable();
            dtItemCategory = SQL.BLL.GetCategoryList(1, 1000, "", "id", 1);
            DataRow newItemCategory = dtItemCategory.NewRow();
            newItemCategory["Alias"] = "-1";
            newItemCategory["Category"] = "-Category-";
            dtItemCategory.Rows.InsertAt(newItemCategory, 0);
            dtItemCategory.AcceptChanges();
            objItemDetail.Categoty = new CommonObjects[dtItemCategory.Rows.Count];
            intCount = 0;
            foreach (DataRow drw in dtItemCategory.Rows)
            {
                objItemDetail.Categoty[intCount] = new CommonObjects();
                objItemDetail.Categoty[intCount].Value = drw["Alias"].ToString();
                objItemDetail.Categoty[intCount].Text = drw["Category"].ToString();
                objItemDetail.Categoty[intCount].DefaultValue = ItemId != 0 ? objMainRow[0]["Category"].ToString() : objItemDetail.Categoty[0].Value;
                intCount++;
            }

            int Price;
            bool IsRecommendItem;

            objItemDetail.ItemName = ItemId != 0 ? objMainRow[0]["nama_menu"].ToString() : "";
            objItemDetail.UrlAlias = ItemId != 0 ? objMainRow[0]["alias_menu"].ToString() : "";
            objItemDetail.Description = ItemId != 0 ? objMainRow[0]["deskripsi_menu"].ToString() : "";
            if (ItemId != 0)
            {
                int.TryParse(Convert.ToString(objMainRow[0]["harga_menu"]), out Price);
                objItemDetail.Price = Price;
            }

            objItemDetail.Tags = ItemId != 0 ? objMainRow[0]["tags"].ToString() : "";

            if (ItemId != 0)
            {
                bool.TryParse(Convert.ToString(objMainRow[0]["is_recommended"]), out IsRecommendItem);
                objItemDetail.IsRecommendItem = IsRecommendItem;
            }

            objItemDetail.ItemImageUrl = ItemId != 0 ? imagefolder + objMainRow[0]["media_photo"].ToString() : "";

            DataTable dt = objItem.GetTags();
            string tags = "";
            foreach (DataRow dr in dt.Rows)
            {
                if (tags == "")
                {
                    if (ItemId != 0 && objMainRow[0]["tags"].ToString().IndexOf(dr["alias"].ToString()) != -1)
                    {
                        tags = dr["alias"].ToString() + "✓" + "^" + dr["nama_tag"].ToString();
                    }
                    else
                    {
                        tags = dr["alias"].ToString() + "^" + dr["nama_tag"].ToString();
                    }

                }
                else
                {
                    if (ItemId != 0 && objMainRow[0]["tags"].ToString().IndexOf(dr["alias"].ToString()) != -1)
                    {
                        tags += "," + dr["alias"].ToString() + "✓" + "^" + dr["nama_tag"].ToString();
                    }
                    else
                    {
                        tags += "," + dr["alias"].ToString() + "^" + dr["nama_tag"].ToString();
                    }
                }
            }
            objItemDetail.Tags = tags;

            return objItemDetail;
        }