Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            hasTheSaveButtonPressed = true;

            bool ok;

            UsernameToBeReturned = txtUsername.Text;

            if (!string.IsNullOrEmpty(txtPassword.Text) || txtPassword.Text.Length > 2)
            {
                Credential credential = new Credential();

                credential.CredentialId          = GlobalCredentialId;
                credential.CredentialDescription = txtDescription.Text;
                credential.Username = txtUsername.Text;
                credential.Password = txtPassword.Text;

                //UPDATE
                ok = DALHelpers.UpdateCredential(credential);

                if (ok == false)
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void btnDeleteDealer_Click(object sender, EventArgs e)
        {
            if (dgvDealer.Rows.Count > 0)
            {
                DealerBranch dealerBranch = new DealerBranch();

                dealerBranch.DealerBranchId = Convert.ToInt32(dgvDealer.CurrentRow.Cells[0].Value.ToString());
                dealerBranch.CTDI           = Convert.ToInt32(dgvDealer.CurrentRow.Cells[1].Value.ToString());
                dealerBranch.DealerName     = dgvDealer.CurrentRow.Cells[2].Value.ToString();
                dealerBranch.BranchName     = dgvDealer.CurrentRow.Cells[3].Value.ToString();
                dealerBranch.PhoneNumber    = dgvDealer.CurrentRow.Cells[4].Value.ToString();
                dealerBranch.BaldoPartner   = dgvDealer.CurrentRow.Cells[5].Value.ToString();
                dealerBranch.CountryId      = Convert.ToInt32(dgvDealer.CurrentRow.Cells[6].Value.ToString());
                dealerBranch.CountryName    = dgvDealer.CurrentRow.Cells[7].Value.ToString();
                dealerBranch.DealerId       = Convert.ToInt32(dgvDealer.CurrentRow.Cells[8].Value.ToString());

                if (MessageBox.Show("Are you sure you want to delete the Dealer Branch: " + dealerBranch.BranchName + "?", "Delete Dealer Branch", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    DALHelpers.DeleteDealerBranch(dealerBranch.DealerBranchId);

                    ActivityLog.DealerBranchLogger(dealerBranch, "DELETE", "Dealer Branch", Environment.UserName);

                    Validation.LocalDatabaseConfig(true);
                    dealerBranchesList = loadDealerBranches();
                }

                dgvDealer.ClearSelection();
                txtSearchDealer.Clear();
                btnDeleteDealerBranch.Enabled = false;
                btnEditDealerBranch.Enabled   = false;
            }
        }
Ejemplo n.º 3
0
        private List <App> loadApplications()
        {
            var countryList = new List <App>();

            applicationList = DALHelpers.GetApplications();

            dgvApplications.DataSource = null;
            dgvApplications.Rows.Clear();
            dtApplications.Clear();

            foreach (App app in applicationList)
            {
                dtApplications.Rows.Add(

                    app.ApplicationId.ToString(),
                    app.ApplicationName.ToString(),
                    app.ApplicationId.ToString() + app.ApplicationName.ToString());
            }

            dgvApplications.DataSource         = dtApplications;
            dgvApplications.Columns[0].Width   = 100;
            dgvApplications.Columns[1].Width   = 280;
            dgvApplications.Columns[0].Visible = false;
            dgvApplications.Columns[2].Visible = false;

            dgvApplications.Sort(dgvApplications.Columns["Application Name"], ListSortDirection.Ascending);

            return(applicationList);
        }
Ejemplo n.º 4
0
        private void btnDeleteApplication_Click(object sender, EventArgs e)
        {
            if (dgvApplications.Rows.Count > 0)
            {
                int    CountryId   = Convert.ToInt32(dgvApplications.CurrentRow.Cells[0].Value.ToString());
                string CountryName = dgvApplications.CurrentRow.Cells[1].Value.ToString();

                if (MessageBox.Show("Are you sure you want to delete the Application " + CountryName + "?", "Delete Application", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    App app = new App();

                    app.ApplicationId   = Convert.ToInt32(dgvApplications.CurrentRow.Cells[0].Value.ToString());
                    app.ApplicationName = dgvApplications.CurrentRow.Cells[1].Value.ToString();

                    DALHelpers.DeleteApplication(CountryId);

                    ActivityLog.ApplicationLogger(app, "DELETE", "", Environment.UserName);

                    Validation.LocalDatabaseConfig(true);
                    //databaseViewModel = Services.GetDataFromDatabase();
                    loadApplications();
                }

                dgvApplications.ClearSelection();
                txtSearchApplication.Clear();
                btnEditApplication.Enabled   = false;
                btnDeleteApplication.Enabled = false;
            }
        }
Ejemplo n.º 5
0
        private void btnDeleteCredential_Click(object sender, EventArgs e)
        {
            if (dgvCredentials.Rows.Count > 0)
            {
                int    CredentialId          = Convert.ToInt32(dgvCredentials.CurrentRow.Cells[0].Value.ToString());
                string CredentialDescription = dgvCredentials.CurrentRow.Cells[1].Value.ToString();

                if (MessageBox.Show("Are you sure you want to delete the credential " + CredentialDescription + "?", "Delete Credential", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Credential credential = new Credential();

                    credential.CredentialId          = Convert.ToInt32(dgvCredentials.CurrentRow.Cells[0].Value.ToString());
                    credential.CredentialDescription = dgvCredentials.CurrentRow.Cells[1].Value.ToString();
                    credential.Username = dgvCredentials.CurrentRow.Cells[2].Value.ToString();
                    credential.Password = dgvCredentials.CurrentRow.Cells[3].Value.ToString();

                    DALHelpers.DeleteCredential(CredentialId);

                    ActivityLog.CredentialLogger(credential, "DELETE", "Credential", Environment.UserName);

                    Validation.LocalDatabaseConfig(true);
                    //databaseViewModel = Services.GetDataFromDatabase();
                    loadCredentials();
                }

                dgvCredentials.ClearSelection();
                txtSearchCredential.Clear();
                btnEditCredential.Enabled   = false;
                btnDeleteCredential.Enabled = false;
            }
        }
Ejemplo n.º 6
0
        public frmShowDealerContacts(int MainDealerId, string DealerName, string Branch, string CNPJ, string CTDI, int CountryId)
        {
            InitializeComponent();

            dealerContactList = DALHelpers.GetDealerContactByDealerId(MainDealerId);

            dtDealerContacts.Columns.Add("DealerContactId", typeof(string));
            dtDealerContacts.Columns.Add("MainDealerId", typeof(string));
            dtDealerContacts.Columns.Add("Description", typeof(string));
            dtDealerContacts.Columns.Add("Department", typeof(string));
            dtDealerContacts.Columns.Add("Phone", typeof(string));
            dtDealerContacts.Columns.Add("CellPhone", typeof(string));
            dtDealerContacts.Columns.Add("Email", typeof(string));

            if (MainDealerId > 0)
            {
                GlobalDealerId = MainDealerId;
                this.Text      = "Dealer Contacts for: " + DealerName;

                if (CountryId == 55)
                {
                    grpDealer.Text = "Branch Specific Details: " + Branch;

                    txtCNPJ.Text = CNPJ;
                    txtCTDI.Text = CTDI;

                    this.Height = 348;
                }

                loadDealerContacts(MainDealerId);
            }
        }
Ejemplo n.º 7
0
        private List <Credential> loadCredentials()
        {
            var credentialList = new List <Credential>();

            credentialList = DALHelpers.GetCredentials();

            dgvCredentials.DataSource = null;
            dgvCredentials.Rows.Clear();
            dtCredentials.Clear();

            foreach (Credential credential in credentialList)
            {
                dtCredentials.Rows.Add(

                    credential.CredentialId.ToString(),
                    credential.CredentialDescription.ToString(),
                    credential.Username.ToString(),
                    Encryption.Decrypt(credential.Password.ToString()),
                    credential.Username.ToString() + credential.CredentialDescription.ToString());
            }

            dgvCredentials.DataSource         = dtCredentials;
            dgvCredentials.Columns[1].Width   = 189;
            dgvCredentials.Columns[2].Width   = 140;
            dgvCredentials.Columns[3].Width   = 140;
            dgvCredentials.Columns[0].Visible = false;
            dgvCredentials.Columns[4].Visible = false;

            dgvCredentials.Sort(dgvCredentials.Columns["Description"], ListSortDirection.Ascending);

            return(credentialList);
        }
Ejemplo n.º 8
0
        private List <Country> loadCountries()
        {
            var countryList = new List <Country>();

            countryList = DALHelpers.GetCountries();

            dgvCountries.DataSource = null;
            dgvCountries.Rows.Clear();
            dtCountries.Clear();

            foreach (Country country in countryList)
            {
                dtCountries.Rows.Add(

                    country.CountryId.ToString(),
                    country.CountryName.ToString(),
                    country.CountryId.ToString() + country.CountryName.ToString());
            }

            dgvCountries.DataSource         = dtCountries;
            dgvCountries.Columns[0].Width   = 100;
            dgvCountries.Columns[1].Width   = 210;
            dgvCountries.Columns[2].Visible = false;

            dgvCountries.Columns["Country Code"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvCountries.Sort(dgvCountries.Columns["Country Code"], ListSortDirection.Ascending);

            return(countryList);
        }
Ejemplo n.º 9
0
        private List <Dealer> loadDealers()
        {
            var dealerlList = new List <Dealer>();

            dealerlList = DALHelpers.GetDealers();

            dgvDealer.DataSource = null;
            dgvDealer.Rows.Clear();
            dtDealers.Clear();

            foreach (Dealer dealer in dealerlList)
            {
                dtDealers.Rows.Add(

                    dealer.DealerId.ToString(),
                    dealer.DealerName.ToString(),
                    dealer.CountryId.ToString(),
                    dealer.CountryName.ToString(),
                    dealer.DealerName.ToString() + dealer.CountryId.ToString() + dealer.CountryName.ToString());
            }

            dgvDealer.DataSource = dtDealers;

            dgvDealer.Columns[1].Width = 300;
            dgvDealer.Columns[3].Width = 100;

            dgvDealer.Columns[0].Visible = false;
            dgvDealer.Columns[2].Visible = false;
            dgvDealer.Columns[4].Visible = false;

            dgvDealer.Sort(dgvDealer.Columns["Country Name"], ListSortDirection.Ascending);

            return(dealerlList);
        }
Ejemplo n.º 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            hasTheSaveButtonPressed = true;

            Credential credential = new Credential();
            bool       ok         = false;

            if (Validation.CredentialDataValidation(txtUsername.Text, txtPassword.Text))
            {
                MessageBox.Show("Please enter the Credential details.");
                return;
            }
            else
            {
                credential.CredentialDescription = txtDescription.Text;
                credential.Username = txtUsername.Text;
                credential.Password = txtPassword.Text;
            }

            if (CredentialId > 0)
            {
                //UPDATE
                credential.CredentialId = CredentialId;
                ok = DALHelpers.UpdateCredential(credential);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }
                else
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Credential!");
                }

                this.Close();
            }
            else //NEW CREDENTIAL
            {
                List <Credential> credentialList = new List <Credential>();

                credentialList = DALHelpers.GetCredentialByUsername(credential.Username);
                if (credentialList.Count > 0)
                {
                    MessageBox.Show("Error: The ID: " + credential.Username + " ,already exists in the database!");
                }
                else
                {
                    //credential.CredentialId = DALHelpers.GetCredentialMaxId() + 1;
                    ok = DALHelpers.AddCredential(credential);

                    if (ok == true)
                    {
                        MessageBox.Show("The record was successfully saved!");
                    }
                }

                this.Close();
            }
        }
Ejemplo n.º 11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            hasTheSaveButtonPressed = true;

            Country country = new Country();
            bool    ok      = false;

            country.CountryId   = Convert.ToInt32(txtCountryCode.Text);
            country.CountryName = txtCountryName.Text;

            if (Validation.CountryDataValidation(country))
            {
                MessageBox.Show("Please enter the Contact details.");
                return;
            }

            if (CountryID > 0)
            {
                //UPDATE
                ok = DALHelpers.UpdateCountry(country, CountryID);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }
                else
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Country!");
                }

                ActivityLog.CountryLogger(country, "UPDATE", CountryName, CountryID, Environment.UserName);
                this.Close();
            }
            else //NEW COUNTRY
            {
                List <Country> countryList = new List <Country>();

                countryList = DALHelpers.GetCountryById(country.CountryId);
                if (countryList.Count > 0)
                {
                    MessageBox.Show("Error: The ID: " + country.CountryId + " already exists in the database!");
                    return;
                }
                else
                {
                    ok = DALHelpers.AddCrountry(country);

                    if (ok == true)
                    {
                        ActivityLog.CountryLogger(country, "CREATE", "", 0, Environment.UserName);
                        MessageBox.Show("The record was successfully saved!");
                    }
                }

                this.Close();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Contact contact = new Contact();
            bool    ok      = false;

            if (Validation.ContactDataValidation(txtUserID.Text, txtName.Text, txtPhone.Text))
            {
                MessageBox.Show("Please enter the Contact details.");
                return;
            }
            else
            {
                contact.Id       = txtUserID.Text;
                contact.Name     = txtName.Text;
                contact.Phone    = txtPhone.Text;
                contact.Computer = txtComputer.Text;
            }

            if (txtUserID.Enabled == false)
            {
                //UPDATE
                ok = DALHelpers.UpdateContact(contact);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }
                else
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Contact!");
                }

                this.Close();
            }
            else //NEW CONTACT
            {
                List <Contact> contactList = new List <Contact>();

                contactList = DALHelpers.GetContactById(contact.Id);
                if (contactList.Count > 0)
                {
                    MessageBox.Show("Error: The ID: " + contact.Id + " ,already exists in the database!");
                }
                else
                {
                    ok = DALHelpers.AddContact(contact);

                    if (ok == true)
                    {
                        MessageBox.Show("The record was successfully saved!");
                    }
                }

                this.Close();
            }
        }
        private void loadAppLinks()
        {
            try
            {
                var appLinksList = new List <AppLinks>();

                appLinksList.Clear();

                appLinksList = DALHelpers.GetAppLinks();

                dgvAppLinks.DataSource = null;
                dgvAppLinks.Rows.Clear();
                dtAppLinks.Clear();

                foreach (AppLinks link in appLinksList)
                {
                    string tempPassword = link.Password.ToString();

                    if (!string.IsNullOrEmpty(tempPassword))
                    {
                        tempPassword = Encryption.Decrypt(tempPassword);
                    }

                    dtAppLinks.Rows.Add(link.ListId.ToString(), link.Description.ToString(), link.Link.ToString(),
                                        link.AppCategoryId.ToString(), link.AppCategoryName.ToString(),
                                        link.ApplicationId.ToString(), link.ApplicationName.ToString(),
                                        link.CountryId.ToString(), link.CountryName.ToString(),
                                        link.CredentialId.ToString(), link.CredentialDescription.ToString(), link.Username.ToString(), tempPassword,
                                        link.AppCategoryName.ToString() + link.ApplicationName.ToString() + link.CountryName.ToString() + link.Description.ToString() + link.Link.ToString() + link.CredentialDescription.ToString() + link.Username.ToString());
                }

                dgvAppLinks.DataSource          = dtAppLinks;
                dgvAppLinks.Columns[0].Visible  = false;
                dgvAppLinks.Columns[3].Visible  = false;
                dgvAppLinks.Columns[5].Visible  = false;
                dgvAppLinks.Columns[7].Visible  = false;
                dgvAppLinks.Columns[9].Visible  = false;
                dgvAppLinks.Columns[13].Visible = false;

                dgvAppLinks.Columns[1].Width  = 200;
                dgvAppLinks.Columns[2].Width  = 300;
                dgvAppLinks.Columns[4].Width  = 70;
                dgvAppLinks.Columns[6].Width  = 70;
                dgvAppLinks.Columns[8].Width  = 70;
                dgvAppLinks.Columns[10].Width = 140;
                dgvAppLinks.Columns[11].Width = 70;

                dgvAppLinks.Sort(dgvAppLinks.Columns["Link Description"], ListSortDirection.Ascending);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message);
            }
        }
Ejemplo n.º 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            hasTheSaveButtonPressed = true;

            Dealer dealer = new Dealer();
            bool   ok     = false;

            if (Validation.DealerDataValidation(txtDealerName.Text, cmbCountries.Text))
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            foreach (Country country in countryList)
            {
                if (cmbCountries.Text == country.CountryName)
                {
                    dealer.CountryId = country.CountryId;
                }
            }

            dealer.DealerName = txtDealerName.Text;

            if (GlobalDealerId != 0)
            {
                dealer.DealerId = GlobalDealerId;
                //UPDATE
                ok = DALHelpers.UpdateMainDealer(dealer);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }
                else
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Dealer Contact!");
                }

                ActivityLog.DealerLogger(dealer, "UPDATE", "Main Dealer", Environment.UserName);
                this.Close();
            }
            else //NEW MAIN DEALER
            {
                ok = DALHelpers.AddMainDealer(dealer);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }

                ActivityLog.DealerLogger(dealer, "CREATE", "Main Dealer", Environment.UserName);
                this.Close();
            }
        }
        public frmAddOrUpdateDealer(int DealerId, string DealerCode, string DealerName, int CountryId)
        {
            InitializeComponent();

            GlobalDealerId = DealerId;

            #region "DEALER - UPDATE"

            if (!string.IsNullOrEmpty(DealerName))
            {
                int counter = 0;

                this.Text          = "Update Dealer";
                txtDealerCode.Text = DealerCode;
                txtDealerName.Text = DealerName;

                countryList = DALHelpers.GetCountries();

                Dictionary <int, Dealer>  comboDealer = new Dictionary <int, Dealer>();
                Dictionary <int, Country> comboBox    = new Dictionary <int, Country>();

                foreach (Country country in countryList)
                {
                    cmbCountries.Items.Add(country.CountryName.ToString());
                    comboBox.Add(counter, country);

                    if (CountryId == country.CountryId)
                    {
                        cmbCountries.SelectedIndex = counter;
                    }

                    counter++;
                }
            }

            #endregion

            #region "DEALER - NEW"
            else
            {
                //LOAD DATA FOR NEW SUBDEALER
                countryList = DALHelpers.GetCountries();

                foreach (Country country in countryList)
                {
                    cmbCountries.Items.Add(country.CountryName.ToString());
                }
            }

            #endregion
        }
Ejemplo n.º 16
0
        public static DatabaseViewModel GetDataFromDatabase()
        {
            DatabaseViewModel databaseViewModel = new DatabaseViewModel();

            databaseViewModel.ContactList        = DALHelpers.GetContacts();
            databaseViewModel.DealerContactList  = DALHelpers.GetDealerContacts();
            databaseViewModel.MainDealerList     = DALHelpers.GetDealers();
            databaseViewModel.DealerBranchesList = DALHelpers.GetDealerBranchs();
            databaseViewModel.ApplicationsList   = DALHelpers.GetApplications();
            databaseViewModel.AppLinksList       = DALHelpers.GetAppLinks();
            databaseViewModel.CountryList        = DALHelpers.GetCountries();

            return(databaseViewModel);
        }
Ejemplo n.º 17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            hasTheSaveButtonPressed = true;

            App  application = new App();
            bool ok          = false;

            if (string.IsNullOrEmpty(txtApplicationName.Text))
            {
                MessageBox.Show("Please enter the Application name.");
                return;
            }
            else
            {
                application.ApplicationId   = GlobalApplicationId;
                application.ApplicationName = txtApplicationName.Text;
            }

            if (GlobalEditOrNew == "Edit")
            {
                //UPDATE APPLICATION
                ok = DALHelpers.UpdateApplication(application);

                if (ok == true)
                {
                    MessageBox.Show("The record was successfully saved!");
                }
                else
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Application!");
                }

                ActivityLog.ApplicationLogger(application, "UPDATE", GlobalApplicationName, Environment.UserName);
                this.Close();
            }
            else //NEW APPLICATION
            {
                ok = DALHelpers.AddApplication(application);

                if (ok == true)
                {
                    ActivityLog.ApplicationLogger(application, "CREATE", "", Environment.UserName);
                    MessageBox.Show("The record was successfully saved!");
                }

                this.Close();
            }
        }
Ejemplo n.º 18
0
        private void loadDealerContacts(int DealerId)
        {
            var dealerContactList = new List <DealerContact>();

            dealerContactList = DALHelpers.GetDealerContactByDealerId(DealerId);

            dgvDealerContacts.DataSource = null;
            dgvDealerContacts.Rows.Clear();
            dtDealerContacts.Clear();

            foreach (DealerContact dealerContact in dealerContactList)
            {
                //dtDealerContacts.Columns.Add("DealerContactId", typeof(string));
                //dtDealerContacts.Columns.Add("MainDealerId", typeof(string));
                //dtDealerContacts.Columns.Add("Description", typeof(string));
                //dtDealerContacts.Columns.Add("Department", typeof(string));
                //dtDealerContacts.Columns.Add("Phone", typeof(string));
                //dtDealerContacts.Columns.Add("CellPhone", typeof(string));
                //dtDealerContacts.Columns.Add("Email", typeof(string));

                dtDealerContacts.Rows.Add(
                    dealerContact.DealerContactId.ToString(),
                    dealerContact.MainDealerId.ToString(),
                    dealerContact.Description.ToString(),
                    dealerContact.Department.ToString(),
                    dealerContact.Phone.ToString(),
                    dealerContact.CellPhone.ToString(),
                    dealerContact.Email.ToString()
                    );
            }

            dgvDealerContacts.DataSource = dtDealerContacts;

            dgvDealerContacts.Columns[0].Visible = false;
            dgvDealerContacts.Columns[1].Visible = false;

            dgvDealerContacts.Columns[2].Width = 140;
            dgvDealerContacts.Columns[3].Width = 100;
            dgvDealerContacts.Columns[4].Width = 100;
            dgvDealerContacts.Columns[5].Width = 100;
            dgvDealerContacts.Columns[6].Width = 180;

            dgvDealerContacts.Sort(dgvDealerContacts.Columns["Description"], ListSortDirection.Ascending);

            dgvDealerContacts.ClearSelection();
        }
Ejemplo n.º 19
0
        private void cmbCountries_SelectionChangeCommitted(object sender, EventArgs e)
        {
            foreach (Country country in countryList)
            {
                if (cmbCountries.SelectedItem.ToString() == country.CountryName)
                {
                    cmbMainDealer.Items.Clear();
                    dealerList.Clear();
                    dealerList = DALHelpers.GetDealersByCountry(country.CountryId);
                }
            }

            foreach (Dealer dealer in dealerList)
            {
                cmbMainDealer.Items.Add(dealer.DealerName.ToString());
            }
        }
Ejemplo n.º 20
0
        public List <DealerBranch> loadDealerBranches()
        {
            dgvDealer.DataSource = null;
            dgvDealer.Rows.Clear();
            dtDealers.Clear();

            dealerBranchesList = DALHelpers.GetDealerBranchs();

            foreach (DealerBranch dealer in dealerBranchesList)
            {
                dtDealers.Rows.Add(
                    dealer.DealerBranchId.ToString(),
                    dealer.CTDI.ToString(),
                    dealer.DealerName.ToString(),
                    dealer.BranchName.ToString(),
                    dealer.PhoneNumber.ToString(),
                    dealer.BaldoPartner.ToString(),
                    dealer.CountryId.ToString(),
                    dealer.CountryName.ToString(),
                    dealer.DealerId.ToString(),
                    dealer.CTDI.ToString() + dealer.PhoneNumber.ToString() + dealer.BaldoPartner.ToString() + dealer.CountryName.ToString() + dealer.DealerName.ToString() + Validation.RemoveDiacritics(dealer.DealerName.ToString()) + dealer.BranchName.ToString() + Validation.RemoveDiacritics(dealer.BranchName.ToString()),
                    dealer.DealerName.ToString() + dealer.BranchName.ToString());
            }

            dgvDealer.DataSource = dtDealers;

            dgvDealer.Columns[0].Visible  = false;
            dgvDealer.Columns[6].Visible  = false;
            dgvDealer.Columns[8].Visible  = false;
            dgvDealer.Columns[9].Visible  = false;
            dgvDealer.Columns[10].Visible = false;

            dgvDealer.Columns[1].Width = 50;
            dgvDealer.Columns[2].Width = 150;
            dgvDealer.Columns[3].Width = 150;
            dgvDealer.Columns[4].Width = 110;
            dgvDealer.Columns[5].Width = 70;
            dgvDealer.Columns[7].Width = 70;

            dgvDealer.Sort(dgvDealer.Columns["Sort"], ListSortDirection.Ascending);

            dgvDealer.ClearSelection();

            return(dealerBranchesList);
        }
Ejemplo n.º 21
0
        public frmUpdatePassword(int CredentialId)
        {
            InitializeComponent();

            hasTheSaveButtonPressed = false;

            //NEW OBJECT credential
            Credential credential = new Credential();

            //GETTING THE CREDENTIAL FROM THE DABASE, SEARCHING BY THE ID
            credential = DALHelpers.GetCredentialById(CredentialId);

            //LOADING THE DATA TO THE FORM
            GlobalCredentialId  = credential.CredentialId;
            txtDescription.Text = credential.CredentialDescription.ToString();
            txtUsername.Text    = credential.Username.ToString();
            txtPassword.Text    = credential.Password.ToString();
        }
Ejemplo n.º 22
0
        public frmAddOrUpdateDealer(Dealer dealer)
        {
            InitializeComponent();

            GlobalDealerId = dealer.DealerId;

            countryList = DALHelpers.GetCountries();

            hasTheSaveButtonPressed = false;

            int counter = 0;

            if (dealer.DealerId != 0)
            {
                foreach (Country _country in countryList)
                {
                    cmbCountries.Items.Add(_country.CountryName.ToString());

                    if (dealer.CountryId == _country.CountryId)
                    {
                        cmbCountries.SelectedIndex = counter;
                    }
                    counter++;
                }

                counter = 0;

                this.Text          = "Update Dealer";
                txtDealerName.Text = dealer.DealerName;
            }
            else
            {
                foreach (Country country in countryList)
                {
                    cmbCountries.Items.Add(country.CountryName.ToString());
                }

                counter = 0;

                this.Text = "New Dealer";
            }

            cmbCountries.Focus();
        }
Ejemplo n.º 23
0
        public frmAddOrUpdateContact(Contact contact)
        {
            InitializeComponent();

            teamList = DALHelpers.GetTeams();
            hasTheSaveButtonPressed = false;

            int counter = 0;

            if (!string.IsNullOrEmpty(contact.Id))
            {
                foreach (Team team in teamList)
                {
                    cmbTeam.Items.Add(team.TeamName.ToString());

                    if (contact.TeamId == team.TeamId)
                    {
                        cmbTeam.SelectedIndex = counter;
                    }

                    counter++;
                }

                this.Text         = "Update Contact";
                txtUserID.Text    = contact.Id;
                txtUserID.Enabled = false;
                txtName.Text      = contact.Name;
                txtPhone.Text     = contact.Phone;
                txtCellPhone.Text = contact.CellPhone;
                txtComputer.Text  = contact.Computer;
            }
            else
            {
                foreach (Team team in teamList)
                {
                    cmbTeam.Items.Add(team.TeamName.ToString());
                }

                this.Text         = "New Contact";
                txtUserID.Enabled = Enabled;
            }

            cmbTeam.Focus();
        }
Ejemplo n.º 24
0
        private void btnDeleteCountry_Click(object sender, EventArgs e)
        {
            if (dgvCountries.Rows.Count > 0)
            {
                int    CountryId   = Convert.ToInt32(dgvCountries.CurrentRow.Cells[0].Value.ToString());
                string CountryName = dgvCountries.CurrentRow.Cells[1].Value.ToString();

                if (MessageBox.Show("Are you sure you want to delete the country " + CountryId.ToString() + "?", "Delete Country", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var dealerList   = new List <Dealer>();
                    var appLinksList = new List <AppLinks>();

                    dealerList   = DALHelpers.GetDealersByCountry(CountryId);
                    appLinksList = DALHelpers.GetAppLinksByCountryId(CountryId);

                    if (countryList.Count == 0 || appLinksList.Count == 0)
                    {
                        Country country = new Country();

                        country.CountryId   = Convert.ToInt32(dgvCountries.CurrentRow.Cells[0].Value.ToString());
                        country.CountryName = dgvCountries.CurrentRow.Cells[1].Value.ToString();

                        DALHelpers.DeleteCountry(CountryId);

                        ActivityLog.CountryLogger(country, "DELETE", "", 0, Environment.UserName);

                        Validation.LocalDatabaseConfig(true);
                        //databaseViewModel = Services.GetDataFromDatabase();
                        countryList = loadCountries();
                    }
                    else
                    {
                        MessageBox.Show("Unable to Delete the Country: " + CountryName + ". This record is used by: " + dealerList.Count + " Main Dealers and " + appLinksList.Count + " Application Links.", "Unable to Delete the Main Dealer!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                dgvCountries.ClearSelection();
                txtSearchCountry.Clear();
                btnDeleteCountry.Enabled = false;
                btnEditCountry.Enabled   = false;
            }
        }
Ejemplo n.º 25
0
        private void btnDeleteDealer_Click(object sender, EventArgs e)
        {
            if (dgvDealer.Rows.Count > 0)
            {
                int    DealerId   = Convert.ToInt32(dgvDealer.CurrentRow.Cells[0].Value.ToString());
                string DealerName = dgvDealer.CurrentRow.Cells[1].Value.ToString();

                if (MessageBox.Show("Are you sure you want to delete the Main Dealer: " + DealerName.ToString() + "?", "Delete Main Dealer", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var dealerList = new List <DealerBranch>();
                    dealerList = DALHelpers.GetDealerBranchByDealerId(DealerId);

                    if (dealerList.Count == 0)
                    {
                        Dealer dealer = new Dealer();

                        dealer.DealerId    = Convert.ToInt32(dgvDealer.CurrentRow.Cells[0].Value.ToString());
                        dealer.CountryName = dgvDealer.CurrentRow.Cells[1].Value.ToString();
                        dealer.CountryId   = Convert.ToInt32(dgvDealer.CurrentRow.Cells[2].Value.ToString());

                        DALHelpers.DeleteMainDealer(DealerId);

                        ActivityLog.DealerLogger(dealer, "DELETE", "Main Dealer", Environment.UserName);

                        Validation.LocalDatabaseConfig(true);
                        //databaseViewModel = Services.GetDataFromDatabase();
                        dealerlList = loadDealers();
                    }
                    else
                    {
                        MessageBox.Show("Unable to Delete the Main Dealer: " + DealerName.ToString() + ". Found " + dealerList.Count + " Dealer Branches created for this Main Dealer", "Unable to Delete the Main Dealer!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                dgvDealer.ClearSelection();
                txtSearchDealer.Clear();
                btnEditDealer.Enabled   = false;
                btnDeleteDealer.Enabled = false;
            }
        }
Ejemplo n.º 26
0
        private void updatePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (var password in PasswordList)
            {
                TreeNode tn = treeView1.SelectedNode;

                if (tn != null)
                {
                    if (treeView1.SelectedNode.Text.ToString() == password.Value.ToString())
                    {
                        frmUpdatePassword _frmUpdatePassword = new frmUpdatePassword(password.Key, left, top, width, height);

                        this.TopMost = false;

                        _frmUpdatePassword.ShowDialog();
                        //loadAppLinks();

                        setTopMostWindowSetting();

                        _frmUpdatePassword.Dispose();

                        PasswordList.Clear();
                        ApplicationsList     = DALHelpers.GetApplications();
                        AppLinksFromDatabase = DALHelpers.GetAppLinks();

                        if (txtAppSearch.Text.Length > 1)
                        {
                            loadAppsFromSearchBox();
                        }
                        else
                        {
                            loadTreeview(false, null);
                        }

                        break;
                    }
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if ((dgvAppLinks.Rows.Count > 0) && (dgvAppLinks.SelectedRows.Count > 0))
            {
                int    LinkId;
                string Description = dgvAppLinks.CurrentRow.Cells[1].Value.ToString();
                LinkId = Convert.ToInt32(dgvAppLinks.CurrentRow.Cells[0].Value.ToString());

                if (MessageBox.Show("Are you sure you want to delete the App Link: " + Description, "Delete App Link", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    DALHelpers.DeleteAppLink(LinkId);
                    System.Threading.Thread.Sleep(1000);
                    loadAppLinks();
                    dgvAppLinks.ClearSelection();
                }
                else
                {
                    dgvAppLinks.ClearSelection();
                }
                txtAppLinkSearch.Clear();
            }
        }
        public frmUpdatePassword(int CredentialId, int left, int top, int width, int height)
        {
            InitializeComponent();

            //SETTING THE FORM LOCATION
            left = left + (width / 4);
            top  = top + (height / 4);

            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(left, top);

            //NEW OBJECT credential
            Credential credential = new Credential();

            //GETTING THE CREDENTIAL FROM THE DABASE, SEARCHING BY THE ID
            credential = DALHelpers.GetCredentialById(CredentialId);

            //LOADING THE DATA TO THE FORM
            GlobalCredentialId  = credential.CredentialId;
            txtDescription.Text = credential.CredentialDescription.ToString();
            txtUsername.Text    = credential.Username.ToString();
            txtPassword.Text    = credential.Password.ToString();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool ok;

            if (!string.IsNullOrEmpty(txtPassword.Text) || txtPassword.Text.Length > 2)
            {
                Credential credential = new Credential();

                credential.CredentialId          = GlobalCredentialId;
                credential.CredentialDescription = txtDescription.Text;
                credential.Username = txtUsername.Text;
                credential.Password = txtPassword.Text;

                //UPDATE
                ok = DALHelpers.UpdateCredential(credential);

                if (ok == false)
                {
                    MessageBox.Show("Error: An error has ocurred when trying to update the Password!");
                }

                this.Close();
            }
        }
Ejemplo n.º 30
0
        private async Task ExecuteJobAsync(string processID, string jobID, MethodInfo methodInfo, string parameters, object instance, CancellationToken?token, bool isSync)
        {
            try
            {
                //Set job to Running
                if (isSync)
                {
                    jobDAL.SetToRunning(processID, jobID);
                }
                else
                {
                    await jobDAL.SetToRunningAsync(processID, jobID);
                }
                jobDAL.SetCachedProgressStatusAsync(jobID, JobStatus.Running);

                var progress = isSync ? UpdateProgressEventAsync(jobID, true).GetAwaiter().GetResult() : await UpdateProgressEventAsync(jobID, false); //Need this to update the progress of the job's

                //Invoke Method
                if (token == null)
                {
                    var tokenSource = new CancellationTokenSource(); //not doing anything when using thread.Start()
                    token = tokenSource.Token;
                }
                var args = DALHelpers.DeserializeArguments(token.Value, progress, methodInfo, parameters);
                methodInfo.Invoke(instance, args);
            }
            catch (TargetInvocationException exc)
            {
                if (exc.InnerException is OperationCanceledException)
                {
                    if (isSync)
                    {
                        SetToStoppedAsync(new List <string> {
                            jobID
                        }, isSync).GetAwaiter().GetResult();
                    }
                    else
                    {
                        await SetToStoppedAsync(new List <string> {
                            jobID
                        }, isSync);
                    }

                    throw exc.InnerException;
                }
                else
                {
                    var job = isSync ? jobDAL.GetJob(jobID) : await jobDAL.GetJobAsync(jobID);

                    if (job != null)
                    {
                        var error = job.Error + " " + exc.ToString();
                        var count = isSync ? SetErrorAsync(processID, job.JobID, error, isSync).GetAwaiter().GetResult()
                            : await SetErrorAsync(processID, job.JobID, error, isSync);
                    }
                    throw exc;
                }
            }
            catch (Exception exc)
            {
                var job = isSync ? jobDAL.GetJob(jobID) : await jobDAL.GetJobAsync(jobID);

                if (job != null)
                {
                    var error = job.Error + " " + exc.ToString();
                    var count = isSync ? SetErrorAsync(processID, job.JobID, error, isSync).GetAwaiter().GetResult()
                        : await SetErrorAsync(processID, job.JobID, error, isSync);
                }
                throw exc;
            }

            //Completed successfully with no error
            if (isSync)
            {
                jobDAL.SetCompleted(processID, jobID);
            }
            else
            {
                await jobDAL.SetCompletedAsync(processID, jobID);
            }
            jobDAL.SetCachedProgressStatusAsync(jobID, JobStatus.Completed);
        }