Пример #1
0
        public void InsertGraphic(string imgpath)
        {
            Object            dispatchHelper    = mxMSFactory.createInstance("com.sun.star.frame.DispatchHelper");
            XDispatchHelper   dispatcher        = dispatchHelper as XDispatchHelper;
            XModel            xModel            = mxDocument as XModel;
            XFrame            xFrame            = xModel.getCurrentController().getFrame();
            XDispatchProvider xDispatchProvider = xFrame as XDispatchProvider;

            unoidl.com.sun.star.beans.PropertyValue[] MyProp = new unoidl.com.sun.star.beans.PropertyValue[4];
            MyProp[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            MyProp[0].Name  = "FileName";
            MyProp[0].Value = new uno.Any(PathConverter(imgpath));
            MyProp[1]       = new unoidl.com.sun.star.beans.PropertyValue();
            MyProp[1].Name  = "FilterName";
            MyProp[1].Value = new uno.Any("<Tous les formats>");
            MyProp[2]       = new unoidl.com.sun.star.beans.PropertyValue();
            MyProp[2].Name  = "AsLink";
            MyProp[2].Value = new uno.Any(false);
            MyProp[3]       = new unoidl.com.sun.star.beans.PropertyValue();
            MyProp[3].Name  = "Style";
            MyProp[3].Value = new uno.Any("Image");
            dispatcher.executeDispatch(xDispatchProvider, ".uno:InsertGraphic", "", 0, MyProp);
        }
Пример #2
0
        public void CozdSchetWriter(string push, int ID)
        {
            DB5  db   = new DB5(kursach.Program.Pole.pole);
            DB16 db2  = new DB16(kursach.Program.Pole.pole);
            DB1  db1  = new DB1(kursach.Program.Pole.pole);
            DB14 db14 = new DB14(kursach.Program.Pole.pole);
            DB13 db13 = new DB13(kursach.Program.Pole.pole);

            Mapping.DB17 db17 = new Mapping.DB17(kursach.Program.Pole.pole);
            var          ec   = from n in db.JurnalRabot
                                where n.ID == Convert.ToInt32(ID)
                                select n;
            int temp = 0;

            foreach (var i in ec)
            {
                temp = i.IDZapisi;
            }
            var ec2 = from n in db2.Zapis
                      where n.ID == temp
                      select n;
            var Firma = from n in db17.Firma
                        where n.ID == 1
                        select n;
            string temp2 = "";

            foreach (var i in ec2)
            {
                temp2 = i.Data;
            }
            unoidl.com.sun.star.uno.XComponentContext     localContext        = uno.util.Bootstrap.bootstrap();
            unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
            XComponentLoader componentLoader = (XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
            XComponent       xComponent      = componentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);

            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().setString("Счет №" + ID + Environment.NewLine);

            unoidl.com.sun.star.text.XTextRange x = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x, "от " + temp2 + "г." + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);
            unoidl.com.sun.star.text.XTextRange xi = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd(); // в конец
            foreach (var i in Firma)
            {
                ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(xi, "ИНН " + i.INN + " КПП " + i.KPP + Environment.NewLine + "Получатель " + i.Name + " № Счета " + i.Schet + Environment.NewLine + "Банк получателя " + i.Bank + " № Счета банка " + i.SchetBank + Environment.NewLine, true);
            }

            DB11 db11       = new DB11(kursach.Program.Pole.pole);
            var  Raspisanie = from n in db11.Raspisanie
                              where n.ID == temp
                              select n;

            foreach (var i in Raspisanie)
            {
                temp = i.IDVrach;
            }
            var Vrach = from n in db14.Vrach
                        where n.ID == temp
                        select n;

            foreach (var i in Vrach)
            {
                temp2 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x2 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x2, "Исполнитель: " + temp2 + Environment.NewLine, true);

            foreach (var i in ec2)
            {
                temp = i.IDPacienta;
            }
            var ec3 = from n in db1.Pacient
                      where n.ID == temp
                      select n;

            foreach (var i in ec3)
            {
                temp2 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x3 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x3, "Заказчик: " + temp2 + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);

            //Таблица
            XFrame          frame           = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getCurrentController().getFrame();
            XDispatchHelper xDispatchHelper = (XDispatchHelper)multiServiceFactory.createInstance("com.sun.star.frame.DispatchHelper");

            unoidl.com.sun.star.beans.PropertyValue[] tableArgs = new unoidl.com.sun.star.beans.PropertyValue[4];
            tableArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[1]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[2]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[3]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[0].Name  = "TableName";
            tableArgs[0].Value = new uno.Any("Акт");
            tableArgs[1].Name  = "Columns";
            tableArgs[1].Value = new uno.Any(4);
            tableArgs[2].Name  = "Rows";
            tableArgs[2].Value = new uno.Any(2);
            tableArgs[3].Name  = "Flags";
            tableArgs[3].Value = new uno.Any(9);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Наименование Услуги");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertTable", "", 0, tableArgs);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs2 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Цена");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs3 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Скидка");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs3);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs4 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Итого");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs4);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec2)
            {
                temp = i.IDUslugi;
            }
            var ec5 = from n in db13.Uslugi
                      where n.ID == temp
                      select n;

            foreach (var i in ec5)
            {
                temp2 = i.Name;
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs5 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs5);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Cena.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs6 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs6);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Skidka.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs7 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs7);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Itog.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs8 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs8);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);

            unoidl.com.sun.star.text.XTextRange x4 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x4, "Всего оказано услуг на сумму: " + temp2 + "рублей " + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);
            string temp3 = "";

            foreach (var i in Vrach)
            {
                temp2 = i.FIO;
            }
            foreach (var i in ec3)
            {
                temp3 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x5 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            foreach (var i in Firma)
            {
                ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x5, "Исполнитель:__________________ " + temp2 + Environment.NewLine + "Бухгалтер:__________________" + i.Buh, true);
            }
            ((XStorable)xComponent).storeToURL(@"file:///" + push.Replace(@"\", "/"), new unoidl.com.sun.star.beans.PropertyValue[0]);
            xComponent.dispose();
        }