[HttpGet("GetDocumentos")] // GET api/Documento/GetDocumentos
        public ActionResult GetDocumentos([FromQuery(Name = "PageNumber")] int PageNumber,
                                          [FromQuery(Name = "Rows")] int Rows)
        {
            DocumentoServices    documentoServices = new DocumentoServices();
            List <InfoDocumento> documentos        = documentoServices.returnDocumentos(PageNumber, Rows);
            int total = 0;

            string query = "SELECT COUNT(*) AS 'TOTAL' FROM [adpruebas_de_timbrado].[dbo].[admDocumentos];";

            string connString = DatabaseServices.GetConnString();

            using (SqlConnection sqlConnection = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(query, sqlConnection);
                sqlConnection.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        total = reader.GetInt32(0);
                    }
                }
            }

            ListOfDocuments listOfDocuments = new ListOfDocuments(documentos, PageNumber, total);
            string          jsonString;

            jsonString = JsonSerializer.Serialize(listOfDocuments);

            return(Ok(jsonString));
        }
        private void OnAddDocument()
        {
            Telerik.Windows.Controls.RadOpenFileDialog fileDialog = new Telerik.Windows.Controls.RadOpenFileDialog();
            fileDialog.Owner            = Application.Current.MainWindow;
            fileDialog.InitialDirectory = lastDirectory;
            fileDialog.RestoreDirectory = true;
            fileDialog.DefaultExt       = "pdf";
            fileDialog.Filter           = "pdf files (*.pdf)|*.pdf";
            bool?result = fileDialog.ShowDialog();

            if (result == null)
            {
                return;
            }
            if (result == false)
            {
                return;
            }

            // set the selected Directory as InitialDirectory for the next open
            FileInfo fileInfo = new FileInfo(fileDialog.FileName);

            lastDirectory = fileInfo.DirectoryName;

            // ReportFileName only contains filename relative to travelExpenseRoot directory
            SelectedFileName = fileDialog.FileName;

            employeeDocuments.Add(new EmployeeDocument
            {
                DateValidUntil             = null,
                DocumentContentDescription = string.Empty,
                DocumentType     = DocumentTypes.Contract,
                DocumentFileName = "",
                Employee         = selectedEmployee,
                EmployeeId       = selectedEmployee.Id
            });
            // Activate added item
            ListOfDocuments.MoveCurrentToLast();
            RaisePropertyChanged("ListOfDocuments");
            RaisePropertyChanged("SelectedDocument");
        }
Exemplo n.º 3
0
        private void InformationAboutPersonForm_Load(object sender, EventArgs e)
        {
            INNBox.Text          = INN;
            INNBox.Enabled       = false;
            person               = new Person(personRepository.Get(int.Parse(INN)));
            SernameBox.Text      = person.Surname;
            SernameBox.Enabled   = false;
            NameBox.Text         = person.Name;
            NameBox.Enabled      = false;
            MiddleName.Text      = person.MiddleName;
            MiddleName.Enabled   = false;
            DateBox.Text         = person.DataRogdeniya.ToShortDateString();
            DateBox.Enabled      = false;
            CityBox.Text         = person.RegistrationCity;
            CityBox.Enabled      = false;
            PhoneBox.Text        = person.ContactPhone;
            PhoneBox.Enabled     = false;
            TypePensyBox.Text    = (typePensyRepository.Get(int.Parse(INN))).ToString();
            TypePensyBox.Enabled = false;
            ListOfDocuments.Items.AddRange(documentRepository.GetAll().ToArray());

            documents = documentRepository.GetByID(int.Parse(INN));

            for (int i = 0; i < ListOfDocuments.Items.Count; i++)
            {
                for (int j = 0; j < documents.Length; j++)
                {
                    Document d = (Document)ListOfDocuments.Items[i];
                    if (documents[j].Equals(d))
                    {
                        ListOfDocuments.SetItemChecked(i, true);
                    }
                }
            }
            ListOfDocuments.MultiColumn = true;
            ListOfDocuments.ColumnWidth = 300;
            ListOfDocuments.Enabled     = false;
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <Document> documents = new List <Document>();

            for (int i = 0; i < ListOfDocuments.Items.Count; i++)
            {
                if (ListOfDocuments.GetItemChecked(i))
                {
                    documents.Add((Document)ListOfDocuments.Items[i]);
                }
            }
            try
            {
                if (statementRepository.Add(new Statement(
                                                new Person(
                                                    Convert.ToInt32(INNBox.Text),
                                                    SernameBox.Text,
                                                    NameBox.Text,
                                                    MiddleName.Text,
                                                    PhoneBox.Text,
                                                    CityBox.Text,
                                                    Convert.ToDateTime(DateBox.Text)),
                                                (TypePensy)TypePensyBox.SelectedItem,
                                                documents,
                                                DateTime.Now)))
                {
                    Close();
                }
                else
                {
                    OnError();
                };
            }catch (Exception ex)
            {
                OnError();
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if ((bool)button1.Tag)
            {
                ListOfDocuments.Enabled = true;
                PhoneBox.Enabled        = true;
                CityBox.Enabled         = true;
                DateBox.Enabled         = true;
                MiddleName.Enabled      = true;
                NameBox.Enabled         = true;
                SernameBox.Enabled      = true;
                ChangeButtonState();
            }
            else
            {
                ChangeButtonState();
                List <Document> docs = new List <Document>();
                for (int i = 0; i < ListOfDocuments.Items.Count; i++)
                {
                    if (ListOfDocuments.GetItemChecked(i))
                    {
                        docs.Add((Document)ListOfDocuments.Items[i]);
                    }
                }

                //List<Document> docs2 = new List<Document>();
                foreach (Document doc in documents)
                {
                    if (docs.Contains(doc))
                    {
                        docs.Remove(doc);
                    }
                }

                try
                {
                    if (statementRepository.Update(new Statement(
                                                       new Person(
                                                           Convert.ToInt32(INNBox.Text),
                                                           SernameBox.Text,
                                                           NameBox.Text,
                                                           MiddleName.Text,
                                                           PhoneBox.Text,
                                                           CityBox.Text,
                                                           Convert.ToDateTime(DateBox.Text)),
                                                       (TypePensy)TypePensyBox.SelectedItem,
                                                       docs,
                                                       DateTime.Now)))
                    {
                        Close();
                    }
                    else
                    {
                        OnError();
                    };
                }
                catch (Exception ex)
                {
                    OnError();
                }
            }
        }