private void LoadUsers()
        {
            cbUsers.Items.Clear();

            if (GlobalVariables.CurrentUser.UserName.Equals("Admin"))
            {
                ListNGSObject listNGSObject = new ListNGSObject();
                userList = listNGSObject.GetListOfUsers();
            }
            else
            {
                userList = new List <User>();
                userList.Add(GlobalVariables.CurrentUser);
            }

            foreach (User u in userList)
            {
                cbUsers.Items.Add(u.UserName);
            }

            for (int i = 0; i < cbUsers.Items.Count; i++)
            {
                if (cbUsers.Items[i].ToString() == GlobalVariables.CurrentUser.UserName)
                {
                    cbUsers.SelectedIndex = i;
                }
            }
        }
Beispiel #2
0
        private void LoadDocumentList()
        {
            lbCategoryList.Items.Clear();
            ListNGSObject list = new ListNGSObject();

            foreach (DocumentTemplateFlow flow in list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C"))
            {
                lbCategoryList.Items.Add(flow.DocumentTemplateFlowName);
            }
        }
Beispiel #3
0
        private void LoadCompany()
        {
            dgvComapny.Rows.Clear();
            ListNGSObject  listNGSObject = new ListNGSObject();
            List <Company> companyList   = listNGSObject.GetListOfCompany();

            foreach (Company c in companyList)
            {
                dgvComapny.Rows.Add(c.CompanyGUID, c.CompanyName);
            }
        }
        private void LoadCompany()
        {
            ListNGSObject listNGSObject = new ListNGSObject();

            companyList = listNGSObject.GetListOfCompany();

            foreach (Model.Company c in companyList)
            {
                lbComapny.Items.Add(c.CompanyName);
            }
        }
Beispiel #5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lbCategoryList.SelectedIndex > -1)
     {
         ListNGSObject list = new ListNGSObject();
         foreach (DocumentTemplateFlow flow in list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" &&
                                                                                        t.DocumentTemplateFlowName == lbCategoryList.Items[lbCategoryList.SelectedIndex].ToString()))
         {
             flow.Delete();
             MessageBox.Show("Kategoria została usunięta", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LoadDocumentList();
         }
     }
 }
Beispiel #6
0
        private void SaveCompany(int rowIndex)
        {
            ListNGSObject list = new ListNGSObject();

            bool           save        = true;
            List <Company> companyList = list.GetListOfCompany();

            foreach (Company c in companyList)
            {
                if (dgvComapny[1, rowIndex].Value != null && c.CompanyName == dgvComapny[1, rowIndex].Value.ToString() &&
                    (dgvComapny[0, rowIndex].Value == null || c.CompanyGUID != dgvComapny[0, rowIndex].Value.ToString()))
                {
                    GlobalVariables.ShowMessage("Podana nazwa firmy \"" + dgvComapny[1, rowIndex].Value.ToString() + "\"  już istnieje.", "Duplikat nazwy firmy.", 3);
                    save = false;
                }
            }

            if (save && dgvComapny[1, rowIndex].Value != null && (dgvComapny[0, rowIndex].Value == null || String.IsNullOrEmpty(dgvComapny[0, rowIndex].Value.ToString())))
            {
                if (NGSLicense.getNumberOfCompaniesRegistered() < rowIndex)
                {
                    GlobalVariables.ShowMessage("Twoja licencja nie pozwala mieć, więcej firm!", "Licencja - błąd", 3);
                    return;
                }

                Company c = new Company();
                c.CompanyGUID = GlobalVariables.GetNewGUID();
                c.CompanyName = dgvComapny[1, rowIndex].Value.ToString();
                dgvComapny[0, rowIndex].Value = c.CompanyGUID;

                c.Save();
            }
            else if (save && dgvComapny[1, rowIndex].Value != null &&
                     dgvComapny[0, rowIndex].Value != null && !String.IsNullOrEmpty(dgvComapny[0, rowIndex].Value.ToString()))
            {
                foreach (Company c in companyList)
                {
                    if (c.CompanyGUID == dgvComapny[0, rowIndex].Value.ToString())
                    {
                        c.CompanyName = dgvComapny[1, rowIndex].Value.ToString();
                        c.Update();
                        break;
                    }
                }
            }
        }
        public void LoadFields(DocumentTemplateFlow dtf)
        {
            ListNGSObject list = new ListNGSObject();

            fieldList = list.GetDocumentTemplateFlowFieldList(dtf.DocumentTemplateFlowGUID);

            if (fieldList.Count == 0)
            {
                this.Close();
            }
            else
            {
                foreach (String field in fieldList)
                {
                    dgvDefaultFields.Rows.Add(field, "");
                }
            }
        }
Beispiel #8
0
        private void LoadUsers()
        {
            listOfUsers = new List <User>();
            dgvUsers.Rows.Clear();
            if (GlobalVariables.CurrentUser.UserName.Equals("Admin"))
            {
                ListNGSObject list = new ListNGSObject();
                listOfUsers = list.GetListOfUsers();
            }
            else
            {
                listOfUsers.Add(GlobalVariables.CurrentUser);
            }

            foreach (User u in listOfUsers)
            {
                dgvUsers.Rows.Add(u.UserGUID, u.UserName, u.FirstName, u.LastName, "*****");
            }
        }
Beispiel #9
0
        public void LoadTreeDocuments()
        {
            tVDocuments.Nodes.Clear();

            ListNGSObject list = new ListNGSObject();

            documentTemplateList = list.GetDocumentTemplateList();
            documentTemplateFlowAssignmentList = list.GetDocumentTemplateFlowAssignmentList();
            documentTemplateFlowList           = list.GetDocumentTemplateFlowList();

            TreeNode root = new TreeNode("Dokumenty");

            LoadTreeDocuments(root, documentTemplateFlowList.Where(t => t.DocumentTemplateFlowType == "S" || t.DocumentTemplateFlowType == "L").ToList <DocumentTemplateFlow>());

            tVDocuments.ShowNodeToolTips = true;
            tVDocuments.Nodes.Add(root);

            TreeNode rejestrZbiorow = new TreeNode("Rejestr czynności");

            rejestrZbiorow.ContextMenu = GetMenuToRejestrZbiorow();
            tVDocuments.Nodes.Add(rejestrZbiorow);

            TreeNode dziennikLogow = new TreeNode("Dziennik logów");

            dziennikLogow.ContextMenu = GetMenuToDziennikLogow();
            tVDocuments.Nodes.Add(dziennikLogow);

            TreeNode nosnikiDataCare = new TreeNode("Nośniki w DataCare");

            nosnikiDataCare.ContextMenu = GetNosnikiDataCare();
            tVDocuments.Nodes.Add(nosnikiDataCare);

            TreeNode mojeDokumenty = new TreeNode("Moje dokumenty");

            LoadTreeDocuments(mojeDokumenty, documentTemplateFlowList.Where(t => t.DocumentTemplateFlowType == "C").ToList <DocumentTemplateFlow>());

            tVDocuments.Nodes.Add(mojeDokumenty);


            tVDocuments.CollapseAll();
        }
Beispiel #10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(tbNewCategory.Text))
            {
                ListNGSObject list = new ListNGSObject();
                if (list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" && t.DocumentTemplateFlowName == tbNewCategory.Text).Count() > 0)
                {
                    MessageBox.Show("Nie można dodac dwóch takich samych kategorii.", "NGSDocument - błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DocumentTemplateFlow dtf = new DocumentTemplateFlow();
                    dtf.DocumentTemplateFlowGUID = GlobalVariables.GetNewGUID();
                    dtf.DocumentTemplateFlowType = "C";
                    dtf.DocumentTemplateFlowName = tbNewCategory.Text;

                    dtf.Save();

                    MessageBox.Show("Kategoria została dodana.", "Infomracja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tbNewCategory.Text = "";
                    LoadDocumentList();
                }
            }
        }
Beispiel #11
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            ListNGSObject list = new ListNGSObject();

            documentList = list.GetDocumentListBySearchPhrase(tbDocumentSearch.Text);

            List <User> userList = list.GetListOfUsers();

            dgvDocumentSearch.Rows.Clear();

            foreach (Document d in documentList)
            {
                if (d is Document)
                {
                    dgvDocumentSearch.Rows.Add(((Document)d).DocumentGUID
                                               , d.DocumentName
                                               , d.CreatedDateTime
                                               , GetUserName(userList, d.CreatedBy)
                                               , ((Document)d).LastModifiedDateTime
                                               , GetUserName(userList, ((Document)d).LastModifiedBy)
                                               , ((Document)d).PrintedDateTime);
                }
            }
        }
Beispiel #12
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(cbCategory.Text))
            {
                MessageBox.Show("Musisz wybrać kategorię do której ma być przypisany szablon!", "Błąd - import szablonów", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (String.IsNullOrEmpty(tbNazwaSzablonu.Text))
            {
                MessageBox.Show("Musisz podać nazwę szablonu!", "Błąd - import szablonów", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!String.IsNullOrEmpty(tbTemplatePath.Text) && !String.IsNullOrEmpty(cbCategory.Text))
            {
                listOfFields = new Dictionary <string, FieldBeforeAfter>();
                System.IO.StreamReader stream = new System.IO.StreamReader(tbTemplatePath.Text, Encoding.GetEncoding("Windows-1250"));
                htmlDoc.Load(stream);

                string body = htmlDoc.DocumentNode.SelectNodes("//body")[0].InnerText.Replace(Environment.NewLine, " ").Replace("  ", " ");

                string before    = "";
                string after     = "";
                string fieldName = "";
                for (int i = 0; i < body.Length; i++)
                {
                    if (body[i] == '{' && i + 1 < body.Length && body[i + 1] == '#')
                    {
                        if (fieldName != "")
                        {
                            addToList(listOfFields, fieldName, null, after);
                        }

                        fieldName = "";
                        after     = "";
                        for (int j = i + 2; j < body.Length; j++)
                        {
                            if (body[j] == '#' && j + 1 < body.Length && body[j + 1] == '}')
                            {
                                addToList(listOfFields, fieldName, before, null);
                                i      = j + 1;
                                before = "";
                                break;
                            }
                            else
                            {
                                fieldName += body[j];
                            }
                        }
                    }
                    else
                    {
                        before += body[i];
                        if (fieldName != "")
                        {
                            after += body[i];
                        }
                    }
                }
                if (fieldName != "")
                {
                    addToList(listOfFields, fieldName, null, after);
                }

                //label3.Text = "Znaleziona " + listOfFields.Count + " pola w szablone.";
                stream.Close();

                if (cbValidEndDate.Checked == true)
                {
                    bool dateFiledExists = false;
                    foreach (FieldBeforeAfter fba in listOfFields.Values)
                    {
                        if (fba.FieldName == "DataWygasniecia")
                        {
                            dateFiledExists = true;
                        }
                    }

                    if (!dateFiledExists)
                    {
                        MessageBox.Show("Pole {#DataWygasniecia#} nie występuje w szablonie. Proszę odznacz ważność dokumentu lub dodaj do szablonu wymagane pole.", "Import szablonu błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                //IMPORT
                stream = new System.IO.StreamReader(tbTemplatePath.Text, Encoding.GetEncoding("Windows-1250"));
                string newBody = stream.ReadToEnd();
                foreach (FieldBeforeAfter fba in listOfFields.Values)
                {
                    newBody = newBody.Replace("{#" + fba.FieldName + "#}", "<ngs_input name='" + fba.FieldName + "' caption='" + fba.FieldName + "' style=\"background-color: #FFFF00;\">.......</ngs_input>");
                }

                newBody = newBody.Replace("<head>", "<head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\" />");

                DocumentTemplate dt = new DocumentTemplate();
                dt.DocumentHint         = "";
                dt.DocumentName         = tbNazwaSzablonu.Text;
                dt.DocumentTemplateGUID = GlobalVariables.GetNewGUID();
                dt.DocumentText         = newBody;
                dt.DocumentType         = "D";
                dt.DocumentEndDate      = cbValidEndDate.Checked ? "Y" : "N";
                dt.Save();
                stream.Close();

                ListNGSObject list = new ListNGSObject();



                DocumentTemplateFlowAssignment dtfa = new DocumentTemplateFlowAssignment();
                dtfa.DocumentPosition = 1;
                dtfa.DocumentTemplateFlowAssignmentGUID = GlobalVariables.GetNewGUID();
                dtfa.DocumentTemplateGUID     = dt.DocumentTemplateGUID;
                dtfa.DocumentTemplateFlowGUID = list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" && t.DocumentTemplateFlowName == cbCategory.Text).First().DocumentTemplateFlowGUID;

                dtfa.Save();

                MessageBox.Show("Szablon został zaimportowany", "Informacja - szablon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //((MainWindow)(this.Parent.Parent)).LoadTreeDocuments();
            }
        }