private void comboBox_MaHoChieu_SelectedIndexChanged(object sender, EventArgs e)
 {
     if(comboBox_MaHoChieu.SelectedItem != null)
     {
         ExportData Objdata = new ExportData((comboBox_MaHoChieu.SelectedItem as HoChieu).MaHoChieu);
         labelValue_GiaTri1.Text = Objdata.congTB.ToString();
         labelValue_GiaTri2.Text = Objdata.duongKhang.ToString() + " mét";
         labelValue_GiaTri3.Text = Objdata.KC_Cot.ToString() + " mét";
         labelValue_GiaTri4.Text = Objdata.KC_Hang.ToString() + " mét";
         labelValue_GiaTri5.Text = Objdata.chieuSauThem.ToString() + " mét";
         labelValue_GiaTri6.Text = Objdata.chieuSauToanBoLK.ToString() + " mét";
         labelValue_GiaTri7.Text = Objdata.chieuDaiBua.ToString() + " mét";
     }                   
 }
        private void CreateWordDocument(object filename, object saves)
        {
            object missing = Missing.Value;

            Word.Application wordApp = null;
            Word.Document doc = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            //word.Table table;
            if (File.Exists((string)filename))
            {
                DateTime today = DateTime.Now;
                object readOnly = false;
                object isvisible = false;                
                if(wordApp == null)
                {
                    wordApp = new Word.Application();
                }
                wordApp.Visible = false;
                /*doc = wordApp.Documents.Open(ref filename, ref missing, ref missing,
                                                ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing, ref missing);*/
                doc = wordApp.Documents.Open(ref filename);
                doc.ActiveWindow.Selection.WholeStory();
                //doc.Activate();
                ExportData Objdata = new ExportData(idHoChieu);
                //this.FindAndReplace(wordApp, "DonVi", txtDonviNo.Text.Trim());
                this.FindAndReplace(wordApp, "hour", (Objdata.thoiDiemNo.Hour.ToString() == String.Empty ? "" : Objdata.thoiDiemNo.Hour.ToString()) );
                this.FindAndReplace(wordApp, "minute", (Objdata.thoiDiemNo.Minute.ToString() == String.Empty ? "" : Objdata.thoiDiemNo.Minute.ToString()) );
                this.FindAndReplace(wordApp, "day", (Objdata.thoiDiemNo.Day.ToString() == String.Empty ? "" : Objdata.thoiDiemNo.Day.ToString()) );
                this.FindAndReplace(wordApp, "month", (Objdata.thoiDiemNo.Month.ToString() == String.Empty ? "" : Objdata.thoiDiemNo.Month.ToString()) );
                this.FindAndReplace(wordApp, "year", (Objdata.thoiDiemNo.Year.ToString() == String.Empty ? "" : Objdata.thoiDiemNo.Year.ToString()) );
                this.FindAndReplace(wordApp, "DiaDiemNo", (Objdata.congTruong.TenCongTruong == String.Empty ? "" : Objdata.congTruong.TenCongTruong) );
                this.FindAndReplace(wordApp, "TenDatDa", (Objdata.datDa.TenDatDa.ToString() == String.Empty ? "" : Objdata.datDa.TenDatDa.ToString()));
                Word.Range range = doc.Range(ref missing, ref missing);
                for (int i = 1; i < Objdata.danhSachLoKhoan.Count; i++)
                {
                    doc.Tables[2].Rows.Add();
                    doc.Tables[2].Rows[i + 1].Cells[1].Range.Text = Objdata.danhSachLoKhoan[i].ID.ToString();
                    doc.Tables[2].Rows[i + 1].Cells[3].Range.Text = (Objdata.danhSachLoKhoan[i].BanKinh * 2).ToString();
                    doc.Tables[2].Rows[i + 1].Cells[4].Range.Text = Objdata.chieuSauToanBoLK.ToString();
                    doc.Tables[2].Rows[i + 1].Cells[5].Range.Text = Objdata.KC_Cot.ToString();
                    doc.Tables[2].Rows[i + 1].Cells[6].Range.Text = Objdata.KC_Hang.ToString();
                    doc.Tables[2].Rows[i + 1].Cells[9].Range.Text = Objdata.chieuDaiBua.ToString();
                }
                Word.Range rangePic = doc.Tables[5].Range;
                String fullPath = Path.GetFullPath(Path.Combine((@"" + Application.StartupPath), @"..\..\"));
                rangePic.InlineShapes.AddPicture(fullPath + "Template\\ViewTemp.bmp", ref missing, ref missing, ref missing);
                // var shape = doc.Bookmarks["PicHere"].Range.InlineShapes.AddPicture(@"C:\2.jpg", false, true);
                // doc.InlineShapes.AddPicture(@""+Application.StartupPath +"\\Sodobaino.bmp", ref missing, ref missing, ranges);
                // shape.Width = 150;
                // shape.Height = 150;                 
            }
            else
            {
                MessageBox.Show("File not exits");
                return;
            }
            // saves filename
            doc.SaveAs2(ref saves, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing);
            MessageBox.Show("Create !!");
        }