Exemple #1
0
        public ActionResult EditExperiences(int userId, int experienceId)
        {
            Person     thisPerson             = Person.Find(userId);
            Experience thisExperience         = Experience.Find(experienceId);
            Dictionary <string, object> model = new Dictionary <string, object> ();

            model.Add("user", thisPerson);
            model.Add("experience", thisExperience);

            return(View("EditExperience", model));
        }
Exemple #2
0
        public void Find_FindsExperienceInDatabase_Experience()
        {
            //Arrange
            Experience testExperience = new Experience(1, 2, "Sky Diving", "Blah Blah..", "/hjfsddjf.com", 150);

            testExperience.Save();

            //Act
            Experience result = Experience.Find(testExperience.GetId());

            //Assert
            Assert.AreEqual(testExperience, result);
        }
Exemple #3
0
        public ActionResult ViewCityExperience(int userId, int cityId, int experienceId)
        {
            Dictionary <string, object> model = new Dictionary <string, object> ();

            Person     thisPerson     = Person.Find(userId);
            City       citySearch     = City.Find(cityId);
            Experience thisExperience = Experience.Find(experienceId);

            model.Add("user", thisPerson);
            model.Add("city", citySearch);
            model.Add("experience", thisExperience);

            return(View("ViewExperienceUser", model));
        }
Exemple #4
0
        public ActionResult EditExperience(int userId, int experienceId)
        {
            Person thisPerson = Person.Find(userId);
            Dictionary <string, object> model = new Dictionary <string, object> ();
            Experience thisExperience         = Experience.Find(experienceId);

            thisExperience.UpdateDescription(Request.Form["experience-description"]);
            thisExperience.UpdatePhoto(Request.Form["experience-photo"]);
            thisExperience.UpdatePrice(Int32.Parse(Request.Form["experience-price"]));

            model.Add("user", thisPerson);
            model.Add("experience", thisExperience);

            return(View("ViewExperienceUser", model));
        }
Exemple #5
0
        public ActionResult BookExperience(int userId, int experienceId)
        {
            Dictionary <string, object> model = new Dictionary <string, object> ();

            Person     thisPerson     = Person.Find(userId);
            Experience thisExperience = Experience.Find(experienceId);
            Booking    newBooking     = new Booking(userId, experienceId);

            newBooking.Save();

            model.Add("user", thisPerson);
            model.Add("experience", thisExperience);
            model.Add("booking", newBooking);

            return(View("BookingConfirm", model));
        }
Exemple #6
0
        public void Update_UpdatesDescriptionInDatabase_String()
        {
            // Arrange
            Experience testExperience = new Experience(1, 2, "Sky Diving", "Blah Blah..", "/hjfsddjf.com", 150);

            testExperience.Save();
            string newDescription = "Bungee jumping";

            // Act
            testExperience.UpdateDescription(newDescription);

            string result = Experience.Find(testExperience.GetId()).GetDescription();

            // Assert
            Assert.AreEqual(newDescription, result);
        }
Exemple #7
0
        public void Update_UpdatesPriceInDatabase_Int()
        {
            // Arrange
            Experience testExperience = new Experience(1, 2, "Sky Diving", "Blah Blah..", "/hjfsddjf.com", 150);

            testExperience.Save();
            int newPrice = 180;

            // Act
            testExperience.UpdatePrice(newPrice);

            int result = Experience.Find(testExperience.GetId()).GetPrice();

            // Assert
            Assert.AreEqual(newPrice, result);
        }
Exemple #8
0
        public ActionResult ViewExperienceViaCity(int experienceId)
        {
            Experience thisExperience = Experience.Find(experienceId);

            return(View("ViewExperience", thisExperience));
        }
Exemple #9
0
        public void Output_Word_zdts()
        {
            try
            {
                if (id == 0)
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true);
                    return;
                }
                Student  stu      = Student.FindById(id);
                string   basePath = Server.MapPath("../../");
                Document doc      = new Document(basePath + "Template/在读台生情况信息表.doc");
                //姓名
                Bookmark bookmark = doc.Range.Bookmarks["Name"];
                bookmark.Text = stu.Name == null ? "" : stu.Name;
                //性别
                bookmark      = doc.Range.Bookmarks["Sex"];
                bookmark.Text = stu.Sex == null ? "" : (bool)stu.Sex ? "女" : "男";
                //出生年月
                bookmark      = doc.Range.Bookmarks["Birth"];
                bookmark.Text = stu.Birthday == null ? "" : ((DateTime)stu.Birthday).ToString("yyyy.MM.dd");
                //证件号码
                bookmark      = doc.Range.Bookmarks["CertificateNum"];
                bookmark.Text = stu.IdentityNo == null ? "" : stu.IdentityNo;
                //就读学校
                bookmark      = doc.Range.Bookmarks["School"];
                bookmark.Text = stu.School == null ? "" : stu.School;
                //专业
                bookmark      = doc.Range.Bookmarks["Subject"];
                bookmark.Text = stu.Major == null ? "" : stu.Major;
                //学制
                bookmark      = doc.Range.Bookmarks["StudyYear"];
                bookmark.Text = stu.SystemOfEdu == null ? "" : stu.SystemOfEdu;
                //联系电话
                bookmark      = doc.Range.Bookmarks["Phone"];
                bookmark.Text = stu.PhoneNo == null ? "" : stu.PhoneNo;
                //就读类别
                bookmark      = doc.Range.Bookmarks["StudyTypeText"];
                bookmark.Text = StudyType.FindOne(CK.K["StudyTypeId"] == stu.StudyTypeId && CK.K["IsDelete"] == false).StudyTypeText;
                //入学日期
                bookmark      = doc.Range.Bookmarks["JoinSchoolDate"];
                bookmark.Text = stu.JoinSchoolDate == null ? "" : ((DateTime)stu.JoinSchoolDate).ToString("yyyy.MM.dd");
                //在沪居住地
                bookmark      = doc.Range.Bookmarks["SHAddress"];
                bookmark.Text = stu.AddressOfH == null ? "" : stu.AddressOfH;
                //备注
                bookmark      = doc.Range.Bookmarks["Memo"];
                bookmark.Text = stu.Tip == null ? "" : stu.Tip;
                //家庭主要成员
                DataTable dt_fa = FamilyOfStudent.Find(CK.K["Student_Id"] == id && CK.K["IsDelete"] == false).ToDataTable();
                if (dt_fa.Rows.Count > 0)
                {
                    int fa_count = dt_fa.Rows.Count <= 5 ? dt_fa.Rows.Count : 5;
                    for (int i = 0; i < fa_count; i++)
                    {
                        //姓名
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Name"];
                        bookmark.Text = dt_fa.Rows[i]["Name"].ToString();
                        //性别
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Sex"];
                        bookmark.Text = dt_fa.Rows[i]["Sex"].ToString().IsNullOrEmpty() ? "" : Convert.ToBoolean(dt_fa.Rows[i]["Sex"].ToString()) ? "女" : "男";;
                        //出生年月
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Birth"];
                        bookmark.Text = dt_fa.Rows[i]["Birthday"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_fa.Rows[i]["Birthday"].ToString()).ToString("yyyy.MM.dd");
                        //与本人关系
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Relation"];
                        bookmark.Text = dt_fa.Rows[i]["Relationship"].ToString();
                        //工作单位
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Department"];
                        bookmark.Text = dt_fa.Rows[i]["Company"].ToString();
                        //备注
                        bookmark      = doc.Range.Bookmarks["Fa_" + i + "_Memo"];
                        bookmark.Text = dt_fa.Rows[i]["Tip"].ToString();
                    }
                }
                //学习经历
                DataTable dt_Exp = Experience.Find(CK.K["Student_Id"] == id && CK.K["IsDelete"] == false).ToDataTable();
                if (dt_Exp.Rows.Count > 0)
                {
                    int exp_count = dt_Exp.Rows.Count <= 10 ? dt_Exp.Rows.Count : 10;
                    for (int i = 0; i < exp_count; i++)
                    {
                        //姓名
                        bookmark      = doc.Range.Bookmarks["Exp_" + i + "_Start"];
                        bookmark.Text = dt_Exp.Rows[i]["StartTime"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_Exp.Rows[i]["StartTime"].ToString()).ToString("yyyy.MM.dd");
                        //性别
                        bookmark      = doc.Range.Bookmarks["Exp_" + i + "_End"];
                        bookmark.Text = dt_Exp.Rows[i]["EndTime"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_Exp.Rows[i]["EndTime"].ToString()).ToString("yyyy.MM.dd");
                        //出生年月
                        bookmark      = doc.Range.Bookmarks["Exp_" + i + "_School"];
                        bookmark.Text = dt_Exp.Rows[i]["School"].ToString();
                    }
                }

                ////插入图片
                //DocumentBuilder builder = new DocumentBuilder(doc);
                //builder.MoveToBookmark("Photo");
                //var img = builder.InsertImage(basePath + "upload/photos/" + photoName);
                //img.Width = 165;
                //img.Height = 240;
                //img.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;

                string fileNameWithOutExtention = Guid.NewGuid().ToString();
                doc.Save(basePath + "upload/word_zdts/" + fileNameWithOutExtention + ".pdf", SaveFormat.Pdf);
                FileStream fs   = new FileStream(basePath + "upload/word_zdts/" + fileNameWithOutExtention + ".pdf", FileMode.Open);
                byte[]     file = new byte[fs.Length];
                fs.Read(file, 0, file.Length);
                fs.Close();
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("在读台生情况信息表-" + stu.Name + ".pdf", System.Text.Encoding.UTF8));
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                Response.ContentType     = "application/octet-stream";
                Response.BinaryWrite(file);
                Response.End();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载失败,请重新再试!')", true);
                return;
            }
        }