Esempio n. 1
0
        private void bnOpen_Click(object sender, EventArgs e)
        {
            DataTable dt = dbCon.GetDataTable("spec_psycho");

            if (bufferDoc == null)
            {
                MessageBox.Show("Документ отсутствует в базе данных", "Сообщение");
                return;
            }

            try
            {
                String       tempFilePath = Path.GetTempPath() + @"\psycho.doc";
                FileStream   fs           = new FileStream(tempFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                BinaryWriter binWriter    = new BinaryWriter(fs);

//                Byte[] buffer = (Byte[])selRow["psycho_doc"];
                Byte[] buffer = this.bufferDoc;
                binWriter.Write(buffer);
                binWriter.Close();
                fs.Close();
                Word.Application wordApp = new Word.Application();
                wordApp.Visible = true;
                Object filename              = tempFilePath;
                Object confirmConversions    = true;
                Object readOnly              = true;
                Object addToRecentFiles      = true;
                Object passwordDocument      = Type.Missing;
                Object passwordTemplate      = Type.Missing;
                Object revert                = false;
                Object writePasswordDocument = Type.Missing;
                Object writePasswordTemplate = Type.Missing;
                Object format                = Type.Missing;
                Object encoding              = Type.Missing;;
                Object oVisible              = Type.Missing;
                Object openConflictDocument  = Type.Missing;
                Object openAndRepair         = Type.Missing;
                Object documentDirection     = Type.Missing;
                Object noEncodingDialog      = false;
                Object xmlTransform          = Type.Missing;

                Word.Document worddocument = worddocument = wordApp.Documents.Open(ref filename,
                                                                                   ref confirmConversions, ref readOnly, ref addToRecentFiles,
                                                                                   ref passwordDocument, ref passwordTemplate, ref revert,
                                                                                   ref writePasswordDocument, ref writePasswordTemplate,
                                                                                   ref format, ref encoding, ref oVisible,
                                                                                   ref openAndRepair, ref documentDirection, ref noEncodingDialog, ref xmlTransform);
            }
            catch (IOException ioe)
            {
                MessageBox.Show(ioe.Message.ToString(), "Ошибка");
            }
        }
Esempio n. 2
0
        private void LoadPsycho()
        {
//            dbCon = new ChildDBConnect(idSpec, "spec_psycho");
            dbCon = new ChildDBConnect(idSpec, "spec_psycho", typeDoc);

            dgPsycho.Columns.Add(new DataGridViewTextBoxColumn());
            dgPsycho.Columns[0].DataPropertyName = "id";
            dgPsycho.Columns[0].HeaderText       = "код";
            dgPsycho.Columns[0].Visible          = false;

            dgPsycho.Columns.Add(new DataGridViewTextBoxColumn());
            dgPsycho.Columns[1].DataPropertyName = "id_spec";
            dgPsycho.Columns[1].HeaderText       = "код";
            dgPsycho.Columns[1].Visible          = false;


            CalendarColumn col = new CalendarColumn();

            {
                col.DataPropertyName = "date_doc";
                col.HeaderText       = "Дата документа";
                col.Width            = 90;
                col.MinimumWidth     = 90;
                col.AutoSizeMode     = DataGridViewAutoSizeColumnMode.None;
            }
            dgPsycho.Columns.Add(col);

            DataGridViewTextBoxColumn textColumn = new DataGridViewTextBoxColumn();

            {
                textColumn.DataPropertyName = "name";
                textColumn.HeaderText       = "Наименование документа";
                textColumn.Width            = 200;
                textColumn.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            }
            dgPsycho.Columns.Add(textColumn);

            dgPsycho.DataSource = new DataView(dbCon.GetDataTable("spec_psycho"));
        }