public static bool DeleteSituation(int situationId)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             SituationToSpecialWork st = SituationToSpecialWork.FindById(situationId);
             st.IsDelete = true;
             st.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
 public static bool UpdateSituation(int situationId, DateTime time, string location, string situationName)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             SituationToSpecialWork st = SituationToSpecialWork.FindById(situationId);
             st.Time          = time;
             st.Location      = location;
             st.SituationName = situationName;
             st.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
 public static bool AddSituation(int communicationId, DateTime time, string location, string situationName)
 {
     try
     {
         DbEntry.UsingTransaction(delegate
         {
             SituationToSpecialWork st = new SituationToSpecialWork();
             st.Communication_Id       = communicationId;
             st.Time          = time;
             st.Location      = location;
             st.SituationName = situationName;
             st.IsDelete      = false;
             st.Save();
         });
     }
     catch { return(false); }
     return(true);
 }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (situationId != 0)//修改
         {
             btn_Add.Text = "确认修改";
             //回填
             try
             {
                 SituationToSpecialWork st = SituationToSpecialWork.FindById(situationId);
                 tb_time.Value     = DateTime.Compare((DateTime)st.Time, new DateTime(1900, 1, 1)) > 0 ? ((DateTime)st.Time).ToString("yyyy/MM/dd") : "";
                 tb_location.Text  = st.Location;
                 tb_Situation.Text = st.SituationName;
             }
             catch (Exception ex)
             {
                 text(ex.ToString());
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true);
             }
         }
     }
 }
Esempio n. 5
0
        public void Output_Word_zdts()
        {
            try
            {
                if (communicationId == 0)
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true);
                    return;
                }
                int selectedYear = Convert.ToInt32(ddl_year.SelectedValue);

                SpecialWork com      = SpecialWork.FindById(communicationId);
                string      basePath = Server.MapPath("../../");
                Document    doc      = new Document(basePath + "Template/专项工作情况表.doc");
                //对口交流地区
                Bookmark bookmark = doc.Range.Bookmarks["Exchange"];
                bookmark.Text = com.Exchange == null ? "" : com.Exchange;
                //交流对象类别
                bookmark      = doc.Range.Bookmarks["Type"];
                bookmark.Text = com.Type == null ? "" : com.Type;
                //姓名
                bookmark      = doc.Range.Bookmarks["Name"];
                bookmark.Text = com.Name == null ? "" : com.Name;
                //性别
                bookmark      = doc.Range.Bookmarks["Sex"];
                bookmark.Text = com.Sex == null ? "" : (bool)com.Sex ? "女" : "男";
                //出生年月
                bookmark      = doc.Range.Bookmarks["Birthday"];
                bookmark.Text = com.Birthday == null ? "" : ((DateTime)com.Birthday).ToString("yyyy.MM.dd");
                //工作单位
                bookmark      = doc.Range.Bookmarks["Company"];
                bookmark.Text = com.Company == null ? "" : com.Company;
                //联系电话
                bookmark      = doc.Range.Bookmarks["PhoneNo"];
                bookmark.Text = com.PhoneNo == null ? "" : com.PhoneNo;
                //类别
                bookmark      = doc.Range.Bookmarks["SpecialWorkTypeText"];
                bookmark.Text = SpecialWorkType.FindOne(CK.K["SpecialWorkTypeId"] == com.SpecialWorkTypeId && CK.K["IsDelete"] == false).SpecialWorkTypeText;
                //任期开始
                bookmark      = doc.Range.Bookmarks["WorkStartDate"];
                bookmark.Text = com.WorkStartDate == null ? "" : ((DateTime)com.WorkStartDate).ToString("yyyy.MM.dd");
                //任期结束
                bookmark      = doc.Range.Bookmarks["WorkEndDate"];
                bookmark.Text = com.WorkEndDate == null ? "" : ((DateTime)com.WorkEndDate).ToString("yyyy.MM.dd");
                //联系地址
                bookmark      = doc.Range.Bookmarks["Address"];
                bookmark.Text = com.Address == null ? "" : com.Address;
                //得票数
                bookmark      = doc.Range.Bookmarks["Ballot"];
                bookmark.Text = com.Ballot == null ? "" : com.Ballot.ToString();
                //是否连任
                bookmark      = doc.Range.Bookmarks["IsReelect"];
                bookmark.Text = com.IsReelect == null ? "" : (bool)com.IsReelect ? "是" : "否";
                //社会关系及人脉
                bookmark      = doc.Range.Bookmarks["Background"];
                bookmark.Text = com.Background == null ? "" : com.Background;
                //工作单位情况
                bookmark      = doc.Range.Bookmarks["Situation"];
                bookmark.Text = com.Situation == null ? "" : com.Situation;
                //交流情况表
                DataTable dt_fa = SituationToSpecialWork.Find(CK.K["Communication_Id"] == communicationId && CK.K["IsDelete"] == false && CK.K["Time"] >= (new DateTime(selectedYear, 1, 1)) && CK.K["Time"] <= (new DateTime(selectedYear, 12, 31))).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["Si_" + i + "_Time"];
                        bookmark.Text = dt_fa.Rows[i]["Time"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_fa.Rows[i]["Time"].ToString()).ToString("yyyy.MM.dd");
                        //地点
                        bookmark      = doc.Range.Bookmarks["Si_" + i + "_Lo"];
                        bookmark.Text = dt_fa.Rows[i]["Location"].ToString();
                        //交流情况
                        bookmark      = doc.Range.Bookmarks["Si_" + i + "_Si"];
                        bookmark.Text = dt_fa.Rows[i]["SituationName"].ToString();
                    }
                }


                ////插入图片
                if (!com.PhotoName.IsNullOrEmpty())
                {
                    DocumentBuilder builder = new DocumentBuilder(doc);
                    builder.MoveToBookmark("Photo");
                    var img = builder.InsertImage(basePath + "upload/photos/" + com.PhotoName);
                    img.Width  = 115;
                    img.Height = 150;
                    img.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
                }

                string fileNameWithOutExtention = Guid.NewGuid().ToString();
                doc.Save(basePath + "upload/word_zxgz/" + fileNameWithOutExtention + ".pdf", SaveFormat.Pdf);
                FileStream fs   = new FileStream(basePath + "upload/word_zxgz/" + 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("专项工作情况表-" + ddl_year.SelectedItem.Text + "-" + com.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;
            }
        }