private string convertByteArrayToImage(string username)
        {
            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = "TP_GetProfilePic";

            User tempUser = new User();
            int  userID   = tempUser.getUserID(username);

            objCmd.Parameters.AddWithValue("@userID", userID);
            DataSet profilePicDS = objDB.GetDataSetUsingCmdObj(objCmd);
            string  imageUrl;

            if (objDB.GetField("Photo", 0) == DBNull.Value)
            {
                imageUrl = null;
            }
            else
            {
                byte[] imageData = (byte[])objDB.GetField("Photo", 0);
                imageUrl = "data:image/jpg;base64," + Convert.ToBase64String(imageData);
            }
            return(imageUrl);
        }
Esempio n. 2
0
        public void ShowVacationPackage()
        {
            string customerName = Session["LoginID"].ToString();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "getVacation";
            objCommand.Parameters.Clear();

            objCommand.Parameters.AddWithValue("@CustomerName", customerName);

            objDB.GetDataSetUsingCmdObj(objCommand);

            if (objDB.GetField("VacationPackage", 0) != System.DBNull.Value)
            {
                Byte[]          byteArray    = (Byte[])objDB.GetField("VacationPackage", 0);
                BinaryFormatter deSerializer = new BinaryFormatter();
                MemoryStream    memStream    = new MemoryStream(byteArray);

                Trip objTrip = (Trip)deSerializer.Deserialize(memStream);

                ArrayList arrTrip = new ArrayList();
                arrTrip.Add(objTrip);

                gvVacationPackage.DataSource = arrTrip;
                gvVacationPackage.DataBind();
            }
        }
        protected void btnSendMessage_Click(object sender, EventArgs e)
        {
            Timer1.Enabled = true;

            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = "TP_GetConversation";
            objCmd.Parameters.AddWithValue("@usernameOne", Session["Username"].ToString());
            objCmd.Parameters.AddWithValue("@usernameTwo", Session["MessageToUsername"].ToString());
            DataSet conversationDS = objDB.GetDataSetUsingCmdObj(objCmd);

            string conversation = objDB.GetField("Content", 0).ToString();
            int    messageID    = int.Parse(objDB.GetField("MessageID", 0).ToString());

            String messageText = txtSendMessage.Text;

            String updateConversation = conversation + "<br />" + Session["Username"].ToString() + ": " + messageText;

            DBConnect  objDBConn  = new DBConnect();
            SqlCommand objCmdConn = new SqlCommand();

            objCmdConn.CommandType = CommandType.StoredProcedure;
            objCmdConn.CommandText = "TP_UpdateConversation";
            objCmdConn.Parameters.AddWithValue("@messageID", messageID);
            objCmdConn.Parameters.AddWithValue("@content", updateConversation);
            int result = objDBConn.DoUpdateUsingCmdObj(objCmdConn);

            if (result == 1)
            {
                DataBind();

                User   tempUser  = new User();
                string recipient = tempUser.getEmailByUsername(Session["MessageToUsername"].ToString());
                Email  emailObj  = new Email();
                string to        = recipient;
                string from      = "*****@*****.**";
                string subject   = "New Message";
                string message   = "You have a new message from " + Session["Username"].ToString() + ". Visit the website to view the message.";
                try
                {
                    emailObj.SendMail(to, from, subject, message);
                }
                catch (Exception ex)
                {
                }
            }
            txtSendMessage.Text = string.Empty;
        }
Esempio n. 4
0
        protected void btnBlock_click(object sender, EventArgs e)
        {
            //Add current profile to block
            SqlCommand objCommand = new SqlCommand();

            //objCommand  = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "TP_GetBlocks";

            objCommand.Parameters.AddWithValue("@UserId", Session["UserID"].ToString());

            objDB.GetDataSetUsingCmdObj(objCommand);



            Byte[] byteArray = (Byte[])objDB.GetField("BlockList", 0);



            BinaryFormatter deSerializer = new BinaryFormatter();

            MemoryStream memStream = new MemoryStream(byteArray);



            List <int> BlockList;

            try
            {
                BlockList = (List <int>)deSerializer.Deserialize(memStream);
            }
            catch
            {
                BlockList = new List <int>();
            }

            BlockList.Add(Convert.ToInt32(Session["CurrentUserID"]));

            BinaryFormatter serializer = new BinaryFormatter();

            MemoryStream stream = new MemoryStream();

            Byte[] Store;

            serializer.Serialize(stream, BlockList);

            Store = memStream.ToArray();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "TP_StoreBlocks";

            objCommand.Parameters.AddWithValue("@UserId", Session["CurrentUserID"].ToString());
            objCommand.Parameters.AddWithValue("@BlockList", Store);
            objDB.DoUpdateUsingCmdObj(objCommand);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Email"] == null)
     {
         Server.Transfer("Default.aspx", false);
     }
     else
     {
         if (!IsPostBack)
         {
             DBConnect  objDB      = new DBConnect();
             SqlCommand objCommand = new SqlCommand();
             objCommand.CommandType = CommandType.StoredProcedure;
             objCommand.CommandText = "TP_GetSerializablePreferences";
             objCommand.Parameters.AddWithValue("@email", Session["Email"].ToString());
             objCommand.Parameters.AddWithValue("@verificationToken", Session["VerificationToken"].ToString());
             DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand);
             // De-serialize the binary data to reconstruct the CreditCard object retrieved
             // from the database
             Byte[]          byteArray    = (Byte[])objDB.GetField("SerialPreferences", 0);
             BinaryFormatter deSerializer = new BinaryFormatter();
             MemoryStream    memStream    = new MemoryStream(byteArray);
             memStream.Position = 0;
             var preferences = (Preferences)deSerializer.Deserialize(memStream);
             for (int i = 0; i < ddlAutoSignIn.Items.Count; i++)
             {
                 ddlAutoSignIn.SelectedIndex = i;
                 if (ddlAutoSignIn.SelectedValue == preferences.AutoSignIn.ToString())
                 {
                     ddlAutoSignIn.SelectedIndex = i;
                     break;
                 }
             }
             for (int i = 0; i < ddlProfileView.Items.Count; i++)
             {
                 ddlProfileView.SelectedIndex = i;
                 if (ddlProfileView.SelectedValue == preferences.Privacy.ToString())
                 {
                     ddlProfileView.SelectedIndex = i;
                     break;
                 }
             }
             for (int i = 0; i < ddlColorStyle.Items.Count; i++)
             {
                 ddlColorStyle.SelectedIndex = i;
                 if (ddlColorStyle.SelectedValue == preferences.Theme.ToString())
                 {
                     ddlColorStyle.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
 }
        public override void DataBind()
        {
            DBConnect  objDB  = new DBConnect();
            SqlCommand objCmd = new SqlCommand();

            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = "TP_GetConversation";
            objCmd.Parameters.AddWithValue("@usernameOne", Session["Username"].ToString());
            objCmd.Parameters.AddWithValue("@usernameTwo", Session["MessageToUsername"].ToString());
            DataSet conversationDS = objDB.GetDataSetUsingCmdObj(objCmd);

            string conversation = objDB.GetField("Content", 0).ToString();

            lblMessages.Text = conversation;
        }
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text != null && txtPassword.Text != null)
            {
                DataSet myData = getLoginData(txtUsername.Text, txtPassword.Text);

                int size = myData.Tables[0].Rows.Count;
                for (int i = 0; i < size; i++)
                {
                    int userBanned = int.Parse(dbConnect.GetField("BanStatus", 0).ToString());
                    if (userBanned == 0)
                    {
                        Response.Write("<script>alert('Your email account is banned.')</script>");
                    }
                    else
                    {
                        String userType = dbConnect.GetField("Type", 0).ToString();

                        if (userType.CompareTo("User") == 0)
                        {
                            Session["UserId"]         = dbConnect.GetField("UserId", 0);
                            Session["Username"]       = txtUsername.Text;
                            Session["HomeAddress"]    = dbConnect.GetField("HomeAddress", 0);
                            Session["BillingAddress"] = dbConnect.GetField("BillingAddress", 0);
                            Session["Avatar"]         = dbConnect.GetField("Avatar", 0);
                            Session["Money"]          = dbConnect.GetField("Money", 0);
                            Session["PhoneNumber"]    = dbConnect.GetField("PhoneNumber", 0);
                            Response.Redirect("ComicUser.aspx");
                        }
                        else
                        {
                            Session["UserId"]         = dbConnect.GetField("UserId", 0);
                            Session["Username"]       = txtUsername.Text;
                            Session["HomeAddress"]    = dbConnect.GetField("HomeAddress", 0);
                            Session["BillingAddress"] = dbConnect.GetField("BillingAddress", 0);
                            Session["Avatar"]         = dbConnect.GetField("Avatar", 0);
                            Session["Money"]          = dbConnect.GetField("Money", 0);
                            Session["PhoneNumber"]    = dbConnect.GetField("PhoneNumber", 0);
                            Response.Redirect("ComicAdmin.aspx");
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('Your Password is Incorrect')</script>");
            }
        }