示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var context = new HireMeEntities();
            var User    = Membership.GetUser();
            var user    = context.Individuals.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault();

            if (user == null)
            {
                // add new record
                var            userId = context.aspnet_Membership.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault().UserId;
                DAL.Individual obj    = new DAL.Individual();
                obj.Name              = txtFullName.Text;
                obj.UserId            = userId;
                obj.Phone             = Convert.ToInt32(txtPhone.Text);
                obj.Location          = Convert.ToInt32(ddlLocation.SelectedValue);
                obj.Gender            = Convert.ToInt32(ddlGendr.SelectedValue);
                obj.Nationality       = Convert.ToInt32(ddlNationality.SelectedValue);
                obj.BobMonth          = (ddlLocation.SelectedValue);
                obj.BdDDay            = Convert.ToInt32(ddlDay.SelectedValue);
                obj.BobYear           = Convert.ToInt32(ddlYear.SelectedValue);
                obj.FieldOfBusiness   = Convert.ToInt32(ddlFieldOfBusiness.SelectedValue);
                obj.GraduationCountry = Convert.ToInt32(ddlGraduationCountry.SelectedValue);
                //obj.GraduationUniversity = Convert.ToInt32(ddlGraduationUniversity.SelectedValue);
                obj.YearsOfExperience = Convert.ToInt32(ddlYearsOfExperience.SelectedValue);
                obj.TypeOfEmployment  = Convert.ToInt32(ddlTypeOfEmployment.SelectedValue);
                obj.AbilityToTravel   = Convert.ToInt32(ddlAbilityToTravel.SelectedValue);
                obj.MinimumSalary     = Convert.ToInt32(txtMinimumSalary.Text);
                obj.EmploymentHistory = txtEmploymentHistory.Text;

                obj.RelationshipStatus = Convert.ToInt32(ddlRelationshipStatus.SelectedValue);
                obj.CoverLetter        = txtCoverletter.Text;
                obj.AcademicDegree     = Convert.ToInt32(ddlAcademicDegree.SelectedValue);
                if (fuCv.HasFile)
                {
                    try
                    {
                        string filename = Path.GetFileName(fuCv.FileName);
                        string savePath = "D:\\Project\\uploads\\" + userId;
                        fuCv.SaveAs(savePath + filename);
                        obj.CvAttachment = savePath + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                }

                foreach (ListItem item in lstSkils.Items)
                {
                    if (item.Selected)
                    {
                        UserSkill objskill = new UserSkill();
                        objskill.UserId  = userId;
                        objskill.SkillId = Convert.ToInt32(item.Value);
                        context.UserSkills.Add(objskill);
                    }
                }
                context.Individuals.Add(obj);
                context.SaveChanges();
                divSuccess.Visible = true;
            }
            else
            {
                user.Name                 = txtFullName.Text;
                user.UserId               = context.aspnet_Membership.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault().UserId;
                user.Phone                = Convert.ToInt32(txtPhone.Text);
                user.Location             = Convert.ToInt32(ddlLocation.SelectedValue);
                user.Gender               = Convert.ToInt32(ddlGendr.SelectedValue);
                user.Nationality          = Convert.ToInt32(ddlNationality.SelectedValue);
                user.BobMonth             = (ddlMonth.SelectedValue);
                user.BdDDay               = Convert.ToInt32(ddlDay.SelectedValue);
                user.BobYear              = Convert.ToInt32(ddlYear.SelectedValue);
                user.FieldOfBusiness      = Convert.ToInt32(ddlFieldOfBusiness.SelectedValue);
                user.GraduationCountry    = Convert.ToInt32(ddlGraduationCountry.SelectedValue);
                user.GraduationUniversity = Convert.ToInt32(ddlGraduationUniversity.SelectedValue);
                user.YearsOfExperience    = Convert.ToInt32(ddlYearsOfExperience.SelectedValue);
                user.TypeOfEmployment     = Convert.ToInt32(ddlTypeOfEmployment.SelectedValue);
                user.AcademicDegree       = Convert.ToInt32(ddlAcademicDegree.SelectedValue);
                user.AbilityToTravel      = Convert.ToInt32(ddlAbilityToTravel.SelectedValue);
                user.MinimumSalary        = Convert.ToInt32(txtMinimumSalary.Text);
                user.EmploymentHistory    = txtEmploymentHistory.Text;
                user.CoverLetter          = txtCoverletter.Text;
                user.RelationshipStatus   = Convert.ToInt32(ddlRelationshipStatus.SelectedValue);
                if (fuCv.HasFile)
                {
                    try
                    {
                        string filename = Path.GetFileName(fuCv.FileName);
                        string savePath = "D:\\Project\\uploads\\" + user.UserId;
                        fuCv.SaveAs(savePath + filename);
                        user.CvAttachment = savePath + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                context.UserSkills.RemoveRange(context.UserSkills.Where(r => r.UserId == user.UserId));
                foreach (ListItem item in lstSkils.Items)
                {
                    if (item.Selected)
                    {
                        UserSkill obj = new UserSkill();
                        obj.UserId  = user.UserId;
                        obj.SkillId = Convert.ToInt32(item.Value);
                        context.UserSkills.Add(obj);
                    }
                }
                context.SaveChanges();
            }
            divSuccess.Visible = true;
        }
示例#2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            var context = new HireMeEntities();


            var User = Membership.GetUser();


            var user       = context.aspnet_Users.Where(x => x.UserName == User.UserName).FirstOrDefault();
            var individual = context.Individuals.Where(x => x.UserId == user.UserId).FirstOrDefault();

            if (individual == null)
            {
                var    obj      = new DAL.Individual();
                string savePath = "D:\\Project\\Images\\" + user.UserId;
                obj.UserId = user.UserId;
                if (fubImage.HasFile)
                {
                    if (!File.Exists(savePath))
                    {
                        System.IO.Directory.CreateDirectory(savePath);
                    }
                    try
                    {
                        string filename = Path.GetFileName(fubImage.FileName);
                        //filename = filename + user.UserId;
                        fubImage.SaveAs(savePath + "//" + filename);
                        obj.ImageUrl = savePath + "//" + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                }

                context.Individuals.Add(obj);
                context.SaveChanges();
            }
            else
            {
                string savePath = "D:\\Project\\Images\\" + user.UserId;
                if (fubImage.HasFile)
                {
                    if (!File.Exists(savePath))
                    {
                        System.IO.Directory.CreateDirectory(savePath);
                    }
                    try
                    {
                        string filename = Path.GetFileName(fubImage.FileName);
                        //filename = filename + user.UserId;
                        fubImage.SaveAs(savePath + "//" + filename);
                        individual.ImageUrl = savePath + "//" + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                    context.SaveChanges();
                }
            }



            System.IO.Stream       fs = fubImage.PostedFile.InputStream;
            System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
            Byte[] bytes        = br.ReadBytes((Int32)fs.Length);
            string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);

            Image1.ImageUrl = "data:image/png;base64," + base64String;
            Image1.Visible  = true;
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var context = new HireMeEntities();
            var User    = Membership.GetUser();
            var user    = context.Individuals.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault();

            if (user == null)
            {
                // add new record
                DAL.Individual obj = new DAL.Individual();
                obj.Name                 = txtFullName.Text;
                obj.UserId               = context.aspnet_Membership.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault().UserId;
                obj.Phone                = Convert.ToInt32(txtPhone.Text);
                obj.Location             = Convert.ToInt32(ddlLocation.SelectedValue);
                obj.Gender               = Convert.ToInt32(ddlGendr.SelectedValue);
                obj.Nationality          = Convert.ToInt32(ddlNationality.SelectedValue);
                obj.BobMonth             = (ddlLocation.SelectedValue);
                obj.BdDDay               = Convert.ToInt32(ddlDay.SelectedValue);
                obj.BobYear              = Convert.ToInt32(ddlYear.SelectedValue);
                obj.FieldOfBusiness      = Convert.ToInt32(ddlFieldOfBusiness.SelectedValue);
                obj.GraduationCountry    = Convert.ToInt32(ddlGraduationCountry.SelectedValue);
                obj.GraduationUniversity = Convert.ToInt32(ddlGraduationUniversity.SelectedValue);
                obj.YearsOfExperience    = Convert.ToInt32(ddlYearsOfExperience.SelectedValue);
                obj.TypeOfEmployment     = Convert.ToInt32(ddlTypeOfEmployment.SelectedValue);
                obj.AcademicDegree       = Convert.ToInt32(ddlAcademicDegree.SelectedValue);
                if (fuCv.HasFile)
                {
                    try
                    {
                        string filename = Path.GetFileName(fuCv.FileName);
                        string savePath = "D:\\Project\\uploads\\";
                        fuCv.SaveAs(savePath + filename);
                        obj.CvAttachment = savePath + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                context.Individuals.Add(obj);
                context.SaveChanges();
            }
            else
            {
                user.Name                 = txtFullName.Text;
                user.UserId               = context.aspnet_Membership.Where(x => x.aspnet_Users.UserName == User.UserName).FirstOrDefault().UserId;
                user.Phone                = Convert.ToInt32(txtPhone.Text);
                user.Location             = Convert.ToInt32(ddlLocation.SelectedValue);
                user.Gender               = Convert.ToInt32(ddlGendr.SelectedValue);
                user.Nationality          = Convert.ToInt32(ddlNationality.SelectedValue);
                user.BobMonth             = (ddlLocation.SelectedValue);
                user.BdDDay               = Convert.ToInt32(ddlDay.SelectedValue);
                user.BobYear              = Convert.ToInt32(ddlYear.SelectedValue);
                user.FieldOfBusiness      = Convert.ToInt32(ddlFieldOfBusiness.SelectedValue);
                user.GraduationCountry    = Convert.ToInt32(ddlGraduationCountry.SelectedValue);
                user.GraduationUniversity = Convert.ToInt32(ddlGraduationUniversity.SelectedValue);
                user.YearsOfExperience    = Convert.ToInt32(ddlYearsOfExperience.SelectedValue);
                user.TypeOfEmployment     = Convert.ToInt32(ddlTypeOfEmployment.SelectedValue);
                user.AcademicDegree       = Convert.ToInt32(ddlAcademicDegree.SelectedValue);
                if (fuCv.HasFile)
                {
                    try
                    {
                        string filename = Path.GetFileName(fuCv.FileName);
                        string savePath = "D:\\Project\\uploads\\";
                        fuCv.SaveAs(savePath + filename);
                        user.CvAttachment = savePath + filename;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }