Beispiel #1
0
 private void InitializeCompanies(bool seller)
 {
     if (seller)
     {
         CompanyWSClient   ws   = new CompanyWSClient();
         editCompanyData[] data = ws.listCompaniesByFilter(
             new CompanyWS.Security {
             BinarySecurityToken = authToken
         },
             new listCompaniesByFilter {
             arg1 = new CompanySearchFilter {
             }
         });
         if (data != null)
         {
             foreach (var companyData in data)
             {
                 user_company.Items.Add(new CompanyComboboxItem {
                     Id    = companyData.id,
                     Label = companyData.companyData.name + " - " + companyData.companyData.idDocument
                 });
             }
         }
     }
 }
Beispiel #2
0
        public void FilterCompaniesTable()
        {
            CompanySearchFilter filter = new CompanySearchFilter
            {
                Name           = comp_name.Text,
                Description    = comp_desc.Text,
                City           = comp_city.Text,
                Region         = comp_region.Text,
                Country        = comp_country.Text,
                ZipCode        = comp_zipcode.Text,
                IdDocument     = comp_document.Text,
                IdDocumentType = comp_document_type.Text
            };
            CompanyWSClient ws = new CompanyWSClient();

            for (int indx = (companiesTable.RowCount * companiesTable.ColumnCount) - 1; indx >= companiesTable.ColumnCount; indx--)
            {
                companiesTable.Controls.RemoveAt(indx);
            }
            companiesTable.RowCount = 1;
            editCompanyData[] data = ws.listCompaniesByFilter(new CompanyWS.Security {
                BinarySecurityToken = authToken
            },
                                                              new listCompaniesByFilter {
                arg1 = filter
            });
            FillCompaniesTable(data);
        }
Beispiel #3
0
 private void edit_company_button_Click(object sender, EventArgs e)
 {
     if (!ValidateEmptyFields())
     {
         return;
     }
     try
     {
         CompanyWSClient ws = new CompanyWSClient();
         completeCompanyData(company.companyData);
         ws.editCompany(new Security {
             BinarySecurityToken = authToken
         },
                        new editCompany {
             arg1 = company
         });
         parentForm.FilterCompaniesTable();
         this.Close();
     } catch (FaultException <RepeatedDocumentException> ex)
     {
         ShowExceptionError("Ya hay otra empresa con dicho documento. Por favor, introduzca otro");
     }
     catch (FaultException <InvalidEntityException> ex)
     {
         ShowExceptionError("Error. No se han recibido todos los campos necesarios para completar la operación");
     }
 }
Beispiel #4
0
        private void EditCompany(dynamic sender, EventArgs e)
        {
            long                id  = sender.Tag;
            CompanyWSClient     ws  = new CompanyWSClient();
            findCompanyResponse res = ws.findCompany(new CompanyWS.Security {
                BinarySecurityToken = authToken
            },
                                                     new findCompany {
                arg1 = id, arg1Specified = true
            });
            CompanyForm form = new CompanyForm(authToken, this, res.@return);

            form.Show();
        }
Beispiel #5
0
        private void InitializeEditUser(bool seller)
        {
            dynamic source = seller ? user.userData.userData : user.userData;

            user_name.Text                   = source.name;
            user_surname.Text                = source.surname;
            user_email.Text                  = source.email;
            user_enabled.Checked             = source.accountEnabled;
            user_document.Text               = source.idDocument;
            user_username.Text               = source.username;
            user_document_type.SelectedIndex = user_document_type.FindStringExact(source.documentType + "");
            if (seller)
            {
                CompanyWSClient     ws  = new CompanyWSClient();
                findCompanyResponse res = ws.findCompany(new CompanyWS.Security {
                    BinarySecurityToken = authToken
                },
                                                         new findCompany {
                    arg1 = user.userData.companyId, arg1Specified = true
                });
                user_company.SelectedIndex = user_company.FindStringExact([email protected] + " - " + [email protected]);
            }
        }
Beispiel #6
0
        private void DeleteCompany(dynamic sender, EventArgs e)
        {
            long id = sender.Tag;
            UserSellerWSClient ws = new UserSellerWSClient();

            editUserSellerData[] sellers = ws.findSellersByCompanyId(new SellerWS.Security {
                BinarySecurityToken = authToken
            },
                                                                     new findSellersByCompanyId {
                arg1 = id, arg1Specified = true
            });
            if (sellers != null && sellers.Length > 0)
            {
                MessageBox.Show("No se puede eliminar la empresa. Todavía tiene usuarios asociados cuyos documentos son: " +
                                string.Join(", ", sellers.Select(seller => seller.userData.userData.idDocument)),
                                "No se puede borrar empresa",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            var confirmResult = MessageBox.Show("Está a punto de eliminar una empresa. " +
                                                "Esta acción no se podrá deshacer. ¿Desea continuar con la operación?",
                                                "Confirmar borrado",
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Warning);

            if (confirmResult == DialogResult.Yes)
            {
                CompanyWSClient companyWS = new CompanyWSClient();
                try
                {
                    removeCompanyResponse response = companyWS.removeCompany(new CompanyWS.Security {
                        BinarySecurityToken = authToken
                    },
                                                                             new removeCompany {
                        arg1 = id, arg1Specified = true
                    });
                    FilterCompaniesTable();
                }
                catch (FaultException <CompanyWS.ElementNotFoundException> ex)
                {
                    MessageBox.Show("Ha ocurrido un error. No se ha encontrado una empresa con id " + id + " en el sistema",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                catch (FaultException <CompanyWS.ArgumentException> ex)
                {
                    MessageBox.Show("Ha ocurrido un error. No se ha recibido el id de la empresa a eliminar",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                catch (FaultException <CompanyWS.CannotRemoveElementException> ex)
                {
                    MessageBox.Show("Ha ocurrido un error. No se puede eliminar la empresa porque todavía tiene usuarios asociados",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }