Esempio n. 1
0
        /// <summary>
        /// Creates a new Cao record.
        /// </summary>
        private void CaoInsertPrivat()
        {
            if (m_bNew == true)
            {
                /* - create insert command text
                 * - create command itself
                 * - set all parameters for the values */

                #region Insert Command Text
                StringBuilder sb_CaoInsert = new StringBuilder();
                sb_CaoInsert.Append("INSERT INTO adressen(");
                sb_CaoInsert.Append("REC_ID, ");
                sb_CaoInsert.Append("KUNDENGRUPPE, ");
                sb_CaoInsert.Append("NAME1, ");
                sb_CaoInsert.Append("NAME2, ");
                sb_CaoInsert.Append("NAME3, ");
                sb_CaoInsert.Append("PLZ, ");
                sb_CaoInsert.Append("ORT, ");
                sb_CaoInsert.Append("LAND, ");
                sb_CaoInsert.Append("ANREDE, ");
                sb_CaoInsert.Append("STRASSE, ");
                sb_CaoInsert.Append("TELE1, ");
                sb_CaoInsert.Append("TELE2, ");
                sb_CaoInsert.Append("FAX, ");
                sb_CaoInsert.Append("FUNK, ");
                sb_CaoInsert.Append("EMAIL, ");
                sb_CaoInsert.Append("INTERNET, ");
                sb_CaoInsert.Append("BRIEFANREDE, ");
                sb_CaoInsert.Append("BRT_TAGE, ");
                sb_CaoInsert.Append("INFO, ");
                sb_CaoInsert.Append("KUN_LIEFART, ");
                sb_CaoInsert.Append("KUN_GEBDATUM, ");
                sb_CaoInsert.Append("KUN_SEIT, ");
                sb_CaoInsert.Append("GEAEND_NAME, ");
                sb_CaoInsert.Append("KUN_ZAHLART, ");
                sb_CaoInsert.Append(@"BRUTTO_FLAG)");
                sb_CaoInsert.Append(@" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                #endregion
                OdbcCommand caoInsert = new OdbcCommand(sb_CaoInsert.ToString(), m_objCao.CaoConnection);

                #region parameters
                caoInsert.Parameters.Add("@REC_ID", OdbcType.Int, 11, "@REC_ID");
                caoInsert.Parameters["@REC_ID"].Value = m_objCao.LatestRecId;
                caoInsert.Parameters.Add("@KUNDENGRUPPE", OdbcType.Int, 11, "@KUNDENGRUPPE");
                caoInsert.Parameters["@KUNDENGRUPPE"].Value = 1;

                caoInsert.Parameters.Add("@NAME1", OdbcType.VarChar, 40, "@NAME1");
                cToolbox tool = new cToolbox();
                caoInsert.Parameters["@NAME1"].Value = tool.UniteName(txtVorname.Text, txtName.Text);

                caoInsert.Parameters.Add("@NAME2", OdbcType.VarChar, 40, "@NAME2");
                caoInsert.Parameters["@NAME2"].Value = txtName2.Text;

                caoInsert.Parameters.Add("@NAME3", OdbcType.VarChar, 40, "@NAME3");
                caoInsert.Parameters["@NAME3"].Value = txtName3.Text;

                caoInsert.Parameters.Add("@PLZ", OdbcType.VarChar, 10, "@PLZ");
                caoInsert.Parameters["@PLZ"].Value = txtPLZ.Text;
                caoInsert.Parameters.Add("@ORT", OdbcType.VarChar, 40, "@ORT");
                caoInsert.Parameters["@ORT"].Value = txtOrt.Text;
                caoInsert.Parameters.Add("@LAND", OdbcType.VarChar, 5, "@LAND");
                caoInsert.Parameters["@LAND"].Value = "CH";
                caoInsert.Parameters.Add("@ANREDE", OdbcType.VarChar, 40, "@ANREDE");
                caoInsert.Parameters["@ANREDE"].Value = cboAnrede.Text;
                caoInsert.Parameters.Add("@STRASSE", OdbcType.VarChar, 40, "@STRASSE");
                caoInsert.Parameters["@STRASSE"].Value = txtStrasse1.Text;
                caoInsert.Parameters.Add("@TELE1", OdbcType.VarChar, 100, "@TELE1");
                caoInsert.Parameters["@TELE1"].Value = txtPhone1.Text;
                caoInsert.Parameters.Add("@TELE2", OdbcType.VarChar, 100, "@TELE2");
                caoInsert.Parameters["@TELE2"].Value = txtPhon2.Text;
                caoInsert.Parameters.Add("@FAX", OdbcType.VarChar, 100, "@FAX");
                caoInsert.Parameters["@FAX"].Value = txtFax.Text;
                caoInsert.Parameters.Add("@FUNK", OdbcType.VarChar, 100, "@FUNK");
                caoInsert.Parameters["@FUNK"].Value = txtMobile.Text;
                caoInsert.Parameters.Add("@EMAIL", OdbcType.VarChar, 100, "@EMAIL");
                caoInsert.Parameters["@EMAIL"].Value = txtEmail.Text;
                caoInsert.Parameters.Add("@INTERNET", OdbcType.VarChar, 100, "@INTERNET");
                caoInsert.Parameters["@INTERNET"].Value = txtWebpage.Text;
                caoInsert.Parameters.Add("@BRIEFANREDE", OdbcType.VarChar, 100, "@BRIEFANREDE");
                caoInsert.Parameters["@BRIEFANREDE"].Value = cboCaoBriefanrede.Text;

                caoInsert.Parameters.Add("@BRT_TAGE", OdbcType.TinyInt, 4, "@BRT_TAGE");
                if (txtCaoZahlungsziel.Text == "")
                {
                    caoInsert.Parameters["@BRT_TAGE"].Value = 30;
                }
                else
                {
                    caoInsert.Parameters["@BRT_TAGE"].Value = Convert.ToInt16(txtCaoZahlungsziel.Text);
                }

                caoInsert.Parameters.Add("@INFO", OdbcType.Text, 65537, "@INFO");
                caoInsert.Parameters["@INFO"].Value = txtBemerkung.Text;
                caoInsert.Parameters.Add("@KUN_LIEFART", OdbcType.Int, 11, "@KUN_LIEFART");
                caoInsert.Parameters["@KUN_LIEFART"].Value = cboCaoVersand.SelectedIndex + 1;

                caoInsert.Parameters.Add("@KUN_GEBDATUM", OdbcType.Date);
                caoInsert.Parameters["@KUN_GEBDATUM"].Value = Convert.ToDateTime(dtpGebDatum.Text);

                caoInsert.Parameters.Add("@KUN_SEIT", OdbcType.Date);
                caoInsert.Parameters["@KUN_SEIT"].Value = DateTime.Today.ToShortDateString();
                caoInsert.Parameters.Add("@GEAND_NAME", OdbcType.VarChar, 20, "@GEAND_NAME");
                caoInsert.Parameters["@GEAND_NAME"].Value = "Cugar";

                caoInsert.Parameters.Add("@KUN_ZAHLART", OdbcType.Int, 11, "@KUN_ZAHLART");
                caoInsert.Parameters["@KUN_ZAHLART"].Value = cboCaoZahlart.SelectedIndex + 1;
                caoInsert.Parameters.Add("@BRUTTO_FLAG", OdbcType.Char, 2, "@BRUTTO_FLAG");
                caoInsert.Parameters["@BRUTTO_FLAG"].Value = 'Y';
                #endregion
                try
                {
                    caoInsert.ExecuteNonQuery();
                }
                catch (Exception asdf)
                {
                    MessageBox.Show(asdf.ToString());
                    throw;
                }

            }
        }
Esempio n. 2
0
        /// <summary>
        /// Checks a few Entrys from the two different selected Rows
        /// and gives a Message if there are fundamental differences.
        /// </summary>
        private void CompareContacts()
        {
            if (m_BS_Cao.Current != null)
            {
                cToolbox m_objTool = new cToolbox();
                string[] foo2;
                foo2 = m_objTool.SplitName(((DataRowView)m_BS_Cao.Current)["NAME1"].ToString());

                if (foo2[1] != ((DataRowView)m_BS_Sugar.Current)["last_name"].ToString())
                {
                    DialogResult dr = MessageBox.Show("Unterschiedliche Datenstze festgestellt (Nachname).\n Datenstze Konsolidieren?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr == DialogResult.Yes)
                    {
                        this.frmMain.DatensatzLadenPrivate();
                    }
                }

                else if (((DataRowView)m_BS_Cao.Current)["STRASSE"].ToString() != ((DataRowView)m_BS_Sugar.Current)["primary_address_street"].ToString())
                {
                    DialogResult dr = MessageBox.Show("Unterschiedliche Datenstze festgestellt (Strasse).\n Datenstze Konsolidieren?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr == DialogResult.Yes)
                    {
                        this.frmMain.DatensatzLadenPrivate();
                    }
                }

                else if (((DataRowView)m_BS_Cao.Current)["TELE1"].ToString() != ((DataRowView)m_BS_Sugar.Current)["phone_home"].ToString())
                {
                    DialogResult dr = MessageBox.Show("Unterschiedliche Datenstze festgestellt (Telefon).\n Datenstze Konsolidieren?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr == DialogResult.Yes)
                    {
                        this.frmMain.DatensatzLadenPrivate();
                    }
                }
                else
                {
                    this.frmMain.DatensatzLadenPrivate();
                }
            }
            else
            {
                MessageBox.Show("Es muss mindestens ein Cao Datensatz ausgewhlt sein!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Fills all the textfields with values from the current
        /// selected DataRow out of the BindingSource. (tblSearch*Contacts)
        /// </summary>
        public void DatensatzLadenPrivate()
        {
            tabMain.SelectedTab = tabContacts;
            #region snippet, obsolete
            /* snippet:
             * textBox.DataBindings.Add("Text", ds.Tables["Products"], "ProductName"); */
            //txtName.DataBindings.Add(
            //m_DS.Tables[m_const_strCaoTableSearchHuman].Rows[0];
            //txtName.Text = m_DS.Tables[m_const_strCaoTableSearchAll].Rows[0][1].ToString
            //txtName.DataBindings.Add(m_BS);
            //MessageBox.Show(m_BS.Position.ToString());
            //MessageBox.Show(m_DS.Tables[m_const_strCaoTableSearchAll].Rows[m_BS.Position]["Name1"].ToString());
            //if (m_BS.Current != null)
            //    MessageBox.Show( ((DataRowView)m_BS.Current)["Name1"].ToString());
            #endregion
            if (m_BS_CaoSearchContacts.Current != null)
            {
                //tabCompanies.
                //set searchtext to personen
                tstxtSuchePrivat.Text = "Personen...";

                #region Convert the name filed into two fields using CToolbox
                cToolbox m_objTool = new cToolbox();
                string[] foo2;
                foo2 = m_objTool.SplitName(((DataRowView)m_BS_CaoSearchContacts.Current)["NAME1"].ToString());
                txtVorname.Text = foo2[0];
                txtName.Text = foo2[1];
                #endregion

                #region fill cbos and set them to the right index
                // set cboCaoVersand to the right index
                int VerdsandId = 0;
                VerdsandId = Convert.ToInt32(((DataRowView)m_BS_CaoSearchContacts.Current)["KUN_LIEFART"]);
                cboCaoVersand.SelectedIndex = VerdsandId - 1;

                //set cboCaoZahlart to the right index
                int ZahlartId = 0;
                ZahlartId = Convert.ToInt32(((DataRowView)m_BS_CaoSearchContacts.Current)["KUN_ZAHLART"]);
                cboCaoZahlart.SelectedIndex = ZahlartId - 1;
                #endregion

                /* Fills in all the textfield using databinding object casted into a datarowview */
                txtName2.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["NAME2"].ToString();
                txtName3.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["NAME3"].ToString();
                cboAnrede.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["ANREDE"].ToString();
                txtStrasse1.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["STRASSE"].ToString();
                txtPLZ.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["PLZ"].ToString();
                txtOrt.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["ORT"].ToString();
                txtWebpage.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["INTERNET"].ToString();
                txtEmail.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["EMAIL"].ToString();
                txtFax.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["FAX"].ToString();
                txtMobile.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["FUNK"].ToString();
                txtPhon2.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["TELE2"].ToString();
                txtPhone1.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["TELE1"].ToString();
                cboCaoBriefanrede.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["BRIEFANREDE"].ToString();
                txtCaoZahlungsziel.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["BRT_TAGE"].ToString();

                dtpKunSeit.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["KUN_SEIT"].ToString();

                //dtpGebDatum.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["KUN_GEBDATUM"].ToString();
                dtpGebDatum.Value = Convert.ToDateTime(((DataRowView)m_BS_CaoSearchContacts.Current)["KUN_GEBDATUM"]);

                txtBemerkung.Text = ((DataRowView)m_BS_CaoSearchContacts.Current)["INFO"].ToString();

                //((DataRowView)m_BS_CaoSearchContacts.Current)["INFO"] = txtBemerkung.Text;

                //txtSugarZugewiesenAn.Text = ((DataRowView)m_BS.Current)[].ToString();
                txtSugarLand.Text = ((DataRowView)m_BS_SugarSearchContacts.Current)["primary_address_country"].ToString();
                txtSugarLeadSource.Text = ((DataRowView)m_BS_SugarSearchContacts.Current)["lead_source"].ToString();
                txtSugarAbteilung.Text = ((DataRowView)m_BS_SugarSearchContacts.Current)["department"].ToString();
                txtSugarTitle.Text = ((DataRowView)m_BS_SugarSearchContacts.Current)["title"].ToString();
            }

            //((DataRowView)m_BS.Current)["NAME1"] = txtName.Text;
            //((DataRowView)m_BS_Sugar.Current)["last_name"] =
            //m_BS.Current
        }