Пример #1
0
        private void fillReport(ReportWord rp, List <MyImage> iList)
        {
            Patient patientInfo = new Patient().getPatientByNum(this.patientId);

            rp.insertText("NumId", this.checkId);
            rp.insertText("SickId", this.patientId);
            rp.insertText("Name", patientInfo.NameProperty);
            rp.insertText("Age", patientInfo.AgeProperty.ToString());
            rp.insertText("Address", patientInfo.AddrProperty);
            rp.insertText("Sex", patientInfo.SexProperty);
            rp.insertText("Telephone", patientInfo.TelephoneProperty);
            rp.insertText("Job", patientInfo.JobProperty);
            rp.insertText("Insurance", patientInfo.InsuranceIdProperty);
            rp.insertText("Cause", patientInfo.CauseCheckProperty);
            rp.insertText("Doctor", Session.Instance.UserName);
            rp.insertText("CreateTime", patientInfo.CreateTimeProperty.ToString(helper.getDateFormat(Settings.Default.datetimeFormat)));
            //validate text data
            if (txtList.Length > 0)
            {
                string[,] data = new string[txtList.Length, 2];
                for (int i = 0; i < txtList.Length; i++)
                {
                    string header = contentShowRp[i].Trim() + " : ";
                    data[i, 0] = header;
                    string content = txtList[i].Text.Trim();
                    if (content.EndsWith(","))
                    {
                        content = content.Remove(content.Length - 1);
                    }
                    data[i, 1] = content;
                }
                rp.createTable("table", data);
            }
            else
            {
                rp.searchReplace("<table>", "");
            }
            //validate image data
            if (iList.Count > 0)
            {
                rp.createImageTable("images", iList);
            }
            else
            {
                rp.searchReplace("<images>", "");
            }

            rp.insertText("Date", DateTime.Now.Day.ToString());
            rp.insertText("Month", DateTime.Now.Month.ToString());
            rp.insertText("Year", DateTime.Now.Year.ToString());
        }
Пример #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            rp = new ReportWord();
            //check number image select
            List <MyImage> iList = new List <MyImage>();

            foreach (int it in lRowSelected)
            {
                MyImage myImg = new MyImage();
                myImg.id        = it / 2;
                myImg.imagePath = imagePath + listNameImg[it / 2];
                object noteInfo = dgvMain.Rows[it - 1].Cells[1].Value;
                if (noteInfo != null)
                {
                    myImg.imageNote = noteInfo.ToString();
                }
                else
                {
                    myImg.imageNote = "";
                }
                iList.Add(myImg);
            }
            if (iList.Count == 0)
            {
                DialogResult result = MessageBox.Show("Bạn chưa chọn ảnh. Bạn có muốn tiếp tục xem báo cáo?", "Thông báo",
                                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
            }

            rp.openTemplateFile();
            fillReport(rp, iList);
            string tmp = Log.Instance.GetTempPath() + "tmp.docx";

            rp.saveFile(tmp, true);
        }