public ItemsM GetPriceByItem(int Id)
        {
            ItemsM _Items = null;

            string query  = ("Select *From Items where Id='" + Id + "' ");
            var    reader = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                reader.Read();
                _Items       = new ItemsM();
                _Items.Price = Convert.ToDecimal(reader["Price"].ToString());
            }
            reader.Close();

            return(_Items);
        }
示例#2
0
        protected void ItemGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                ItemsM _ItemsM = new ItemsM();
                _ItemsM.Id = Convert.ToInt32(e.CommandArgument);

                int deletesuccess = _ItemRepository.Delete(_ItemsM);
                if (deletesuccess > 0)
                {
                    LoadItem();
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, MessageType.Error);
            }
        }
        public List <ItemsM> GetAllItemsByCategories(int id)
        {
            var    _ItemsList = new List <ItemsM>();
            string query      = ("Select *From Items where CategoriesId='" + id + "' ");
            var    reader     = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var _Items = new ItemsM();
                    _Items.Id   = Convert.ToInt32(reader["Id"].ToString());
                    _Items.Name = reader["Name"].ToString();

                    _ItemsList.Add(_Items);
                }
            }
            reader.Close();

            return(_ItemsList);
        }
示例#4
0
        protected void AddItemButton_Click(object sender, EventArgs e)
        {
            try
            {
                ItemsM _ItemsM = new ItemsM();
                _ItemsM.Name         = txtItemName.Text;
                _ItemsM.Price        = Convert.ToDecimal(txtPrice.Text);
                _ItemsM.CategoriesId = Convert.ToInt32(CategoriesDropDownList.SelectedValue);

                decimal AlreadyExistItem = _ItemRepository.AlreadyExistItem(_ItemsM);
                if (AlreadyExistItem >= 1)
                {
                    ShowMessage("This Item Already Here!!..This Category", MessageType.Warning);
                }
                else
                {
                    int savesuccess = _ItemRepository.Add(_ItemsM);
                    if (savesuccess > 0)
                    {
                        ShowMessage("Successfully Saved Item", MessageType.Success);
                        LoadItem();
                        txtItemName.Text = "";
                        txtPrice.Text    = "";
                        CategoriesDropDownList.ClearSelection();
                    }
                    else
                    {
                        ShowMessage("Failed Saving Item", MessageType.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, MessageType.Warning);
            }
        }
        public int Delete(ItemsM _Items)
        {
            string query = ("Delete From Items Where Id='" + _Items.Id + "'");

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
        public int Update(ItemsM _Items)
        {
            string query = "Update Items SET Name='" + _Items.Name + "',Price='" + _Items.Price + "' Where Id='" + _Items.Id + "' ";

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
        public int Add(ItemsM _Items)
        {
            string query = "Insert Into Items(Name,Price,CategoriesId) Values ('" + _Items.Name + "','" + _Items.Price + "','" + _Items.CategoriesId + "')";

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
        public decimal AlreadyExistItem(ItemsM _Items)
        {
            string query = "Select Count(*)from Items Where Name='" + _Items.Name + "' And Categoriesid='" + _Items.CategoriesId + "' ";

            return(_MainRepository.ExecuteScalar(query, _MainRepository.ConnectionString()));
        }