Beispiel #1
0
 private void cmdAcceptChanges_Click(object sender, EventArgs e)
 {
     FillTextBox();
     dgvSugarActive.DataSource = null;
     dgvSugarActive.DataSource = m_DS.Tables[m_const_strSugarTableSearchAllPrivate].DefaultView;
     cSugar m_objSugar = new cSugar(m_DS, m_BS);
     m_objSugar.SaveChanges();
 }
Beispiel #2
0
 /// <summary>
 /// Please make sure to set the property Privat to true or false 
 /// before calling any functions!
 /// </summary>
 /// <param name="ds">a DataSet</param>
 /// <param name="searchstring">the searchstring</param>
 /// <param name="obj_cao">the cCao Object from frmMain</param>
 /// <param name="obj_sugar">the cSugar Object from frmMain</param>
 /// <param name="mainform">reference to the frmMain</param>
 /// <param name="bsCao">The Databinding for Cao</param>
 /// <param name="bsSugar">The Databinding for Sugar</param>
 public frmSuche(DataSet ds, string searchstring, cCao obj_cao, cSugar obj_sugar, frmMain mainform, BindingSource bsCao, BindingSource bsSugar)
 {
     m_strSuchstring = searchstring;
     m_DS = ds;
     m_objCao = obj_cao;
     m_objSugar = obj_sugar;
     this.frmMain = mainform;
     m_BS_Cao = bsCao;
     m_BS_Sugar = bsSugar;
     InitializeComponent();
 }
Beispiel #3
0
        /// <summary>
        /// Searches Cao and Sugar for contacts
        /// according to the checked search criterion.
        /// </summary>
        /// <param name="searchstring">the stirng to search for</param>
        public void StartSearchPrivat(string searchstring)
        {
            /* Create new Object cCao.
             * Use the Search Contacts Method.
             * Bind the DataSource from the Binding Source
             * Set the DataSource for the dgv */

            m_objCao = new cCao(m_DS, m_BS_Cao);
            if (rbName.Checked == true)
            {
                m_objCao.SearchContactsByName(searchstring);
            }
            if (rbStrasse.Checked == true)
            {
                m_objCao.SearchContactsBySteet(searchstring);
            }
            if (rbTelefon.Checked == true)
            {
                m_objCao.SearchContactsByPhone(searchstring);
            }
            m_BS_Cao.DataSource = m_DS.Tables[m_const_strCaoTableSearchAllPrivate];
            dgvCaoSuche.DataSource = m_BS_Cao;
            HideRowsCao();

            m_objSugar = new cSugar(m_DS, m_BS_Sugar);
            if (rbName.Checked == true)
            {
                m_objSugar.SearchContactsByName(searchstring);
            }
            if (rbStrasse.Checked == true)
            {
                m_objSugar.SearchContactsByStreet(searchstring);
            }
            if (rbTelefon.Checked == true)
            {
                m_objSugar.SearchContactsByPhone(searchstring);
            }
            m_BS_Sugar.DataSource = m_DS.Tables[m_const_strSugarTableSearchAllPrivate];
            dgvSugarSuche.DataSource = m_BS_Sugar;
            HideRowsSugarContacts();
        }
Beispiel #4
0
        /// <summary>
        /// Searches Cao and Sugar for companies
        /// according to the checked search criterion.
        /// </summary>
        /// <param name="searchstring">the stirng to search for</param>
        public void StartSearchFirma(string searchstring)
        {
            m_objCao = new cCao(m_DS, m_BS_Cao);
            if (rbName.Checked == true)
            {
                m_objCao.SearchCompanyByName(searchstring);
            }
            if (rbStrasse.Checked == true)
            {
                m_objCao.SearchCompanyByStreet(searchstring);
            }
            if (rbTelefon.Checked == true)
            {
                m_objCao.SearchCompanyByPhone(searchstring);
            }
            m_BS_Cao.DataSource = m_DS.Tables[m_const_strCaoTableSearchAllCompanies];
            dgvCaoSuche.DataSource = m_BS_Cao;
            HideRowsCao();

            m_objSugar = new cSugar(m_DS, m_BS_Sugar);
            if (rbName.Checked == true)
            {
                m_objSugar.SearchCompanyByName(searchstring);
            }
            if (rbStrasse.Checked == true)
            {
                m_objSugar.SearchCompanyByStreet(searchstring);
            }
            if (rbTelefon.Checked == true)
            {
                m_objSugar.SearchCompanyByPhone(searchstring);
            }
            m_BS_Sugar.DataSource = m_DS.Tables[m_const_strSugarTableSearchAllCompanies];
            dgvSugarSuche.DataSource = m_BS_Sugar;
            HideRowsSugarCompanies();
        }
Beispiel #5
0
        private void cmdTest_Click(object sender, EventArgs e)
        {
            Cugar.Properties.Settings.Default.caohost = txtCaoHost.Text;
            Cugar.Properties.Settings.Default.caouser = txtCaoUser.Text;
            Cugar.Properties.Settings.Default.caopw = txtCaoPW.Text;

            Cugar.Properties.Settings.Default.sugarhost = txtSugarHost.Text;
            Cugar.Properties.Settings.Default.sugaruser = txtSugarUser.Text;
            Cugar.Properties.Settings.Default.sugarpw = txtSugarPW.Text;

            Cugar.Properties.Settings.Default.Save();
            Cugar.Properties.Settings.Default.Upgrade();

            DataSet m_ds = new DataSet();
            cCao m_objCao = new cCao(m_ds);

            /* Test Cao connection */
            if (m_objCao.testConnection == true)
            {
                /* on Success show a Message and save the success into caook */
                MessageBox.Show("Cao Verbindung erfolgreich getestet.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                caook = true;
            }
            else
            {
                MessageBox.Show("Fehler in Cao Verbindung. \n Bitte überprüfen Sie die Einstellungen!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            /* Test Sugar Connection */
            cSugar m_objSugar = new cSugar(m_ds);
            if (m_objSugar.testConnection == true)
            {
                /* on success display a message and save the success into sugarok */
                MessageBox.Show("Sugar Verbindung erfolgreich getestet.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                sugarok = true;
            }
            else
            {
                MessageBox.Show("Fehler in Sugar Verbindung. \n Bitte überprüfen Sie die Einstellungen!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (caook == true && sugarok == true)
            {
                /* the user may only save hes settings if both settings are correct */
                MessageBox.Show("Beide Verbindungen erfolgreich getestet. Klicken Sie auf Speichern um fortzufahren...", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmdSave.Enabled = true;
            }
        }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            /* If its the first start show frmSettings */
            if (Cugar.Properties.Settings.Default.first_start == true)
            {
                frmSettings m_SubForm_Settings = new frmSettings();
                m_SubForm_Settings.ShowDialog();
            }

            if (m_DS.Tables.Count == 0)
            {
                #region prepare cCao Object and cSugar Object
                try
                {
                    m_objCao = new cCao(m_DS);
                }
                catch (Exception asdf)
                {
                    MessageBox.Show(asdf.ToString());
                    Application.Exit();
                }

                try
                {
                    m_objSugar = new cSugar(m_DS);
                    #region obsolete
                    //searchme
                    //m_objSugar = new cSugar(m_DS, m_BS_SugarSearchContacts);
                    //m_objSugar = new cSugar(m_DS);
                    //m_objSugar.LoadPrivateCustomers();
                    //m_dvSugar = m_DS.Tables[m_const_strSugarTablePrivate].DefaultView;
                    //dgvSugar.DataSource = m_dvSugar;
                    #endregion
                }
                catch (Exception asdf)
                {
                    MessageBox.Show("Ein Fehler ist aufgetreten!\n Bitte überprüfen Sie die Einstellungen!");
                    MessageBox.Show(asdf.ToString());
                    Application.Exit();
                }
                #endregion

                /* Versandarten ausfüllen */
                if (m_objCao.testConnection == true)
                {
                    LoadCaoVersandArten();
                    cboCaoVersand.SelectedIndex = 0;
                }

                /* zahlunggsarten ausfüllen */

                if (m_objCao.testConnection == true)
                {
                    LoadCaoZahlungsarten();
                    cboCaoZahlart.SelectedIndex = 0;
                }

            }
            // Prepare cbos
            cboAnrede.SelectedIndex = 0;
            cboFAnrede.SelectedIndex = 0;
            cboFSugarType.SelectedIndex = 0;
            cboFCaoBriefanrede.SelectedIndex = 0;
            cboFSugarType.SelectedIndex = 0;
            cboCaoBriefanrede.SelectedIndex = 0;
            cboFSugarIndustry.SelectedIndex = 0;
        }
Beispiel #7
0
        /// <summary>
        /// Updates the Current Contact in the Sugarcrm Contacts Table.
        /// </summary>
        private void UpdateContactSugar()
        {
            cSugar m_objUpdateSugar = new cSugar(m_DS, m_BS_SugarSearchContacts);
            MySqlConnection m_cnSugar = new MySqlConnection();
            m_cnSugar = m_objUpdateSugar.SugarConnection;

            StringBuilder sb_UpdateCommand = new StringBuilder();
            sb_UpdateCommand.Append("UPDATE contacts SET ");
            sb_UpdateCommand.Append(@"first_name='");
            sb_UpdateCommand.Append(txtVorname.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"last_name='");
            sb_UpdateCommand.Append(txtName.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"salutation='");
            sb_UpdateCommand.Append(cboAnrede.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"primary_address_street='");
            sb_UpdateCommand.Append(txtStrasse1.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"primary_address_postalcode='");
            sb_UpdateCommand.Append(txtPLZ.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"primary_address_city='");
            sb_UpdateCommand.Append(txtOrt.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_fax='");
            sb_UpdateCommand.Append(txtFax.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_mobile='");
            sb_UpdateCommand.Append(txtMobile.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_work='");
            sb_UpdateCommand.Append(txtPhon2.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_home='");
            sb_UpdateCommand.Append(txtPhone1.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"description='");
            sb_UpdateCommand.Append(txtBemerkung.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"primary_address_country='");
            sb_UpdateCommand.Append(txtSugarLand.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"lead_source='");
            sb_UpdateCommand.Append(txtSugarLeadSource.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"department='");
            sb_UpdateCommand.Append(txtSugarAbteilung.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"title='");
            sb_UpdateCommand.Append(txtSugarTitle.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"birthdate='");
            sb_UpdateCommand.Append(dtpGebDatum.Value.Year.ToString() + "-" + dtpGebDatum.Value.Month.ToString() + "-" + dtpGebDatum.Value.Day.ToString());
            sb_UpdateCommand.Append(@"', ");

            DateTime today = DateTime.Now;
            sb_UpdateCommand.Append(@"date_modified='");
            sb_UpdateCommand.Append(today.ToString("yyyy-MM-dd"));
            sb_UpdateCommand.Append(@"'");

            sb_UpdateCommand.Append(@" where id = '");
            sb_UpdateCommand.Append(((DataRowView)m_BS_SugarSearchContacts.Current)["id"].ToString());
            sb_UpdateCommand.Append(@"';");

            MySqlCommand myUpdateCommand = new MySqlCommand(sb_UpdateCommand.ToString(), m_objSugar.SugarConnection);

            if (myUpdateCommand.Connection.State == ConnectionState.Closed)
            {
                myUpdateCommand.Connection.Open();
            }
            try
            {
                myUpdateCommand.ExecuteNonQuery();
                myUpdateCommand.Connection.Clone();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());

            }
        }
Beispiel #8
0
        /// <summary>
        /// Updates the Current Company in the Sugar accounts table.
        /// </summary>
        private void UpdateCompanySugar()
        {
            cSugar m_objUpdateSugar = new cSugar(m_DS, m_BS_SugarSearchFirma);
            MySqlConnection m_cnSugar = new MySqlConnection();
            m_cnSugar = m_objUpdateSugar.SugarConnection;

            StringBuilder sb_UpdateCommand = new StringBuilder();
            sb_UpdateCommand.Append("UPDATE accounts SET ");
            sb_UpdateCommand.Append(@"name='");
            sb_UpdateCommand.Append(txtFName1.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"billing_address_street='");
            sb_UpdateCommand.Append(txtFStrasse.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"billing_address_postalcode='");
            sb_UpdateCommand.Append(txtFPLZ.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"billing_address_city='");
            sb_UpdateCommand.Append(txtFOrt.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"billing_address_country='");
            sb_UpdateCommand.Append(txtFSugarLand.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_office='");
            sb_UpdateCommand.Append(txtFPhone.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"phone_fax='");
            sb_UpdateCommand.Append(txtFFax.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"description='");
            sb_UpdateCommand.Append(txtFBemerkung.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"website='");
            sb_UpdateCommand.Append(txtFWeb.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"account_type='");
            sb_UpdateCommand.Append(cboFSugarType.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"industry='");
            sb_UpdateCommand.Append(cboFSugarIndustry.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"annual_revenue='");
            sb_UpdateCommand.Append(txtFSugarUmsatz.Text);
            sb_UpdateCommand.Append(@"', ");
            sb_UpdateCommand.Append(@"employees='");
            sb_UpdateCommand.Append(txtFSugarMitarbeiter.Text);
            sb_UpdateCommand.Append(@"', ");

            sb_UpdateCommand.Append(@"modified_user_id='");
            sb_UpdateCommand.Append("ed2d04a5-8264-45e7-fbdb-4ebebdf8375a");
            sb_UpdateCommand.Append(@"', ");

            DateTime today = DateTime.Now;
            sb_UpdateCommand.Append(@"date_modified='");
            sb_UpdateCommand.Append(today.ToString("yyyy-MM-dd_HH:mm:ss"));
            sb_UpdateCommand.Append(@"'");

            sb_UpdateCommand.Append(@" where id = '");
            sb_UpdateCommand.Append(((DataRowView)m_BS_SugarSearchFirma.Current)["id"].ToString());
            sb_UpdateCommand.Append(@"';");

            MySqlCommand myUpdateCommand = new MySqlCommand(sb_UpdateCommand.ToString(), m_objSugar.SugarConnection);

            if (myUpdateCommand.Connection.State == ConnectionState.Closed)
            {
                myUpdateCommand.Connection.Open();
            }
            try
            {
                myUpdateCommand.ExecuteNonQuery();
                myUpdateCommand.Connection.Clone();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());

            }
        }