1C:Enterprise 8.2 Development Basics Tutorial
-
Upload
ion-temciuc -
Category
Documents
-
view
218 -
download
1
Transcript of 1C:Enterprise 8.2 Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
1/114
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
2/114
ENTIRE COPYRIGHT TO SOFTWARE
AND DOCUMENTATION BELONGS TO 1C Company
By purchasing 1:Enterprise software system
you hereby agree to protect rights of 1C Company
and refrain from making copies of the software
and documentation without prior written permission from 1C Company.
1C, LLC, 19962012
1C Company, Moscow, 123056, P.O. 64
Sales Department: 21, Seleznevskaya st.,
Phone: +7 (495) 737-92-57,
Fax: +7 (495) 681-44-07,
E-mail: [email protected]
URL: www.1c.ru/eng, www.1c-dn.com
Software Development Group: A. Alekseev, A. Bezborodov, D. Beskorovainov, P. Vasilets,
A. Vinogradov, A. Volkov, N. Evgrafov, I. Golshtein, E. Gornostayev, G. Damie,
O. Derut, D. Zaretsky, D. Ivashov, S. Kopienko, N. Korsakov, S. Kravtchenko, A. Lakutin,
M. Leybovitch, G. Leontyev, A. Lekhan, A. Medvedev, E. Mitroshkin, S. Murzin, S. Nuraliev,
M. Otstavnov, D. Pavlenko, A. Plyakin, A. Rukin, D. Rusanov, D. Sluzhbin, A. Smirnov,
P. Solodky, V. Sosnovsky, A. Toporkov, V. Tunegov, V. Philippov, V. Cheremisinov,
P. Chikov, A. Chicherin, A. Shevtchenko.
Documentation: V. Baidakov, V. Dranishchev, E. Korolkova, A. Krayushkin, I. Kuznetsov, M. Lavrov,
A. Monichev, A. Plyakin, M. Radchenko.
Technical Support Group: O. Akulova, S. Alekseeva, O. Bagrova, O. Baklushina, A. Garifullina,
V. Davydova, O. Dmitryenko, L. Ermakova, M. Ershova, U. Zhestkov, O. Zavalskaya,N. Zayavlina, M. Zvonilov, M. Ivanova, G. Korobka, U. Lavrova, S. Lepeshkina, S. Mazurin,
S. Markov, J. Misan, A. Pavlikov, I. Panin, O. Pekhtereva, S. Postnova, A. Prokurovsky,
E. Romanova, G. Stepanenko, N. Stepanov, T. Tokareva, E. Shirokova.
QA Group: T. Akulova, A. Andriyanova, E. Antonova, M. Gubko, B. Ziatdinov, A. Kapralova,
S. Karasev, I. Karelin, A. Lapin, E. Litvinenko, E. Medvedev, O. Reader, E. Sitosenko,
E. Smirnova, E. Stetsenko, G. Fadeeva, S. Khrisanova, N. Shargunova.
Book Title: 1C:Enterprise 8.2. Development Basics Tutorial
Publication Number:
Publication Date:
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
3/114
Contents
Agreement on terms, designations and additional agreements ......................................... 5
1. Introduction ........................................................................................................................ 7
2. General provisions .............................................................................................................92.1. The task ........................................................................................................................... 9
2.2. Creating a new database ................................................................................................ 11
3. Constants .......................................................................................................................... 17
4. Catalogs ............................................................................................................................. 23
4.1. General description and purpose ................................................................................... 23
4.2. Hierarchy ....................................................................................................................... 25
4.3. Predefined elements ...................................................................................................... 27
4.4. Catalog attributes ........................................................................................................... 29
4.5. Tabular section .............................................................................................................. 334.6. Subordination ................................................................................................................ 36
4.7. Form. List form, Item form .......................................................................................... 37
5. Enumeration ..................................................................................................................... 45
6. Form controls ...................................................................................................................47
6.1. Field ............................................................................................................................... 47
6.1.1. Text box ..................................................................................................................48
6.1.2. Check box ...............................................................................................................50
6.1.3. Switch field .............................................................................................................51
6.2. Command ...................................................................................................................... 526.3. Group ............................................................................................................................. 54
6.3.1. Normal group ..........................................................................................................54
6.3.2. Command panel ......................................................................................................54
6.3.3. Group of pages ........................................................................................................55
6.4. Table .............................................................................................................................. 56
7. Event handler ...................................................................................................................57
8. Document ..........................................................................................................................59
8.1. Header attributes ........................................................................................................... 60
8.2. Document forms ............................................................................................................ 62
8.3. Attributes of the tabular section .................................................................................... 70
8.4. Printing out a document. The print wizard .................................................................... 77
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
4/114
4 1C:Enterprise 8.2. Development Basics Tutorial
9. Functional options ............................................................................................................ 85
10. Subsystems and interface .............................................................................................. 89
11. Information register....................................................................................................... 93
12. Query ............................................................................................................................. 101
13. Report. Data composition ............................................................................................ 109
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
5/114
Agreement on terms, designations
and additional agreements
The names of the dialog buttons, tabs, menu items and other objects will be givenin double quotes, for example, OK, Services, Institution, Contact, etc.
The menu items are indicated using a right arrow. For example, Help ControlPanel.
The practical assignments are divided into Workshops (tasks performed separately)and exercises (completed with the teacher). The practical assignments look likethis:
Workshop numberAssignment and objective of the workshop in bold italics.
(Then, in parentheses, the path to the desired catalog or document is shown
in italics).
The mechanism (tips) for performing the practical assignment is also
explained in italics.
Workshops marked with an asterisk are very complex assignments and not allstudents can perform them.
Important additions to the material are given in the section titled
IMPORTANT!
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
6/114
6 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
7/114
1. Introduction
The aim of the course is to give students a basic idea of how to work with the main
objects and mechanisms of the platform, give them skills for working in the systemby solving the so-called "end-to-end" example. The main focus in the course is onpreparing the students to work alone.
Besides mastering the material, students must study the documentation that comeswith the standard package, namely:
1C:Enterprise 8. Users manual
1C:Enterprise 8. Configuration and administration
1C:Enterprise 8. Description of the script language.
These books are essential insofar as the present handbook does not replace, butmerely supplements the program documentation with more specific examples andpractical exercises.
This book consists of separate chapters. Each chapter covers a separate topic usingspecific examples. In the examples, we explain the relevant procedures step-by-stepto help the student to master the material in the chapter.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
8/114
8 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
9/114
2. General provisions
2.1. The task
Suppose you are tasked with automating the operations of a wholesaler/retailer.
The company consists of two departments: administration and sales, and the latteris divided into wholesale and retail sales.
You must keep a list of employees as part of the companys personnel records.You must be able to provide information about the qualifications of each employee(where and when he or she studied), as well as information about his or her children
(Fig. 2.1). When the salary is set or changed, or when the employee is transferred toa different location, record this in the Personnel Order document
Fig. 2.1.
The company's primary business is the purchase and subsequent sale of goods andprovision of related services. You must keep a list of goods, services, suppliers andcustomers. All settlements with contacts are under contracts.
When you pay a supplier for goods, record this action as a Cash Outflow. Whenyou receive the goods, record this action in a Purchase Invoice.
Make sure you are able not only to pay suppliers, but employees of the company as
well.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
10/114
10 1C:Enterprise 8.2. Development Basics Tutorial
When you send goods to a buyer, record this action as a Goods Issue (Fig. 2.2).When you receive the payment for it, record it as a Cash Inflow (Fig.2.3). Makesure you are able to print out Goods Issues satisfactorily.
Fig. 2.2.
Fig. 2.3.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
11/114
112. General provisions
When selling goods, the company may need to keep foreign currency records. Youshould be able to turn this function on and off.
To analyze the company's operations, you must be able to find out the sales figuresfor each business unit in the current month. 2.4).
Fig. 2.4.
2.2. Creating a new database
The 1C:Enterprise 8.2 software suite includes a platform and applied solutions
developed on top of it to automate the activities of organizations and individuals.
The platform itself is not a software product for end users who work with the
applied solution (configuration) developed on this platform. Accordingly, the
system has two modes of operation: 1C:Enterprise (user mode) and Designer(intended for developers of applied solutions and database administrators).
We will start in design mode, since this is where existing configurations are
modified and new ones are created.
The first thing we need to do to complete the task at hand is to create a newdatabase. On the C:disk, create a directory called Introduction 8.2, then launch1C:Enterprise 8.2
The 1C:Enterprise Startup dialogue box appears (Fig.2.5).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
12/114
12 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 2.5.
Create a new database by clicking Add.
Next, follow the instructions on the screen. Since were creating a new database,we leave the radio button in the first window as-is (Fig. 2.6).
Fig. 2.6.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
13/114
132. General provisions
Next, select the second radio button, specifying that youre creating a new database,but not a standard one from a template (Fig. 2.7).
Fig. 2.7.
Then name the database you want to create. In this case, well call it Introduction to
1C:Enterprise 8 framework (Fig. 2.8).
Fig. 2.8.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
14/114
14 1C:Enterprise 8.2. Development Basics Tutorial
After that, you need to specify where to store the data contained in our database.For this purpose, we have already created a special folder, which we indicate in thesettings (Fig. 2.9).
Fig. 2.9.
In the next window, leave the default settings (Fig. 2.10). The new database hasnow been created.
Fig 2.10.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
15/114
152. General provisions
Now when you run 1C:Enterprise 8.2, you can work with the new database (Fig.2.11), and in both modes. You can switch between the modes by clicking theappropriate buttons 1C:Enterprise or Designer
Fig. 2.11.
Since our database lacks a structure for storing information, you must create one byopening a database in Designer mode. In the window that opens, open the Configu-ration window
Select Configuration-Open configuration. In the new window we see somethinglike this picture (Fig. 2.12):
Fig. 2.12.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
16/114
16 1C:Enterprise 8.2. Development Basics Tutorial
This window is called the configuration window, and the information containedin it is in the form of a configuration tree.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
17/114
3. Constants
The object known as Constantis used to store constant or quasi-constant data. The
important thing is that a single constant is designed to store only one value. Therecan be any number of constants in the system. Constants are created in the Designer,but are given values in user mode.
When creating the documents we will need information about the CEO of our firmas well as the companys name and registration date. This information will notchange, so you can use a constant to store it. Since the constant is used to store asingle value, you need to create three constants.
To create a new constant in the configuration object tree window, right-click on theConstantsbranch to call up the context menu, then selectAdd. (Fig 3.1)
Fig. 3.1.
After we select the item, the properties palette, showing the properties of theconstants, appears. (Fig 3.2)
Fig. 3.2.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
18/114
18 1C:Enterprise 8.2. Development Basics Tutorial
Henceforth you can call up this window by double-clicking on the correspondingbranch in the configuration object tree window, or throughPropertiesin the contextmenu, which you can call up using the right mouse button. (Fig 3.3)
Fig. 3.3.
We will need to fill in the following fields:
Name (the identifier of the constant). Since the system can have any number ofconstants, you must give each one a unique name.
Synonym (a name that is convenient for the user).
Data type (the type of data stored in the constant). For string data, you mustspecify a maximum string length and how the string is to be stored. The systemallows you to store strings of unlimited length.
The permissible length reflects how the system stores the strings. To store astring in the system, specify a certain place for it. Accordingly, we can fill theentire place by adding spaces to the string, or fill only the portion of the placethat we need to store our string. In our case, well use a 50-character string withvariable permissible length. When the length of the string is constant, the speci-fied value of the characters is always stored, with spaces added, if the string
itself being stored is shorter.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
19/114
193. Constants
Thus, we have created a data structure that will allow us to store the informationwe need, but have not entered the name of the CEO of our organization. In orderto specify the desired value directly, go into user mode (1C:Enterprise mode). Theuser should be able to use the new object which was previously absent. To do this,
select the menu item Tools - 1C:Enterpriseand reaffirm step-by-step that you wantto update the database (Fig. 3.4 and Fig. 3.5).
Fig. 3.4.
Fig. 3.5.
All of these actions must be done in order to enter the necessary information in usermode (Fig. 3.6 and Fig. 3.7).
Fig. 3.6.
Fig. 3.7.
Henceforth, if there is no need to change the data structure, you can launch the
database in the standard way (Fig. 2.11).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
20/114
20 1C:Enterprise 8.2. Development Basics Tutorial
We now move on to the creation of the following constant to enter our firmsregistration date. Repeat the steps we took before. In the configuration tree window(notice that new nesting levels have been added to the tree), right-click on Constantsto call up the context menu, then selectAdd(Fig. 3.8).
Fig. 3.8.
After we select the item, the properties palette of the constant that we createdappears. Fill in the fieldsName andSynonym, and specifyDate as the data type. Inthis case, a set of properties has changed compared to the properties possessed bythe constant OrganizationName, with String as the data type (Fig. 3.9).
Fig. 3.9.
The 1C:Enterprise 8 system can store dates with precision down to the second.We can manually specify the date contents (date, time, or date-and-time) we needdepending on the date contents with which it is convenient for us to work in this
case. In theDate Contentsfield you can choose one of three options: date, time, ordate-and-time. For our purposes we must choose Date, since were not concernedabout the time of day when our company was registered. We launch 1C:Enterprisein user mode and indicate the actual date of registration. Since we changed thedata saving structure in our database (added a new object), we must restructure thedatabase. This process is complicated, and the user obviously cannot work withthe object when its structure is being changed, so you may receive the followingwarning message (Fig. 3.10):
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
21/114
213. Constants
Fig. 3.10.
This message indicates that the database is open in user mode, and you need to exituser mode before you can restructure further. The user can use the new object onlyafter the changes are loaded (Fig. 3.11).
Fig. 3.11.
This example demonstrates clearly enough the basics of 1C:Enterprise 8.2.
During configuration, the necessary structures for storing information are created.
Later, during the execution stage, these structures will be filled with the necessarydata.
Working independently
Create a new constant called CEO to store information about the
CEO in the database.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
22/114
22 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
23/114
4. Catalogs
4.1. General description and purpose
A catalog is a list which the user fills out during execution, allowing the storageof reference information about objects of the same type. Each element of the listmay have a complex structure defined during configuration. The number of cata-logs is specified during configuration and can be arbitrary. By using a catalog, youcan avoid having to enter the same information many times, such as name of thecounterparty, and it also provides authentication throughout the system, such asidentification of the counterparty upon goods issue and payment.
To implement our record-keeping system in line with the customers require-
ments, we must store reference information about employees, departments, goods,customers and their contracts. Hence, we must create corresponding catalogs.
To create a new catalog in the configuration object tree, select the Catalogsbranch.Then right-click it to call up the context menu and select Add, or on the toolbar ofthe configuration object tree window in the menu Actions - Add, or on the toolbarof the configuration object tree window click theAddbutton (Fig. 4.1)
Fig. 4.1.
All these actions are identical and call up the configuration object editing window(Fig. 4.2). Henceforth, you can call up this window by double-clicking on theselected catalog.
Since the system can have several catalogs, you need to distinguish between them.
To distinguish one catalog from another, use the Nameproperty. The system callsup this catalog by name, so the name of the catalog is created according to the samerules as the names of the constants or the names of variables, i.e., do not use spacesor other special characters. The Synonym field contains a user-friendly representa-tion of the name without any restrictions. On the whole, everything is exactly thesame as for constants.
Well create the first catalog to store information about our products and services.For convenience, well indicate Name as the general concept Products, and forthe user well also enter the long form Goods & Services in the Synonym field.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
24/114
24 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 4.2.
At this point, weve successfully created a simple catalog and can now switch toEnterprises user mode and look at what weve just created (Fig. 4.3). We can
perform all the necessary actions when working with a catalog by clicking on Allactions and selecting the appropriate item from the dropdown menu.
Fig. 4.3.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
25/114
254. Catalogs
Enter the following data into the catalog (Fig. 4.4):
Fig. 4.4.
4.2. Hierarchy
The catalog we created allows us to work only with simple data sets. Questionsarise almost immediately. How do we deal with large volumes of data? Will it beconvenient to work with a list containing several hundred items? For convenience,you can make the catalog hierarchical, i.e., create a tree structure. The simplestanalogy is that of a hard drive, which contains many thousands of files located atvarious levels of a hierarchy, making it possible to navigate them quickly.
We want to make the Products catalog hierarchical, so in designer mode in theconfiguration object tree window we double-click on Products catalog to call upthe catalog editing window and switch to the Hierarchy tab. First, place a checkmark after Hierarchical catalog.The next field that we need to fill is Hierarchytype, where you can choose one of the two values Hierarchy of folders and itemsorHierarchy of elements. To find out why they are needed, consider the followingsituation.
Suppose were selling a computer. We assume it consists of a system unit, monitorand peripherals. We can sell them together or separately. In this case, the computermust be considered both a commodity and as a folder, as the node of a tree uniting
the components that comprise it. In this case, when there is no difference betweenthe grouping element and the elements being grouped, you must choose a hierarchyof elements.
Now consider another situation. Due to increasing demand, our organizationhas decided to focus on selling clothing and footwear. Accordingly, it will beconvenient to group our products in the catalog according to type. At the sametime, the grouping element itself will not have intrinsic value but will rather serveto ease navigation or as a unifying feature in the various reports from which youcan display the results. For this purpose, the handbook contains a separate type of
special items, which are called Catalog Group, and in order to use them you mustchooseHierarchy of groups and elements as the hierarchy type (Fig. 4.5). We can
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
26/114
26 1C:Enterprise 8.2. Development Basics Tutorial
also limit the number of hierarchy levels by placing a checkmark next toLimit thenumber of groups in the hierarchy and entering the required number in theNumberof hierarchy levels field.
The nature of the task requires us to make the Product catalog hierarchical, withHierarchy of groups and elements as the hierarchy type.
Fig. 4.5.
The appearance of the catalog will now change for the user. Groups now appear inaddition to the elements. Working with them is analogous to working with files andfolders in Windows Explorer (Fig. 4.6).
Fig. 4.6.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
27/114
274. Catalogs
You can create new elements and groups right in the desired group and can moveexisting ones from one group to another. Thus, after creating a convenient hierar-chical structure, the user can quickly and easily navigate within the catalog (Fig.4.7).
Fig. 4.7.
It should be noted that by choosingAll actions Display modeyou can choose oneof three ways to display the catalog.
Working independently
Create a new catalog called Departments for storing data about thedivisions of the organization. The catalog must have a hierarchy of
elements.
4.3. Predefined elements
For the convenience of the user, you can create the catalog elements in advance.
Unlike elements created interactively (or automatically) by the user, predefinedelements cannot be deleted. Furthermore, each predefined element of a cataloghas a unique name, which allows you to automatically refer to this element moreconveniently than to conventional catalog elements.
Now lets create a new catalog called Contacts, for storing data about our suppliersand customers. For the convenience of the end user, it is best to separate buyersand suppliers, which you can easily do through groups. Accordingly, the Contactscatalog must be made hierarchical. Next, using either the context menu in theconfiguration tree (Fig.4.8), or the Predefined button on theMiscellaneous tab (Fig.
4.9), we call up a window for editing the predefined elements of the catalog (Fig.4.10).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
28/114
28 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 4.8.
We can add new predefined groups and elements in the same way as in user mode.The difference will lie in the presence of an additional Name, a system attributewhich is subject to standard naming conventions and which will not be available tothe user in 1C:Enterprise mode.
Fig. 4.9.
Fig. 4.10.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
29/114
294. Catalogs
4.4. Catalog attributes
Heretofore we have been considering the catalog as a list of items, but now welltake a closer look at the elements of this list.
As we mentioned earlier, sometimes we need to store additional information for acatalog element. For this purpose, we have catalog attributes.
In the simplest case we consider the catalog as a table in which each element of thecatalog has a corresponding row in the table, with the columns of the table corre-sponding to its attributes. For a Catalog-type object, there is always a set of systemattributes such as Code andName.
Since the catalog is constantly updated with new items, you must somehow identifythem, and the Code attribute is usually intended for this purpose, while the Name
attribute is usually used to store the semantic information in the item.On the Data and Numbering tabs you must define the following properties of thecatalog code (Fig. 4.11 and Figure 4.12):
Autonumbering allows the system to automatically assign the following codewhen creating a new catalog item. This code can be changed later.
Check uniqueness is a function that ensures that each new code is unique. Beforerecording a new item, the system makes sure that no item with the same codeexists.
Code series defines the way in which the code is numbered
Within subordination (within each group) or Within subordination to the owner(is meaningful for the subordinate directories).
Fig. 4.11.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
30/114
30 1C:Enterprise 8.2. Development Basics Tutorial
Name length is the maximum number of characters that a name can occupy.
Code length is the maximum number of characters that the code can occupy.For example, when the code length is 10, the code itself can be equal to 1 or100000.
Code type defines whether the code is stored as an integer or a string. It shouldbe noted that in the case of a string code, the numbers are perceived as charac-ters. For example, the code 01 is distinguished from the code 001.
Fig. 4.12.
In addition to the system attributes, you can add your required attributes to thecatalog. To add a new attribute to the catalog, on theData tab, right-clickAttributesto call up the context menu and selectAdd (Fig. 4.12). You can perform the sameaction by selectingAdd from the toolbar of this field.
Fig. 4.13.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
31/114
314. Catalogs
Next, you need to define the properties of our attribute in the appropriate window.(Fig. 4.13). Henceforth, you can call up the attribute properties palette by double-clicking on this attribute, or by right-clicking it and selecting Properties. Letscreate a new attribute called Tax ID(of theNumbertype with length of 12).
For us, the following attribute properties will be significant:
Name the identifier of theattribute
Use defines to which element of the catalog, element or group, the attribute willrelate
Data type defines the data type of the attribute. The data type can be of a primi-tive, reference or composite type.
You can also use the attributes to complete the next task: we must store the nameof our contractor, but its very long. Since theName attribute is used system-wide,
certain restrictions are place on it, including with regard to its length. On the onehand, the name of our counterparty must be kept in the Name, attribute, but, on theother hand, it does not fit there. What can we do? In this case, in the Name attributewe can store a short version of contacts name for internal use, and store the fullname in an additional attribute, which can store the entire set of information.
Working independently
Create in the Contacts catalog a new attribute for storing the
contacts full legal name.The properties palette has some interesting peculiarities. First, you can use theright mouse button to specify that you want to display it as a list or set of tabs. InFig. 4.13 and Fig. 4.14 one and the same properties palette is displayed as a set oftabs and as a list. Furthermore, if you choose list, you can expand or collapse thecorresponding groups.
Fig. 4.14.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
32/114
32 1C:Enterprise 8.2. Development Basics Tutorial
Second, the toolbar has a button called Show only important. This saves the usertime by not requiring him to fill out the less frequently used properties. However,you should always remember that not all the properties are displayed in this case.
You should also note that you can also call up the properties palette for the entirecatalog. To do this, right-click on the corresponding branch in the configurationobject tree window and selectProperties. (Fig. 4.15). The title bar of the propertiespalette displays the name of the object whose properties are being displayed in thecurrent window.
Fig. 4.15.
Now consider the following situation: Suppose you want to enter information onthe division in which an employee works.
To do this, we add to the Configuration window a new catalog called Employeesand assign him the Unit attribute with data type CatalogRef.Departments. (Fig.4.16)
Fig. 4.16.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
33/114
334. Catalogs
In this case, the newly-created attribute will be filled with values from the Depart-ments catalog, bearing in mind that a link to the catalog itemDepartments will bestored in the Employees catalog, i.e., in effect, when we turn to the Departmentattribute of theEmployees catalog, we turn to an item in theDepartments catalog.
For example, for the employeeBalaganovwe indicated that he works in the Salesdepartment. Then, as a result of restructuring within the company, the name of thedepartment has changed from simply Sales to Sales Department. To record this inthe Departments catalog, we change the name of the corresponding item to SalesDepartment. Do we now need to change the name of the department in the Bala-ganov record? No, because the Employees catalog doesnt store the name of thedepartment, but rather a link to the catalog item, with all of its attributes.
Working independently
In the Contacts catalog, create a new attribute for storing the VAT
rate at which this product will be sold from now on.
4.5. Tabular section
Sometimes you need to store more than one value in an attribute. For example,suppose you want to store information on an employee's children. For this purpose,the system has a tabular section.
Tabular section is a table whose structure is defined during configuration, and thedata are entered by the user during execution. For a Catalog object you can nowcreate any number of tabular sections.
Suppose the client wants you to store information on the employee's children andwhere the employee studied. This information has no intrinsic value, and thereforeit must be an attribute of the catalog. Since we dont know how many children the
employee hasand he may have manywe must create not just an attribute, but atabular section.
A similar situation arises when it comes to information about the employee's educa-tion. And since theres no link between the two, we must store them separately.Thus, we need to create two tabular sections.
To create a tabular section for a catalog, right-click the Data tab and select Add.You can also right-click Tabular section in theconfiguration object tree window ofthe selected catalog and selectAdd to get the same result.(Fig. 4.17)
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
34/114
34 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 4.17.
From now on, the you can call up the properties palette by double-clicking on theselected tabular section. Since there can be several tabular sections, you must namethem. The name of a table must meet the same conditions as the names of catalogsor constants. Well call the first tabular section Children. (Fig. 4.18)
Fig. 4.18.
Well define whether this tabular section relates only to items, groups or both. Inour case, information about children in relation to the group of the catalog does notmake sense, so in the Use field we leave the valueFor item.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
35/114
354. Catalogs
Then we must define the structure of the tabular section. In our case the table mustcontain two columnsthe child's name and date of birth. We create two tabularsection attributes. The tabular section attributes are defined in the same way asthe catalog attributes. Right-click on the appropriate tabular section to call up the
context menu, then selectAdd Tabular section attribute. (Fig. 4.19)
Fig. 4.19.
To store data about the surname, name and patronymic (middle name) of the child,we create a 50-character string attribute and call it Name, and for the date ofbirth, respectively theBirthDate Date-type attribute withDate as the date contents,since we are not interested in the time of birth (Fig. 4.20).
Fig. 4.20.
In user mode, the catalog will now appear as shown in Fig. 4.21
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
36/114
36 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 4.21.
Working independently
Add a tabular section called Education in the Employees catalog
(Fig. 4.22)
Fig. 4.22.
4.6. Subordination
Consider the following scenario: settlements with contractors are conducted in thecontext of agreements, i.e., we may have several agreements with any given coun-
terparty. In principle, you can create a new catalog in which agreements are items,and use groups order to combine the agreements of a single counterparty. However,this method is not very convenient. First of all, when we have a large number ofcontacts, for the agreements we need to organize a system of nested groups of aneven more complex level. And second, we still have to manually search for thenecessary group of agreements corresponding to the selected counterparty. The1C:Enterprise 8 system allows us to select them at the system level. For our task,lets consider how this works in more detail.
Create a new catalog called Agreements. Lets assume that the number of agree-
ments with one customer will not be very big and we wont have to group them, sowell make the catalog non-hierarchical. To specify the settings for subordination,
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
37/114
374. Catalogs
go to the Owners tab. In the toolbar of the Catalog owner list window, chooseEditlist item. When we choose this item, we are shown a list from which to choose fromwhere to select the catalog owner. (Fig. 4.23). In our case, the Agreements catalogmust be subordinated to the Contacts catalog, i.e., the Contactscatalog will be the
Owner of the Agreements catalog (the system allows us to organize subordinationto multiple catalogs at the same time, but such a case in principle will not differ andwill not be considered in this course).
Fig. 4.23.
4.7. Form. List form, Item form
In user mode of 1C:Enterprise, the user doesnt work directly with the object thatstores information, but through the objectknown asForm. It should be noted that,depending on the user's current task, he or she can work with the same object usingvarious forms. For example, when working with the catalog, as with a list of items,you useList form, but when working with one item of this list, you use
Item form. If the developer didnt take any additional steps to configure the object,the system will automatically create the appropriate form with which the user willwork. If the automatic form does not suit the user for any reason, the developer cancreate the necessary form himself.
Lets create a list form for the catalog Contacts by going to the form tab and
creating a new list form using the designer (Fig. 4.24).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
38/114
38 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 4.24.
Well complete all the steps that the designer suggests. On the first tab, we indicatethat were creating a list form (Fig. 4.25).
Fig. 4.25.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
39/114
394. Catalogs
Then we mark the attributes of the catalog that we want to see (Fig. 4.26).
Fig. 4.26.
This will result in the creation of a form (Fig. 4.27).
Fig. 4.27.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
40/114
40 1C:Enterprise 8.2. Development Basics Tutorial
Open the Commands - Global command tab and drag the item Items.List.Current-Data.Ref to the left window in the Command panel (Fig. 4.28).
Fig. 4.28.
In the properties of the command panel item that appears, specify the headingAgreements(Fig.4.29)
Fig. 4.29.
Now, in user mode, you can view only those agreements that relate to the currentcounterparty in the list form of the Employees catalog and in the record for the user(Fig. 4.30).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
41/114
414. Catalogs
Fig. 4.30.
Similarly, you can create the item form for the catalog. For example, for theEmployees catalog, the item form will look like this (Fig. 4.31).
Fig. 4.31.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
42/114
42 1C:Enterprise 8.2. Development Basics Tutorial
Printing out a catalogUntil now, all the objects and mechanisms we have considered have been intendedfor entering data into the database. Of course, the user must be able to extract the
data, such as in a printable form.To print out a list of contractors, in the list form of the Contacts catalog, clickAllactions and select the menu item Output list (Fig.4.32).
Fig. 4.32.
Select the attributes of the catalog you want to print (Fig. 4.33).
Fig. 4.33.
The result is a table that can be printed or saved as an external file (Fig.4.34).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
43/114
434. Catalogs
Fig. 4.34.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
44/114
44 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
45/114
5. Enumeration
Enumeration is a non-hierarchical list of finite length which is populated with
values only during configuration. Each item of the list is a simple value (it doesnot have any details or attributes) and cannot be changed by the user. For example,if we know for certain that an employee may be hired either part-time or full-time,it is logical to create an enumeration with two items. Of course, you can create anew catalog, set predefined items in it and assign roles so that they cannot specifynew items, but enumeration is faster and easier to use for the programmer, systemand end user.
So then, we want to have information in our database about whether our employeeworks for the company full time or part time. How do we do this? Well, first of
all, this information must be specified for each employee, which means we need tocreate a new attribute of theEmployees catalog. Second, the employee can either befull-time or part-time, so it is logical to create a new enumeration and specify it asthe data type of our new catalog attribute.
Lets create a new enumeration called HiringTypes. To do this, right-click onEnumeration and selectAdd. (Fig. 5.1).
Fig. 5.1.
Specify the name HiringTypes , which automatically populates the Synonym fieldjust as it did for the catalogs. (Fig. 5.2).
On theDatatab, right-click Values and selectAdd, or select the appropriate buttonin the toolbar. The familiar properties palette appears (Fig. 5.3), in which we specifyName the enumeration values. Similarly, we create the following value.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
46/114
46 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 5.2.
Fig. 5.3.
Notice that, unlike the attributes of the catalog, the enumeration values must beplaced in the order in which the user wants to see them. You can change the orderof the enumeration values by using the toolbar buttonsMove up andMove down, orby the corresponding context menu items, which you can call up by right-clickingon the value you want.
At this point, in theEmployees catalog we add the new attributesHiringType
with data typeEnumRef.HiringTypes.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
47/114
6. Form controls
As mentioned above, the user does not work directly with the object, but with an
on-screen form, and the user can use various forms to work with one and the sameobject. The system allows developers to use a number of standard mechanisms(form controls) in combination to create almost any functionality and appearance.Its like building things with Legos; you can put the pieces together in variousways to create something completely new. Next, we consider a number of standardmechanisms in more detail. It should be borne in mind that these features of theon-screen form are not tied to any particular type of configuration items, so you canuse them for any on-screen form of any object.
Although various elements of the form are designed for various purposes and have
their own specific features, many properties will be important for all of them.Name is the system name, a unique identifier that allows you to work with the item
DataPath establishes a connection between what is displayed on the form andwhere the information is stored
Visible allows you to either show the object or hide it from the user
Accessibility allows the user to see the object, but does not allow him to interac-tively modify it
You can add any of the form items by right-clicking and selecting Add from the
context menu (Fig. 6.1).
Fig. 6.1.
For each form item, you can call up its properties palette to configure the necessarymechanisms by right-clicking it and selecting from the context menu.
6.1. Field
TheField form item is designed to display data on the form and enable the user tochange the data. Depending on its Type, its appearance can vary.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
48/114
48 1C:Enterprise 8.2. Development Basics Tutorial
6.1.1. Text boxIn the Employees catalog we have the HiringType attribute, but the user cannotwork with it. To work with it, you must place the attribute on the catalog item form.
TheField form item with Text box type makes it easier to work with this attribute.There are two ways to place on a form a text box that will show the data of theattribute. You can add a new form item by specifying the type Field (Fig. 6.2) andthen specifying in its propertiesDataPath, Type and Title (Fig. 6.3).
Fig. 6.2.
Fig. 6.3.
You can also use the left mouse button to drag the attribute out of the attributes
window to the form items window (Fig. 6.4).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
49/114
496. Form controls
Fig. 6.4.
The most important properties for the text box will be:
Title the text header that the user sees
Title position the position of the title relative to the text box
Ignore during input allows you to automatically move the cursor to the field whenediting items on the form.
Activate by default allows you to make the field active when the form is opened.
Warn on edit allows you to issue a warning to the user when he or she is editing thedata in the field, if WarnOnEdit is specified
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
50/114
50 1C:Enterprise 8.2. Development Basics Tutorial
6.1.2. Check boxBy using the checkbox on the form, you can display data with Boolean orNumberas the type.
Create an item form for theProductscatalog (Fig. 6.5).
Fig. 6.5.
Then add to the catalog the Service attribute withBoolean as the type so as to allowthe user to indicate whether this catalog item is a product or service. Now add thisattribute to the form by dragging the Service attribute from the attributes window tothe form items window (Fig. 6.6).
Fig. 6.6.
SinceBoolean attributes are conveniently displayed on the form as a checkbox, thesystem will automatically indicate this type of field (Fig. 6.7).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
51/114
516. Form controls
Fig. 6.7.
For the checkbox, the most important properties for us will be the following:
Title the text header that the user sees
Title position the position of the title relative to the checkbox
6.1.3. Switch fieldSwitch field is designed to give the user a choice of one of several predefinedoptions.
In the Products catalog, for each item well indicate its quality, which may beone of three: high, normal and low. To do this, create a new enumeration calledGoodsQuality consisting of three values. Now in the Products catalog, add thenew attribute GoodsQuality with the appropriate data type. In the properties of theattribute, indicate the initial (default) value (Fig. 6.8).
Fig. 6.8.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
52/114
52 1C:Enterprise 8.2. Development Basics Tutorial
To create the required number of switch items, use SelectionList
(Fig. 6.9).
Fig. 6.9.
For the switch, the most important properties for us will be the following:
Title the text header that the user sees
Title position defines the position of the title relative to the switch items.
Selection list defines the items of the switch, how many there are of them, how theyare to be represented on the form and the selected values.
Number of columns defines the appearance of the switch (Fig. 6.10).
Fig. 6.10.
6.2. Command
Command allows the user to perform any of the actions that were predefined duringconfiguration. These actions can be described in a script in the form module andthen linked with the form (Fig.6.11) in the form of a button (or hyperlink) and beexecuted when the user clicks on this object.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
53/114
536. Form controls
Fig. 6.11.
Text of the procedure that is performed when the button is clicked:
&AtClient
Procedure Command1(Command)
Message ("Button is pressed.");
EndProcedure
Command may also perform any of the standard actions that the platform allowsyou to perform on an object (Fig. 6.12).
Fig. 6.12.
The following properties will be important for the button:
Title is a textual representation of the object on the form.
Type causes the command to appear as a button or hyperlink.
CommandName establishes a relationship between the form object and the actionbeing performed.
Picture allows you to place on the form the image that is displayed depending ontheDisplaysettings.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
54/114
54 1C:Enterprise 8.2. Development Basics Tutorial
6.3. Group
Group allows you to bring together several items located close to each other on the
form in order to work with them. Its appearance can change depending on the Typeproperty.
6.3.1. Normal groupThe item known as Groupitem withNormal group as the type allows you to visu-ally combine several items on the form and control where they appear on the form(Fig.6.13).
Fig. 6.13.
For a normal group, the most important properties are:
Display defines the appearance of the group on the form
Grouping defines how the items within the group are located on the form
6.3.2. Command panelThe command panel is a set of commands that can be either standard or created bythe developer (Fig. 6.14).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
55/114
556. Form controls
Fig. 6.14.
6.3.3. Group of pages
The groups withPages andPage as the type allow you to place items on the formin the form of several layers of pages. To do this, create a Pages-type group andthen for each page within it create a Page-type group (Fig. 6.15), and place theform items on it in the usual order.
Fig. 6.15.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
56/114
56 1C:Enterprise 8.2. Development Basics Tutorial
The following properties are important for us:
PagesRepresentation- for the Pages group sets how the tabs are displayed on theform.
Title- for thePage group sets the title on the tab of the form.
6.4. Table
Table allows you to display a table on the form, such as a tabular section of anobject (Fig. 6.16).
Fig. 6.16.
A table may include various items such as a command panel, fields and groups,thus defining how the table appears on the form.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
57/114
7. Event handler
When you need to have actions performed automatically in response to user actions,
use the event handler.We store the short and long versions of the counterpartys name in the Contactscatalog. It is logical to assume that these names will be similar. Therefore, whena user enters a short name, it is desirable to replicate it in full, i.e., perform certainactions in conjunction with a name change. The system cannot predict what actionswe want to perform when an event occurs, so we must write our own procedurefor the system to perform and link this process to the event that is being processed(Fig. 7.1).
Fig. 7.1.
Text of the event handler procedure:
&AtClient
Procedure DescriptionOnChange(Item)
If Object.FullDescription="" Then
Object.FullDescription = Object.Description;
EndIf;EndProcedure
Besides being able to perform actions when an event occurs, you can sometimesmanage the event itself, i.e., indicate whether the event will happen or not.
Consider the following scenario: Suppose you need to set a VAT of only 18%on services. In this case, when you save a catalog item, you must make sure it isa service. If a Product item is a service and VAT is not 18%, the program mustinform the user that this is not allowed and refuse to record the item until the user
either specifies the correct VAT rate or specifies that it is a product.To solve this problem, we use the event handlerBeforeWriteAtServer (Fig.7.2).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
58/114
58 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 7.2.
Text of the procedure:
&AtServer
Procedure BeforeWriteAtServer(Cancel, CurrentObject, WriteParameters)
If CurrentObject.Service And
(CurrentObject.VATRateBase Catalogs.VATRates.VAT18) Then
Message(The service can have the VAT rate only 18%");
Cancel = True;
EndIf;
EndProcedure
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
59/114
8. Document
Document is the type of configuration object designed for recording day-to-day
events that happen within a company in the system and corresponds to the gener-ally-accepted concept of a document. A document is uniquely defined by its type,number and date. The date of the document is stored in the date-and-time formatwith precision down to the second. You can create any number of various types ofdocuments.
To record a completed payment, create a new document type. Creating a new docu-ment type is the same as creating a new catalog. In the configuration object treewindow, right-click onDocuments and selectAdd. In the new window, specify theName of the document, i.e., its type. This name is subject to the same restrictions as
the names of other configuration objects. Lets call itExpenseCashAssets and Cashoutflowas the Synonym (Fig. 8.1). Next, we need to determine the structure of ourdocument based on its attributes.
Fig. 8.1.
Depending on their purpose, all attributes can be divided into those that occuronce and those that are repeated. Accordingly, the attributes of a document aredivided into those of the header and those of the tabular section. For example, agoods received note usually indicates the supplier and a list of the goods receivedfrom him, and in this case the supplier will be the attribute of the header, while themerchandise will be the attribute of the tabular section.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
60/114
60 1C:Enterprise 8.2. Development Basics Tutorial
8.1. Header attributes
When a cash outflow occurs, well assume that its more convenient for the
customer to work with each payment separately, so in this case the document willonly have the attributes of the header.
Fig. 8.2.
As we have already stated, documents always have the attributesDate andNumber.In the editing window of theExpenseCashAssets document on theNumbering tab,set the following properties related to its date and number (Fig. 8.2):
Autonumbering a checkbox that toggles automatic creation of the documentnumber when it is created. You can change the number later.
Number length
is the maximum number of characters the document number canoccupy.
Check uniqueness is a checkbox that toggles automatic checking of the docu-ment number. The system warns you if an action is in violation of the numberingrules.
Number type specifies the data type of the document number. It may be anumber or string. On the one hand, it is convenient when the documents arenumbered in sequence, but sometimes you need to specify not only a number ina sequence, but also the prefix of the document (a letter or string of letters). In
this case, the entire number must be defined as a string, i.e., practically the sameas the catalog code.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
61/114
618. Document
Periodicity. The numbering of documents is usually not open-ended, but withina certain time interval, most often in years. The system allows for this byoffering the following periodicity options:
Non-periodicWithin a yearWithin a quarterWithin a month
Within a day
For the documentExpenseCashAssets lets change the number length to 6 charac-ters and the periodicity to Within a year.
According to the task, you must keep records of settlements with contacts in thecontext of agreements. Furthermore, the documentExpenseCashAssets must allow
us to pay not only suppliers, but employees as well. To fulfill this requirement, youmust create new attributes of theExpenseCashAssets document. We need to createthree attributes:
Counterparty
Agreement
Amount.
Fig. 8.3.
On the Data, tab in the same way as was done for the catalog, add the new
attributes. (Fig. 8.3) Specify the Name of the attribute, its type and, if necessary,
additional settings for the type, such as, for example, the string length or the
precision of the number. Since the system already stores information about contacts
and agreements, the type of the attributes Counterparty and Agreement you must
specify CatalogRef.Contacts and CatalogRef.Agreements. For the attributeAmount
you must not only specify theNumber type, butprecision 2 as well, so that you can
correctly enter the amount of money received. Furthermore, since you need to pay
not only contacts, but employees as well, for the attribute Counterparty you canindicate the aggregative data type CatalogRef.Contacts andCatalogRef.Employees.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
62/114
62 1C:Enterprise 8.2. Development Basics Tutorial
8.2. Document forms
In the same way as when working with a catalog, the user does not work directly
with the Document object, but through the on-screen form. Accordingly, whenworking with one document, use Document form (Fig. 8.4), and for working withmultiple documents of this type, useList form (Fig. 8.5).
Fig. 8.4.
Fig. 8.5.
If the auto-generated form is not satisfactory, you can create a corresponding formin the Designer using the form-handling mechanism we described earlier (Fig.8.6). However, you can specify some of the settings affecting the appearance and
behavior of the form without creating the form itself.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
63/114
638. Document
Fig. 8.6.
To ensure that the user can select only those agreements in the document form thatrelate to the selected counterparty, you must make the following settings (Fig. 8.7)
In the properties of the Agreement attribute, establish a connection between thechoice parameters and the Counterparty who must be the owner for theAgreement.
Fig. 8.7.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
64/114
64 1C:Enterprise 8.2. Development Basics Tutorial
The program provides ample opportunities for the user to configure the list formdirectly in 1C:Enterprise mode.
ClickAll actions in the document list form and selectList options in the menu thatappears. Then by marking the settings tab-by-tab (Fig. 8.8 - Fig. 8.12), the user cancause the form to be displayed in the most convenient way (Fig. 8.13).
Fig. 8.8.
Fig. 8.9.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
65/114
658. Document
Fig. 8.10.
Fig. 8.11.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
66/114
66 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.12.
Fig. 8.13.
Working independently
Create a document called Cash inflow (Fig. 8.14)
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
67/114
678. Document
Fig. 8.14.
Note that the user himself can, within certain limits, change the appearance of the
form (Fig. 8.15 and Fig. 8.16). To do this, select Change form from the drop-downlist that appears when you clickAll actions.
Fig. 8.15.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
68/114
68 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.16.
Until now, all the forms we have considered had a static appearance, which was setin the designer, but the appearance of the form can vary depending on the situation.
Since the attributes of the payer have meaning only when the payment is cashless,we will cause them to be hidden in all other cases. To make it easier to hide theattributes, group them together (Fig.8.17).
Fig. 8.17.
To make the attributes disappear when the payment method changes, use theOnChange event handler for the payment method (Fig. 8.18).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
69/114
698. Document
Fig. 8.18.
In addition, you must use the OnOpen event handler for the entire form (Fig.8.19).
Fig. 8.19.
Text of the event handler procedures in the CashInflow document form module (foreasier visualization, this code is not optimized for running in thin client mode):
&AtClient
Procedure PaymentMethodOnChange(Item)
Items.Group1.Visible=GetVisible(Object.PaymentMethod);EndProcedure
&AtServer
Function GetVisible(Method)
If Method=Enums.PaymentMethods.Noncash Then
Ret=True;
Else
Ret=False;
EndIf;
Return Ret;EndFunction
&AtClient
Procedure OnOpen(Cancel)
Items.Group1.Visible=GetVisible(Object.PaymentMethod);
EndProcedure
As a result, for the user in 1C:Enterprise mode the appearance of the form will
change over time depending on the users actions(Fig.8.20).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
70/114
70 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.20.
8.3. Attributes of the tabular section
In order to store not just a single value, but any number of values of the same type,we use a tabular section of the document. For each document we can define anynumber of tabular sections, each of which can contain any number of atttributes.
In our case, for the PurchaseInvoice document we need to create a tabular sectioncalled Goods with the attributes Goods, Quantity, Price and Amount with value
types CatalogRef.Product, Number with precision of 3 andNumber with precisionof 2, respectively. Creating a tabular section of the document is also identical tocreating a tabular section of a catalog. On the Data tab in the appropriate windowusing the context menu, we create a tabular section, and then its attributes (Fig.8.21).
For the Purchase Invoice document, the form will differ from the form of the Cashinflow and Cash outflow documents in that it has a tabular section. When you createan invoice, you must also pay attention to the connection between Agreement andCounterparty, as well as bring up the total of theAmount column.
To calculate the amount, use the OnChange event handlers for quantity and price(Fig. 8.22). Though the result of these handlers must be the same, for conveniencewe give 2 different ways of writing this action.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
71/114
718. Document
Fig. 8.21.
&AtClient
Procedure GoodsQuantityOnChange(Item)
Items.Goods.CurrentData.Total=
Items.Goods.CurrentData.Price*
Items.Goods.CurrentData.Quantity
EndProcedure
&AtClient
Procedure GoodsPriceOnChange(Item)CalculateRow = Items.Goods.CurrentData;
CalculateRow.Total = CalculateRow.Price * CalculateRow.Quantity;
EndProcedure
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
72/114
72 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.22.
Fig. 8.23.
In order to let the user see not only the sum in each row, but also the total for thedocument, in the properties of the Goods table we indicate that it is necessary to
output theFooter (Fig. 8.23). Then in the properties of the Total field we indicateFooter data (Fig. 8.24).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
73/114
738. Document
Fig. 8.24.
As a result, the user receives the following form (Fig. 8.25) for working with apurchase invoice.
Fig. 8.25.
Working independently
Create a Sales invoice document (Fig. 8.26 and Fig. 8.27)
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
74/114
74 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.26.
Fig. 8.27.
The SalesInvoice document has a more complicated structure than the
PurchaseInvoice document we considered earlier, so we use a number of additional
mechanisms to make it easier for the user. First, to ensure that the user can only
enter goods in the Goods tabular section and only services in the Services tabular
section, we set the choice parameters in the properties of the attributes (Fig. 8.28).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
75/114
758. Document
Fig. 8.28.
Second, since the user has already indicated the VAT rate at which each good mustbe sold, it is desirable to automatically insert the rate in the document. For this we
use the event handler OnChange for the product in the Goods table.Third, we need to calculate the amount of VAT according to the specified rate.Since the VAT rate is a reference to a catalog item, it is not subject to multiplica-tion. To obtain for each VAT rate the number for calculating the amount of VAT,in the VATRates catalog we add a new attribute calledRate (Fig. 8.29).
Fig. 8.29.
Furthermore, to allow the user to see the total sum of the document in the list form,
we must calculate the DocumentTotalattribute, for which we use the BeforeWrite
event handler. Since we want to handle this event not for the form, but for the objectitself, the text of the event handler procedure will be in the document module.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
76/114
76 1C:Enterprise 8.2. Development Basics Tutorial
&AtClient
rocedure GoodsVATAmountOnChange(Item)
CurRow = Items.Goods.CurrentData;
CurRow.Total = CurRow.SubTotal+CurRow.VATAmount;ndProcedure
&AtClient
rocedure GoodsVATRateOnChange(Item)
CurRow = Items.Goods.CurrentData;
RateNumber = GetRate(CurRow.VATRate);
CurRow.VATAmount = CurRow.SubTotal * RateNumber;
GoodsVATAmountOnChange(Item);
ndProcedure
&AtServerNoContext
unction GetRate(VATRate)
Ret = VATRate.Rate / 100;
Return Ret;
ndFunction
&AtClient
rocedure GoodsSubTotalOnChange(Item)
GoodsVATRateOnChange(Item);
ndProcedure
&AtClient
rocedure GoodsPriceOnChange(Item)
CurRow = Items.Goods.CurrentData;
CurRow.SubTotal = CurRow.Price * CurRow.Quantity;
ndProcedure
&AtClient
rocedure GoodsQuantityOnChange(Item)
GoodsPriceOnChange(Item);
ndProcedure
&AtClient
rocedure GoodsProductOnChange(Item)
CurRow = Items.Goods.CurrentData;
CurRow.VATRate = GetProductRate(CurRow.Product);
GoodsVATRateOnChange(Item);ndProcedure
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
77/114
778. Document
8.4. Printing out a document. The print wizard
To allow the user to print out documents, we use the print wizard. Go to theLayouts
tab and click Wizards (Fig. 8.30).
Fig. 8.30.
Following the instructions in the wizard (Fig. 8.31 Fig. 8.36), fill in all therequired fields.
Fig. 8.31.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
78/114
78 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.32.
Fig. 8.33.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
79/114
798. Document
Fig. 8.34.
Fig. 8.35.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
80/114
80 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 8.36.
The wizard then creates a new template (Fig. 8.37) as well as a new command, andthe following code will be created in the command module and manager module:
Procedure Print(Spreadsheet, Ref) Export
//{{_PRINT_WIZARD(Print)
Template = Documents.SalesInvoice.GetTemplate("Print");
Query = New Query;
Query.Text =
"SELECT
SalesInvoice.Agreement,
SalesInvoice.Contact,
SalesInvoice.Date,
SalesInvoice.DocumentTotal,
SalesInvoice.Employee,
SalesInvoice.Number,
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
81/114
818. Document
SalesInvoice.Goods.(
LineNumber,
Product,
Quantity,
Price,
SubTotal,
VATRate,
VATAmount,
Total
),
SalesInvoice.Services.(
LineNumber,
Product,
SubTotal,
VATAmount,
Total
)
FROM
Document.SalesInvoice AS SalesInvoice
WHERE
SalesInvoice.Ref IN (&Ref)";
Query.Parameters.Insert("Ref", Ref);
Selection = Query.Execute().Choose();
AreaCaption = Template.GetArea("Caption");
Header = Template.GetArea("Header");
AreaGoodsHeader = Template.GetArea("GoodsHeader");
AreaGoods = Template.GetArea("Goods");
AreaServicesHeader = Template.GetArea("ServicesHeader");
AreaServices = Template.GetArea("Services");
Footer = Template.GetArea("Footer");
Spreadsheet.Clear();
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
82/114
82 1C:Enterprise 8.2. Development Basics Tutorial
Spreadsheet.Put(AreaServicesHeader);
SelectionServices = Selection.Services.Choose();
While SelectionServices.Next() Do
AreaServices.Parameters.Fill(SelectionServices);
Spreadsheet.Put(AreaServices, SelectionServices.Level());
EndDo;
Footer.Parameters.Fill(Selection);
Spreadsheet.Put(Footer);
InsertPageBreak = True;
EndDo;
//}}
EndProcedure
Fig. 8.37.
In addition, thePrintbutton has appeared in the list form and document form on thecommand panel (Fig. 8.38). Click on it to print out the document.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
83/114
838. Document
Fig. 8.38.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
84/114
84 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
85/114
9. Functional options
The functional options are a mechanism that allows you to quickly enable or disable
the selected functionality in user mode.Create the following objects:
A boolean constant called CurrencyAccounting
A catalog called Currencies
In the document CashInflow,an attribute called Currencywith CatalogRef.Curren-ciesas the type
In the document SalesInvoicean attribute called Currencywith CatalogRef.Curren-cies as the type
A functional option called CurrencyAccounting(Fig. 9.1)
Fig. 9.1.
In the properties of the functional option we include the catalog and the attributeswe created (Fig. 9.2). Of course, we also need to add the attributes we created to thedocument forms. We then switch to 1C:Enterprise mode and do the following:
Set the value of the constant CurrencyAccounting False (unchecked) and open thedocuments CashInflow and SalesInvoice. In this case, the relevant attributes will behidden (Fig. 9.3). In addition, the Currency catalog will be unavailable to the user.
Now we set the constant to True and make sure the user has access to the objectsthat are responsible for currency accounting (Fig. 9.4).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
86/114
86 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 9.2.
Fig. 9.3.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
87/114
879. Functional options
Fig. 9.4.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
88/114
88 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
89/114
10. Subsystems and interface
Subsystem allows you to group various system objects according to any functional
sign.Lets create some subsystems and indicate their composition (Fig. 10.1). Keep inmind that all objects must be included in one subsystem or other.
Fig. 10.1.
As a result of these actions, an interface which is divided according to the subsys-tems has been automatically created for the user in 1C:Enterprise mode (Fig. 10.2).
Fig. 10.2.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
90/114
90 1C:Enterprise 8.2. Development Basics Tutorial
You will notice that for each subsystem there is an additional section on the parti-tion panel called Desktop. To activate this section, we create for all the object types(documents and catalogs), which we may want to see as the user, the list forms.After that, in the configuration properties (Fig. 10.3), open the desktop workspace.
In the window that appears, in both columns, we add all the list forms that wecreated (Fig. 10.4) and then hide them by unchecking the Visible checkbox.
Fig. 10.3.
Fig. 10.4.
In 1C:Enterprise mode, right-click the Desktop icon, select Desktop setup (Fig.
10.5) and indicate the forms of the objects that we as the user want to see on thedesktop (Fig. 10.6). In this way, the user can customize the functionality andappearance of the desktop (Fig. 10.7).
Fig. 10.5.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
91/114
9110. Subsystems and interface
Fig. 10.6.
Fig. 10.7.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
92/114
92 1C:Enterprise 8.2. Development Basics Tutorial
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
93/114
11. Information register
Sometimes its inconvenient to store information in a catalog. For example, if we
buy a product from a single vendor, the price isnt likely to change very often. Itwould be convenient to be able to store the price and automatically insert it intodocuments. To accomplish this task, we need to store the price for each vendor andfor each product we purchase from it. The task is much more complex if we decideto also store the price as part of an agreement. On the one hand, this is frequently-accessed information, i.e., it makes sense to store it in a catalog. On the other hand,it is difficult to store it, and many of the systems catalog capabilities are super-fluous in this case. Besides, we would like to be able to find values quickly. For thispurpose, there is a special object calledInformation register.
Working with the information register is similar to working with other objects.The register must be structured for the kind of information that will be stored init. If you want to store various types of information, you can create any number ofinformation registers.
Fig. 11.1.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
94/114
94 1C:Enterprise 8.2. Development Basics Tutorial
Creating a new register is similar to creating a new document or catalog (Fig. 11.1).Define the structure of the register on theData tab. (Fig. 11.2). The information westore in the register is located in a Resource, while the various contexts in which wewant to see the information is in Dimensions. In our case, we must store the price
for each product purchased under each agreement with each vendor, i.e., price inthe context of vendors, agreements and products. Consequently, the price must bea resource, while the vendor, agreement and product are dimensions. In this case,the system will make sure that for each unique set of measurement values there canbe only one value of the resource, i.e., there can be only one price for each itemunder each agreement. Of course, you must enter the appropriate data type for thedimensions and resources.
Fig. 11.2.
The user can enter information in the register in 1C:Enterprise mode using theappropriate list form list (Fig. 11.3).
Fig. 11.3.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
95/114
9511. Information register
To ensure that the price is automatically inserted in a Purchase Invoice, use theGoodsProductOnChange event handler. To get the desired price, we must extractonly the information we need now out of all the information stored in the register,i.e., filter it somehow. This can be done using a special object called Structure.
Then we apply the filter to our register to get the price we need.
The code is as follows:
&AtServer
Function GetPrice(Product)
FilterStructure = New Structure;
FilterStructure.Insert(Vendor",Object.Contact);
FilterStructure.Insert(Agreement",Object.Agreement);
FilterStructure.Insert(ebackslashes
Product",Product);
FilterResult = InformationRegisters.VendorPrices.Get(FilterStructure);
Return FilterResult.Cost;
EndFunction
AtClient
Procedure GoodsProductOnChange(Item)
CalculateRow = Items.Goods.CurrentData;
CalculateRow.Cost = GetPrice(CalculateRow.Nomenclature);
GoodsPriceOnChange(Item)
EndProcedure
The information register allows us to not only quickly retrieve information invarious contexts, but also accomplish a number of other tasks. Sometimes we want
to know the history of changes to certain information, such as currency exchangerates. In this case, we need to store the exchange rate for each currency every day.Applying what we learned above, we can add a new dimension calledDate to theinformation register. However, since this is a common occurrence, we do it at thesystem level. In the properties of the information register, you can indicate that it isperiodic (Fig. 11.4).
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
96/114
96 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 11.4.
Depending on the periodicity that we set for the information register, it can storeinformation that is unique to various periods, for example, one value for each year,
or one value for the month or day, etc. If the register is periodic, we add a dimen-sion calledPeriod, (Fig. 11.5 and Fig. 11.6) and the system allows fast access to theinformation we need for the selected time period.
Fig. 11.5.
Fig. 11.6.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
97/114
9711. Information register
Information stored in the information register can be linked with documents. Forexample, we can keep track of where each employee works and his or her salary,using an appropriate personnel order to assign him or her to the appropriate depart-ment and set his or her salary. On the one hand, if we create a document and
fill in the catalog attributes, all this information will be entered into the system.However, if we delete that same document, the information remains in the catalogand becomes irrelevant. To solve this problem, there is a document-posting mecha-nism which allows us to establish a relationship between the data in the registerand the document. Heres how it works: You can assign a status called Posted toa recorded document, which is determined by the value of the system attributePosted. When you assign this status, you trigger the posting event handler, in whichyou can describe which records in which register create the document. If this statusis removed (such as when it is marked for deletion), the records generated by this
document are automatically deleted from the registers. The status of the documentis displayed in the appropriate pictogram and may be changed by the user.
To accomplish this task, you need to create an information register calledInforma-tion about employees. Well assume that our organization does not have part-timeemployees, i.e., an employee can only work in one department and earn a salarythere. The structure of the information register must be as follows: dimensionEmployee and resourcesDepartment and Salary. Keep in mind that you can store areference value in a resourcein our case, a reference to the Departments catalog(Fig. 11.7).
Fig. 11.7.
Thereafter, our employees will probably eventually be able to move from onedepartment to another or receive another salary, so we set the periodicity of theregister as Within a month. Then to ensure that the data from the document is storedin the register, we must specify Subordinate to recorder as the write mode (Fig.
11.8). In this case, the register will show an additional field called Recorders, inwhich the document that created these records will be indicated.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
98/114
98 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 11.8.
Then we create a document called Personnel order. The document will have theattributesEmployee, Department and Salary (Fig. 11.9).
Fig. 11.9.
Since we want the document to create records in the register, go to the Registerrecords tab and set the following properties (Fig. 11.10):
Posting: Enable (for this document we can assign the Posted status)
Register records deletion isautomatic (i.e., after the posting of this document iscanceled, the records that it formed will be deleted in the registers)
Specify the registers in which the records will be created.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
99/114
9911. Information register
Fig. 11.10.
Then use the designer to create the code that will define which information will berecorded and where. To do this, click Register records wizard, and then manuallyor automatically usingFill expressions (Fig. 11.11).
Fig. 11.11.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
100/114
100 1C:Enterprise 8.2. Development Basics Tutorial
The wizard then creates an event handler procedure in the document module.
Procedure Posting(Cancel, Mode)//{{__REGISTER_REGISTERRECORDS_WIZARD
// This fragment was built by the wizard.// Warning
! All manually made changes will be lost next time you use the wizard.
// register InformationAboutEmployeesRegisterRecords.InformationAboutEmployees.Write = True;
Record = RegisterRecords.InformationAboutEmployees.Add();
Record.Period = Date;
Record.Employee = Employee;
Record.Department = Department;Record.Salary = Salary;
//}}__REGISTER_REGISTERRECORDS_WIZARD
EndProcedure
In 1C:Enterprise mode, users can post and unpost documents (Fig. 11.12).
Fig. 11.12.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
101/114
12. Query
Query is an object of the script language that is used to get information from the
database as a sample that is created according to specified rules.Lets try using this function to obtain information about the sales figures for thecurrent month for this or that department.
To learn how to create a query and see what it does, use the data processor of thequery console. Change the settings as follows (Fig. 12.1):
In the system preferences, specify startup mode Thick client (managed application).In the configuration properties, specify Use ordinary forms in managed applica-tion.
Fig. 12.1.
Open the data processor in 1C:Enterprise mode and create a new query (Fig. 12.2).
Fig. 12.2.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
102/114
102 1C:Enterprise 8.2. Development Basics Tutorial
Its easier to create a query using the Query Builder (Fig. 12.3).
Fig. 12.3.
Fig. 12.4.
Since our database doesnt have a direct connection between departments and sales,we divide the problem into parts. Using the first query, try to collect the data on theemployees sales (Fig. 12.4)
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
103/114
10312. Query
Fig. 12.5.
The result of this query will show us the sales data (Fig. 12.5), but lets processthem first to make it easier to work with them. To obtain general sales information,use the grouping function (Fig. 12.6 and Fig. 12.7).
Fig. 12.6.
-
8/22/2019 1C:Enterprise 8.2 Development Basics Tutorial
104/114
104 1C:Enterprise 8.2. Development Basics Tutorial
Fig. 12.7.
Since were interested in sales figures for a certain period of time, we specify theappropriate condition in the query (Fig. 12.8).
Fig. 12.8.
The value of the parameters themselves must be set manually by clicking Param-eters (Fig. 12.9).
Fig. 12.9.