コード例 #1
0
        public PreviousWork previousWork(int id)
        {
            PreviousWork freelancer = null;

            string query = "SELECT * FROM portfolio  WHERE FreelacnerId = @id";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                command.Parameters.AddWithValue("@id", id);
                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        if (reader.Read())
                        {
                            freelancer = new PreviousWork(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
                        }
                    }
                    reader.Close();
                }
                //Close Connection
                command.Connection.Close();
            }
            return(freelancer);
        }
コード例 #2
0
        public void postPortfolio(PreviousWork freelancer)
        {
            //check if the frelancer has previously added work

            if (existingFreelancer(freelancer.FreelacnerId))
            {
                //if record exist then update
                updatetPortfolio(freelancer);
            }
            else
            {
                //if doesn't exist then insert
                insertPortfolio(freelancer);
            }
        }
コード例 #3
0
        public void updatetPortfolio(PreviousWork freelancer)
        {
            query = @"UPDATE  portfolio Set Pictures = @Pictures, Videos = @Videos, Links = @Links WHERE FreelacnerId = @FreelacnerId";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                //General
                command.Parameters.AddWithValue("@Pictures", freelancer.Pictures);
                command.Parameters.AddWithValue("@Videos", freelancer.Videos);
                command.Parameters.AddWithValue("@Links", freelancer.Links);
                command.Parameters.AddWithValue("@FreelacnerId", freelancer.FreelacnerId);

                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;
                command.ExecuteNonQuery();

                command.Connection.Close();
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["STUDENT"] == null)
            {
                Response.Redirect("~/Web/Account/tempLogin.aspx?page=Users/Student/students-add-work.aspx");
            }

            //load previous work images
            Qaelo.Models.StudentModel.Student student = (Qaelo.Models.StudentModel.Student)(Session["STUDENT"]);

            PreviousWork work = connection.getPortfolio(student.Id);

            if (work != null && !IsPostBack)
            {
                //Load the previous work
                string[] pictures = work.Pictures.Split(';');
                txtLink.Text = work.Links;
                string[] videos = work.Videos.Split(';');
            }
        }
コード例 #5
0
        public void insertPortfolio(PreviousWork freelancer)
        {
            if (freelancer == null)
            {
                return;
            }

            query = @"INSERT INTO portfolio(FreelacnerId, Pictures, Videos, Links) values(@FreelacnerId, @Pictures, @Videos, @Links)";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                //General
                command.Parameters.AddWithValue("@FreelacnerId", freelancer.FreelacnerId);
                command.Parameters.AddWithValue("@Pictures", freelancer.Pictures);
                command.Parameters.AddWithValue("@Videos", freelancer.Videos);
                command.Parameters.AddWithValue("@Links", freelancer.Links);

                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;
                command.ExecuteNonQuery();

                command.Connection.Close();
            }
        }
コード例 #6
0
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            string name = "";

            Qaelo.Models.StudentModel.Student student = (Qaelo.Models.StudentModel.Student)Session["STUDENT"];

            string f1 = "default.jpg";
            string f2 = "default.jpg";
            string f3 = "default.jpg";
            string f4 = "default.jpg";
            string f5 = "default.jpg";
            string f6 = "default.jpg";


            if (file1.HasFile)
            {
                try
                {
                    f1 = student.Id + Path.GetFileName(file1.FileName);
                    file1.SaveAs(Server.MapPath("~/Images/Freelancer/") + f1);
                }
                catch (Exception ex)
                {
                    f1 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f1 = "default.jpg";
            }

            if (file2.HasFile)
            {
                try
                {
                    f2 = student.Id + Path.GetFileName(file2.FileName);
                    file2.SaveAs(Server.MapPath("~/Images/Freelancer/") + f2);
                }
                catch (Exception ex)
                {
                    f2 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f2 = "default.jpg";
            }

            if (file3.HasFile)
            {
                try
                {
                    f3 = student.Id + Path.GetFileName(file3.FileName);
                    file3.SaveAs(Server.MapPath("~/Images/Freelancer/") + f3);
                }
                catch (Exception ex)
                {
                    f3 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f3 = "default.jpg";
            }


            if (file4.HasFile)
            {
                try
                {
                    f4 = student.Id + Path.GetFileName(file4.FileName);
                    file4.SaveAs(Server.MapPath("~/Images/Freelancer/") + f4);
                }
                catch (Exception ex)
                {
                    f4 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f4 = "default.jpg";
            }

            if (file5.HasFile)
            {
                try
                {
                    f5 = student.Id + Path.GetFileName(file5.FileName);
                    file5.SaveAs(Server.MapPath("~/Images/Freelancer/") + f5);
                }
                catch (Exception ex)
                {
                    f5 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f5 = "default.jpg";
            }


            if (file6.HasFile)
            {
                try
                {
                    f6 = student.Id + Path.GetFileName(file6.FileName);
                    file6.SaveAs(Server.MapPath("~/Images/Freelancer/") + f6);
                }
                catch (Exception ex)
                {
                    f6 = "default.jpg";
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                f6 = "default.jpg";
            }

            string pictures = f1 + ";" + f2 + ";" + f3;
            string videos   = f4 + ";" + f5 + ";" + f6;

            PreviousWork previousWork = new PreviousWork(student.Id, pictures, videos, txtLink.Text);

            connection.postPortfolio(previousWork);

            lblSuccess.Text = "Sucessfully Saved previous work";

            Response.Redirect("students-profile.aspx?page=previousWork");
        }
コード例 #7
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            //load
            StudentConnection connection = new StudentConnection();

            //Get all students from selected varsity
            string query = " Institution = " + "'" + txtText.Text + "'";
            List <Qaelo.Models.StudentModel.Student> students = connection.getAllStudents(query);

            List <Qaelo.Models.StudentModel.Freelancer> freelancers = new List <Models.StudentModel.Freelancer>();

            //add each profile to freelance list
            foreach (Qaelo.Models.StudentModel.Freelancer freelancer in connection.getAllFreelancers())
            {
                //add student as freelance
                if (connection.getStudent(freelancer.StudentId) != null)
                {
                    if (connection.getStudent(freelancer.StudentId).Institution.Equals(txtText.Text))
                    {
                        if (freelancer.Work.Contains(txtFreelancers.Text))
                        {
                            freelancers.Add(freelancer);
                        }
                    }
                }
            }
            string html   = "";
            int    length = General.getLengthOfLongestFreelancer(freelancers);

            foreach (Models.StudentModel.Freelancer freelancer in freelancers)
            {
                if (connection.isProfilePublic(freelancer.StudentId))
                {
                    //if a student is a freelancer then include it here
                    string[] abilities = freelancer.Work.Split(';');
                    string   work      = "";

                    for (int i = 0; i < abilities.Count(); i++)
                    {
                        if (abilities[i].Count() > 0)
                        {
                            if ((i + 1) == abilities.Count())
                            {
                                work += abilities[i];
                            }
                            else
                            {
                                if (abilities[i].Count() > 4)
                                {
                                    work += "<li>" + abilities[i] + "</li>";
                                }
                                //work += "." + abilities[i] + "." + "<br/>";
                            }
                        }
                    }

                    string fr = "<h6 style='margin-top:10px'>I freelance as a : <br/><ul></h6><small style='font-size:12px'>" + work + "</b></small><ul/>";
                    Qaelo.Models.StudentModel.Student student = connection.getStudent(freelancer.StudentId);
                    string[] images = freelancer.Image.Split(';');

                    html += string.Format(@"
                        <div class='col-md-3 thumbnail'>
                          <div class='w3-card-12'>
                                        <figure >
                                          <img src='../../../Images/Users/Students/{0}' style='height:220px;width:100%' />
                                  <figcaption style = 'background-image: url('')'>
                                        {1}                  
                                  </figcaption>
                                   </figure>
                            <div class='w3-container' style='margin:10px'>
                                <h6><b>{2} - <small style='font-size:12px'>{3}</small></b></h6>
                                {4}<br/>
                              <a href='#freelancer{5}'  data-toggle='modal' class='btn pull-right form-control' style='background:#d89b4e'>View profile</a>
                                <br/><br/>
                            </div>
                          </div>
                        </div>

                       
                    ", student.ProfileImage, student.Description, student.FirstName + student.LastName, student.Institution, fr, student.Id);

                    //Modal pop up

                    //Get freelance portfolio
                    PreviousWork portfolio = connection.getPortfolio(student.Id);

                    string image1 = "default.jpg";
                    string image2 = "default.jpg";
                    string image3 = "default.jpg";

                    string video1 = "videoDefault.mp4";
                    string video2 = "videoDefault.mp4";
                    string video3 = "videoDefault.mp4";

                    string cvDescription = "";

                    if (portfolio != null)
                    {
                        //Test for images
                        string[] pictures = portfolio.Pictures.Split(';');

                        if (pictures[0] != string.Empty)
                        {
                            image1 = pictures[0];
                        }

                        if (pictures[1] != string.Empty)
                        {
                            image2 = pictures[1];
                        }

                        if (pictures[2] != string.Empty)
                        {
                            image3 = pictures[2];
                        }

                        //Test for videos
                        string[] videos = portfolio.Videos.Split(';');

                        if (videos[0] != string.Empty)
                        {
                            video1 = videos[0];
                        }

                        if (videos[1] != string.Empty)
                        {
                            video2 = videos[1];
                        }

                        if (videos[2] != string.Empty)
                        {
                            video3 = videos[2];
                        }

                        cvDescription = portfolio.Links;
                    }

                    lblSingleProfile.Text += string.Format(@"<div class='modal fade' id='freelancer{11}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
                            <div class='modal-dialog modal-lg'>
                            <div class='modal-content'>
                                        <div class='modal-body'>
                                            <div class='container'>
                                                <div class='col-sm-9'>
                                                    <div class='col-sm-5'>
                                                        <h2>Education</h2>
                                                        <hr />            
                                                        <strong>University:</strong><p>{0}</p>
                                                        <strong>Course Enrolled:</strong><p>{1}</p>
                                                        <strong>Freelance:</strong><p>{2}</p>
                                                        <strong>Freelancing Description:</strong><p>{3}</p>
                                                        <strong>Price:</strong><p>{4}</p>
                                                    </div>
                                                    <div class='col-sm-5'>
                                                        <h2>Contact Info</h2>
                                                         <hr />   
                                                        <strong>Full Name :</strong><p>{5}</p>
                                                        <strong>Email:</strong><p>{6}</p>
                                                        <strong>Phone No:</strong><p>{7}</p>
                                                    </div>
                                                 </div>

                                                 <div class='col-sm-9' style='margin-top:50px'> </div>

 <!-- Portfolio-->
<div class='col-sm-9'>                                       
         <div class='panel-group' id='accordion{11}'>
                                                      
             <div class='panel panel-warning'>
                                                        
                 <div class='panel-heading'>
                                                          <h4 class='panel-title'>
                                                            <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse1{11}'>
                                                           View My Portfolio Pictures</a>
                                                          </h4>
                                                        </div>
                                                        
                 <div id='collapse1{11}' class='panel-collapse collapse in'>
                                                          <div class='panel-body'>
                                                              <div class='col-sm-12'>
                                                    
                                                                  
                                                                                                        <div class='col-sm-4'>
                                                                                                            <a id='popover1{11}' class='btn' rel='popover1{11}' data-content=''  >
                                                                                                                <img src='../../../Images/Freelancer/{12}' class='img-thumbnail' />
                                                                                                            </a>
                                                                                                             
                                                                                                        </div>
                                                                                                       
                                                                                                         <div class='col-sm-4'>
                                                                                                             <a id='popover2{11}' class='btn' rel='popover2{11}' data-content=''  >
                                                                                                             <img src='../../../Images/Freelancer/{13}' class='img-thumbnail' />
                                                                                                                 </a>
                                                                                                        </div>
                                                                                                       
                                                                                                         <div class='col-sm-4'>
                                                                                                             <a id='popover3{11}' class='btn' rel='popover3{11}' data-content=''  >
                                                                                                             <img src='../../../Images/Freelancer/{14}' class='img-thumbnail' />
                                                                                                                 </a>
                                                                                                        </div>
                                                                                                     </div>
                                                          </div>
                                                        </div>
                                                      
             </div>
         </div>
         <!-- Next conetent here-->


                                                      <div class='panel panel-warning'>
                                                        <div class='panel-heading'>
                                                          <h4 class='panel-title'>
                                                            <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse2{11}'>
                                                            View My Portfolio Videos</a>
                                                          </h4>
                                                        </div>
                                                        <div id='collapse2{11}' class='panel-collapse collapse'>
                                                          <div class='panel-body'>
                                                              <div class='col-sm-12'>
                                                                <div class='col-sm-4'>
                                                                    <video src='../../../Images/Freelancer/{15}' class='img-thumbnail' style='height:150px;' controls='controls' />
                                                                </div>
                                                                                                       
                                                                 <div class='col-sm-4'>
                                                                     <video src='../../../Images/Freelancer/{16}' class='img-thumbnail' style='height:150px;' controls='controls' />
                                                                </div>
                                                                                                        
                                                                <div class='col-sm-4'>
                                                                    <video src='../../../Images/Freelancer/{17}' class='img-thumbnail' style='height:150px;' controls='controls' />
                                                                </div>
                                                                                                     
                                                              </div>

                                                          </div>
                                                        </div>
                                                      </div>
    <!-- Next content here-->
                                                <div class='panel panel-warning'>
                                                        <div class='panel-heading'>
                                                          <h4 class='panel-title'>
                                                            <a data-toggle='collapse' data-parent='#accordion{11}' href='#collapse3{11}'>
                                                            View My Portfolio CV</a>
                                                          </h4>
                                                        </div>
                                                        <div id='collapse3{11}' class='panel-collapse collapse'>
                                                          <div class='panel-body'>
                                                              <div class='col-sm-12'>
                                                    
                                                                                                        <p>
                                                                                                           {18}
                                                                                                        </p>
                                                                                                     </div>

                                                          </div>
                                                        </div>
                                                      </div>
     </div>

                                               
                                                 </div>
                                        <div class='modal-footer'>
                                            <button  class='btn btn-default pull-left' data-dismiss='modal'>Cancel</button>
                                        </div>
                                        </div>
                                    </div>
                                </div>
</div>", student.Institution, student.QualificationEnrolled, freelancer.Work, freelancer.Description, freelancer.Price, student.FirstName + " " + student.LastName, student.Email, student.Number, images[0], images[1], images[2], student.Id, image1, image2, image3, video1, video2, video3, cvDescription);
                }
            }

            if (html.Length > 0)
            {
                lblProfileView.Text = html;
            }
        }