Example #1
0
        /// <summary> Method to for OnClick of ListView Items. </summary>
        /// <returns>void.</returns>
        protected void lvProducts_OnItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (user.UserId != 0)
            {
                if (String.Equals(e.CommandName, "Enquiry"))
                {
                    // Verify that the employee ID is not already in the list. If not, add the
                    // employee to the list.
                    /// <summary> Store the ListViewDataItem. </summary>
                    ListViewDataItem dataItem = (ListViewDataItem)e.Item;

                    /// <summary> Store the Product ID. </summary>
                    //tblProductDetails[dataItem.DataItemIndex];
                    int ProductId =
                        int.Parse(lvProducts.DataKeys[dataItem.DisplayIndex].Value.ToString());
                    /// <summary> Store the Product User ID. </summary>
                    int ProductUserId = int.Parse(e.CommandArgument.ToString());
                    tblMessageProductUser = adpMessageProductUser.GetMessages(ProductUserId, ProductId);
                    if (tblMessageProductUser.Count > 0)
                    {
                        Response.Redirect("~/Messages.aspx");
                    }
                    else
                    {
                        adpMessage.Insert("Hey, I am interesterd in this product. Is it still available?", user.UserId, ProductUserId, ProductId);
                    }
                    //System.Diagnostics.Debug.WriteLine("Parameter" + param);
                }
                else if (String.Equals(e.CommandName, "Buy"))
                {
                    /// <summary> Store the ListViewDataItem. </summary>
                    ListViewDataItem dataItem = (ListViewDataItem)e.Item;

                    //tblProductDetails[dataItem.DataItemIndex];
                    /// <summary> Store the Product ID. </summary>
                    int ProductId =
                        int.Parse(lvProducts.DataKeys[dataItem.DisplayIndex].Value.ToString());
                    /// <summary> Store the Product User ID. </summary>
                    int ProductUserId = int.Parse(e.CommandArgument.ToString());

                    /// <summary> Store the ROW object. </summary>
                    FinalProjectDataset.ProductDetailRow row = tblProductDetails[dataItem.DisplayIndex];
                    if (string.Equals(row.ProductType, "Available"))
                    {
                        adpUserProduct.Insert(user.UserId, ProductId, 1);
                        if (adpUserProduct.GetTotalQtyByProduct(ProductId) == row.ProductQty)
                        {
                            //row.ProductType = "Sold";
                            adpProduct.UpdateProductType("Sold", row.ProductId);
                            tblProductDetails[dataItem.DisplayIndex].ProductType = "Sold";
                            //Response.Redirect("");
                        }
                    }
                }
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }
        }
Example #2
0
        public static Guid InsertMessage(Guid?parentMessageId, string localObjectType, string localObjectId, Guid fromUserId, Guid?toUserId, string subject, string text)
        {
            Guid messageId = Guid.NewGuid();

            using (MessageTableAdapter adapter = new MessageTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
            {
                adapter.Insert(messageId, parentMessageId, localObjectType, localObjectId, fromUserId, toUserId, subject, text, DateTime.UtcNow);
            }
            return(messageId);
        }
Example #3
0
 /// <summary>
 /// method called when message send button is called
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSendMessage_Click(object sender, EventArgs e)
 {
     MessageFromId = int.Parse(Cache["MessageFromId"].ToString());
     MessageToId   = int.Parse(Cache["MessageToId"].ToString());
     ProductId     = int.Parse(Cache["ProductId"].ToString());
     if (!string.IsNullOrEmpty(txtMessage.Text))
     {
         int ToUserId    = MessageFromId != user.UserId ? MessageFromId : MessageToId;
         int insertedRow = adpMessage.Insert(txtMessage.Text, user.UserId, ToUserId, ProductId);
         if (insertedRow > 0)
         {
             System.Diagnostics.Debug.WriteLine("Messege sent successfully.");
             txtMessage.Text = "";
             LoadMessages();
         }
         else
         {
             System.Diagnostics.Debug.WriteLine("Messege Failure.");
         }
     }
 }