protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Login"] == null)
     {
         Response.Redirect("Login.aspx");
     }
     else
     {
         HelloLabel.Text = "Hi! " + Session["Login"].ToString();
     }
     if (!IsPostBack)
     {
         //Load Category Dropdownlist
         LoadCategoryList();
         //Load MerchantList
         int catid = Convert.ToInt32(CategoryDropDownList.SelectedValue);
         LoadMerchantList(catid);
         //Load Merchant Detail
         string cardid = MerchantDropDownList.SelectedValue;
         LoadMerchantDetails(cardid);
         //Load to Merchant Panel
         CardBO card = new CardBO();
         card = cardBUS.GetOneCard(cardid);
         MerchantImage.ImageUrl = card.Image;
         MechantDescriptionTextBox.Text = card.Description;
     }
 }
Esempio n. 2
0
 public void LoadCardInfo(string cardid)
 {
     CardBO cardBO = new CardBO();
     cardBO = cardBUS.GetOneCard(cardid);
     CardImage.ImageUrl = cardBO.Image;
     CardnameLabel.Text = cardBO.CardName;
     CardDesciptionTxt.Text = cardBO.Description;
     DiscountCardName.Text = cardBO.CardName;        
 }
 protected void CategoryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
      int catid = Convert.ToInt32(CategoryDropDownList.SelectedValue);
      LoadMerchantList(catid);
      if (MerchantDropDownList.Items.Count > 0)
      {
          MerchantDropDownList.SelectedIndex = 0;
          string cardid = MerchantDropDownList.SelectedValue;
          LoadMerchantDetails(cardid);
          CardBO card = new CardBO();
          card = cardBUS.GetOneCard(cardid);
          MerchantImage.ImageUrl = card.Image;
          MechantDescriptionTextBox.Text = card.Description;
      }
 }
Esempio n. 4
0
 public void LoadImage(ImageButton imagebutton, CardBO cardbo)
 {
     imagebutton.ImageUrl = cardbo.Image;
     imagebutton.PostBackUrl = "";
 }
Esempio n. 5
0
 public void LoadImage(ImageButton imagebutton,CardBO cardbo)
 {
     imagebutton.ImageUrl = cardbo.Image;
     imagebutton.PostBackUrl = "buy.aspx?cardid="+cardbo.CardID;
 }
 protected void MerchantDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
     string cardid = MerchantDropDownList.SelectedValue;
     LoadMerchantDetails(cardid);
     //Load to Merchant Panel
     CardBO card= new CardBO();
     card= cardBUS.GetOneCard(cardid);
     MerchantImage.ImageUrl = card.Image;
     MechantDescriptionTextBox.Text = card.Description;   
 }
Esempio n. 7
0
 public void Add(CardBO catBO)
 {
     List.Add(catBO);
 }
Esempio n. 8
0
 //////SELECT//////////      
 public CardBO SelectOneCard(string cardid)//Get ONE Card which has ID=cardID
 {
     CardBO cardBO = new CardBO();
     SqlCommand cmd = new SqlCommand("SELECT * FROM Card where cardid=@cardid", cnn);
     cmd.Parameters.AddWithValue("@cardid", cardid);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {                
         cardBO.CardID = dr["CardID"].ToString();
         cardBO.CatID = Convert.ToInt32(dr["CatID"].ToString());
         cardBO.CardName = dr["CardName"].ToString();
         cardBO.Description = dr["Description"].ToString();
         cardBO.Image = dr["Image"].ToString();
       
     }
     cnn.Close();
     return cardBO;
 }
Esempio n. 9
0
 ///////////////////////////////SELECT//////////////////////////////////////
 public CardCollection SelectMerchant(string cardID)
 {
     SqlCommand cmd = new SqlCommand("SELECT MerchantID,Card.CardID,CardName,Image,Value,[Save],Pay,Notes FROM Merchant INNER JOIN Card ON Merchant.CardID=Card.CardID WHERE Card.cardid=@cardid Order By CardName", cnn);
     cmd.Parameters.AddWithValue("@cardid", cardID);
     CardCollection cardColl = new CardCollection();
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {  
         CardBO cardBO = new CardBO();
         cardBO.Image = dr["Image"].ToString();
         cardBO.CardName = dr["CardName"].ToString();
         MerchantCollection MerchantColl = new MerchantCollection();
         MerchantBO merBO = new MerchantBO();
         merBO.MerchantID = dr["MerchantID"].ToString();
         merBO.Value = Convert.ToDecimal(dr["Value"].ToString());
         merBO.Pay = Convert.ToDecimal(dr["Pay"].ToString());
         merBO.Save = Convert.ToDecimal(dr["Save"].ToString());
         merBO.Notes = dr["Notes"].ToString();
         //Add to merchantColl
         MerchantColl.Add(merBO);
         //Assing Card.Detail = MerchantColl
         cardBO.Details = MerchantColl;
         //Add Card to cardColl
         cardColl.Add(cardBO);
     }
     cnn.Close();
     return cardColl;
 }
Esempio n. 10
0
 public CardCollection SelectOutOfStockMerchant(int catid)
 {
     CardCollection CardColl = new CardCollection();
     SqlCommand cmd = new SqlCommand("SELECT CardID,CardName AdID, CatID, CardName, Description, Image FROM Card  WHERE (CardID NOT IN (SELECT CardID FROM Merchant)) AND card.catid=@catid Order By CardName", cnn);
     cmd.Parameters.AddWithValue("@catid", catid);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         CardBO cardBO = new CardBO();
         cardBO.CardID = dr["CardID"].ToString();
         cardBO.CardName = dr["CardName"].ToString();
         cardBO.Image = dr["Image"].ToString();
         CardColl.Add(cardBO);
     }
     cnn.Close();
     return CardColl;
 }
Esempio n. 11
0
        /// <summary>
        /// //////////////////////for buy-cards.aspx////////////////////////////////////
        public CardCollection SelectDisCountMerchant(int catid)
        {
            CardCollection CardColl = new CardCollection();
            SqlCommand cmd = new SqlCommand("SELECT Card.CardID,CardName,Image, MAX(Merchant.[Save]) AS Save1,MerchantCount FROM Card INNER JOIN  Merchant ON Card.CardID = Merchant.CardID WHERE card.catid=@catid GROUP BY Card.CardID,Image,CardName,MerchantCount HAVING MerchantCount>0 Order By CardName", cnn);
            cmd.Parameters.AddWithValue("@catid", catid);
            cnn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                CardBO cardBO = new CardBO();
                MerchantCollection Mercoll = new MerchantCollection();
                MerchantBO merBO = new MerchantBO();
                cardBO.CardID = dr["CardID"].ToString();
                cardBO.CardName = dr["CardName"].ToString();
                cardBO.Image = dr["Image"].ToString();
                cardBO.MerchantCount = Convert.ToInt32(dr["merchantcount"].ToString());
                merBO.Save = Convert.ToDecimal(dr["Save1"].ToString());
                Mercoll.Add(merBO);
                cardBO.Details = Mercoll;
                CardColl.Add(cardBO);
            }
            cnn.Close();
            return CardColl;

        }
Esempio n. 12
0
 //////UPDATE//////////  
 public void UpdateCard(CardBO cardBO,bool hasimage)
 {
     SqlCommand cmd = null;
     if (hasimage == true)
     {
         cmd = new SqlCommand("UPDATE Card SET CatId=@Catid,CardName=@CardName,Description=@Description,Image=@Image WHERE CardID=@CardID", cnn);
         cmd.Parameters.AddWithValue("@Catid", cardBO.CatID);
         cmd.Parameters.AddWithValue("@CardName", cardBO.CardName);
         cmd.Parameters.AddWithValue("@Description", cardBO.Description);
         cmd.Parameters.AddWithValue("@Image", cardBO.Image);
         cmd.Parameters.AddWithValue("@CardID", cardBO.CardID);
     }
     else
     {
         cmd = new SqlCommand("UPDATE Card SET CatId=@Catid,CardName=@CardName,Description=@Description WHERE CardID=@CardID", cnn);
         cmd.Parameters.AddWithValue("@Catid", cardBO.CatID);
         cmd.Parameters.AddWithValue("@CardName", cardBO.CardName);
         cmd.Parameters.AddWithValue("@Description", cardBO.Description);            
         cmd.Parameters.AddWithValue("@CardID", cardBO.CardID);
     }
     cnn.Open();
     cmd.ExecuteNonQuery();
     cnn.Close();
     UpMerchantCount();
     UpCardCount();
 }
Esempio n. 13
0
 //////INSERT//////////      
 public void InsertCard(string adid,CardBO cardBO,bool hasimage)
 {
     SqlCommand cmd;
     if (hasimage == true)
     {
         cmd = new SqlCommand("INSERT INTO Card(CardID,AdID,CatId,CardName,Description,Image) VALUES(dbo.NewCardID(),@adid,@catid,@cardname,@description,@image)", cnn);
         cmd.Parameters.AddWithValue("@adid",adid );
         cmd.Parameters.AddWithValue("@catid", cardBO.CatID);
         cmd.Parameters.AddWithValue("@cardname", cardBO.CardName);
         cmd.Parameters.AddWithValue("@description", cardBO.Description);
         cmd.Parameters.AddWithValue("@image", cardBO.Image);
     }
     else
     {
         cmd = new SqlCommand("INSERT INTO Card(CardID,AdID,CatId,CardName,Description) VALUES(dbo.NewCardID(),@adid,@catid,@cardname,@description)", cnn);
         cmd.Parameters.AddWithValue("@adid", adid);
         cmd.Parameters.AddWithValue("@catid", cardBO.CatID);
         cmd.Parameters.AddWithValue("@cardname", cardBO.CardName);
         cmd.Parameters.AddWithValue("@description", cardBO.Description);               
     }
     cnn.Open();
     cmd.ExecuteNonQuery();
     cnn.Close();
     UpMerchantCount();
     UpCardCount();
 }
Esempio n. 14
0
 public CardCollection SelectRelatedCard(string cardid)
 {
     CardCollection CardColl = new CardCollection();
     string sql = "SELECT Card.CardID,CardName,Image, MAX(Merchant.[Save]) AS Save1,MerchantCount ";
     sql += "FROM Card LEFT OUTER JOIN  Merchant ON Card.CardID = Merchant.CardID ";
     sql += "WHERE Card.CardID<>@cardid AND catid=(SELECT catid from Card where cardid=@cardID) ";
     sql += "GROUP BY Card.CardID,Image,CardName,MerchantCount Order By CardName";
     SqlCommand cmd = new SqlCommand(sql, cnn);
     cmd.Parameters.AddWithValue("@cardid", cardid);            
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         CardBO cardBO = new CardBO();
         MerchantCollection Mercoll = new MerchantCollection();
         MerchantBO merBO = new MerchantBO();
         cardBO.CardID = dr["CardID"].ToString();
         cardBO.CardName = dr["CardName"].ToString();
         cardBO.Image = dr["Image"].ToString();
         cardBO.MerchantCount = Convert.ToInt32(dr["merchantcount"].ToString());
         if(dr["Save1"].ToString()!="")
             merBO.Save = Convert.ToDecimal(dr["Save1"].ToString());
         Mercoll.Add(merBO);
         cardBO.Details = Mercoll;
         CardColl.Add(cardBO);
     }
     cnn.Close();
     return CardColl;       
 }
Esempio n. 15
0
 public CardCollection SelectCard(int catid)//Get every cards in a Category
 {
     CardCollection cardColl = new CardCollection();
     SqlCommand cmd = null;
     if (catid != -1)
     {
         cmd = new SqlCommand("SELECT * FROM Card where catid=@cateid Order By CardName", cnn);
         cmd.Parameters.AddWithValue("@cateid", catid);
     }
     else
         cmd = new SqlCommand("SELECT * FROM Card Order By CardName", cnn);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         CardBO cardBO = new CardBO();        
         cardBO.CardID = dr["CardID"].ToString();
         cardBO.CatID = Convert.ToInt32(dr["CatID"].ToString());
         cardBO.CardName = dr["CardName"].ToString();
         cardBO.Description = dr["Description"].ToString();           
         cardBO.Image = dr["Image"].ToString();
         cardBO.MerchantCount=Convert.ToInt32(dr["MerchantCount"].ToString());
         cardColl.Add(cardBO);
     }
     cnn.Close();
     return cardColl;
 }
Esempio n. 16
0
 public CardCollection SelectMerchant(List<string> MerIDList)
 {
     string sql = "SELECT MerchantID,Card.CardID,CardName,Image,Value,[Save],Pay,Notes ";
     sql += "FROM Merchant INNER JOIN Card ON Merchant.CardID=Card.CardID ";
     sql +="WHERE MerchantID= '"+MerIDList[0]+"'";
     for(int i=1;i<MerIDList.Count;i++)
     {
         sql += "OR ";
         sql+= "MerchantID='"+MerIDList[i]+"' ";
    
     }
     SqlCommand cmd = new SqlCommand(sql, cnn);        
     CardCollection cardColl = new CardCollection();
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         CardBO cardBO = new CardBO();
         cardBO.Image = dr["Image"].ToString();
         cardBO.CardName = dr["CardName"].ToString();
         MerchantCollection MerchantColl = new MerchantCollection();
         MerchantBO merBO = new MerchantBO();
         merBO.MerchantID = dr["MerchantID"].ToString();
         merBO.Value = Convert.ToDecimal(dr["Value"].ToString());
         merBO.Pay = Convert.ToDecimal(dr["Pay"].ToString());
         merBO.Save = Convert.ToDecimal(dr["Save"].ToString());
         merBO.Notes = dr["Notes"].ToString();
         //Add to merchantColl
         MerchantColl.Add(merBO);
         //Assing Card.Detail = MerchantColl
         cardBO.Details = MerchantColl;
         //Add Card to cardColl
         cardColl.Add(cardBO);
     }
     cnn.Close();
     return cardColl;
 }
Esempio n. 17
0
 public bool EditCard(string cardid,string cardname,int categoryid,string description,string image)
 {
    try
    {
         CardBO cardBO= new CardBO();
         cardBO.CardID = cardid;
         cardBO.CardName = cardname;
         cardBO.CatID = categoryid;
         cardBO.Description = description;
         cardBO.Image = image;
         bool hasimage = true;
         if (image == "")
             hasimage = false;
         cardDAO.UpdateCard(cardBO,hasimage);
         return true;
     }
     catch
     {
         return false;
     }
 }
 public void LoadImage(Image imagebutton, CardBO cardbo)
 {
     imagebutton.ImageUrl = cardbo.Image;
 }