Пример #1
0
        protected void DeleteItem_Command(object sender, CommandEventArgs e)
        {
            if (Cache["UserId"] is int)
            {
                int itemid = int.Parse(e.CommandArgument.ToString());
                int userid = int.Parse(Cache["UserId"].ToString());

                if (ItemLogic.DeleteItemFromUserInv(userid, itemid))
                {
                    // Success in deleting
                    OutComeLbl.Text        = "Successful Delete of Item";
                    WarningLbl.Visible     = false;
                    WarningMessageLbl.Text = "Item Deleted from user inventory.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "UserInvenModal", "ShowPopUp();", true);
                    Response.Redirect("UserInventory.aspx", true);
                }
                else
                {
                    OutComeLbl.Text        = "Delete Error";
                    WarningMessageLbl.Text = "Item cannot be deleted from user's inventory as part is used in machine";
                    // Part in used cannot delete
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "UserInvenModal", "ShowPopUp();", true);
                }
            }
            else
            {
                Response.Redirect("UserInventory.aspx", true);
            }
        }
Пример #2
0
 protected void CfmSellBtn_Click(object sender, EventArgs e)
 {
     if (Cache["ItemIDToSell"] is int)
     {
         if (ItemLogic.DeleteItemFromUserInv(CurrentUser.Entity().UserID, (int)Cache["ItemIDToSell"]))
         {
             using (DataContext db = new DataContext())
             {
                 Users u = CurrentUser.Entity(false, db);
                 u.Coins = u.Coins + int.Parse(Cache["PriceToSell"].ToString());
                 db.SaveChanges();
             }
             Response.Redirect("Parts.aspx", true);
         }
         else
         {
             // need to pop up something
         }
     }
 }