Пример #1
0
        private void buttonErfassen_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textFieldSellerId.Text) == true)
            {
                DialogResult result = MessageBox.Show("Wenn die Verkäufer Id leer gelassen wird,\r\nwird eine Verkäufer Id neu vergeben!", "Achtung", MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            if (String.IsNullOrEmpty(textFieldGivenName.Text) == true ||
                String.IsNullOrEmpty(textFieldSureName.Text) == true ||
                String.IsNullOrEmpty(textFieldStreet.Text) == true ||
                String.IsNullOrEmpty(textFieldHouseNumber.Text) == true ||
                String.IsNullOrEmpty(textFieldPostalCode.Text) == true ||
                String.IsNullOrEmpty(textFieldVillage.Text) == true)
            {
                MessageBox.Show("Sie haben nicht alle Daten erfasst");
            }
            else
            {
                int sellerId = -1;

                if (String.IsNullOrEmpty(textFieldSellerId.Text) == false)
                {
                    sellerId = Convert.ToInt32(textFieldSellerId.Text);
                }

                CustomDataObjects.Seller seller = new CustomDataObjects.Seller(sellerId,
                                                                               textFieldGivenName.Text,
                                                                               textFieldSureName.Text,
                                                                               textFieldStreet.Text + " " + textFieldHouseNumber.Text,
                                                                               textFieldPostalCode.Text + " " + textFieldVillage.Text,
                                                                               textFieldSellerEmail.Text);

                NetworkComms.SendObject("MessageSeller", _Model.ServerIpAddresse, Convert.ToInt32(_Model.ServerPort), seller);
            }
        }
Пример #2
0
        private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Access (*.mdb)|*.mdb";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                DataTable userTables = null;
                string    fileName   = openFileDialog1.FileName;
                string    conString  =
                    @"Provider=Microsoft.JET.OLEDB.4.0;"
                    + @"data source=" + fileName;

                OleDbConnection oleDbConnection = new OleDbConnection(conString);

                oleDbConnection.Open();

                // create the DataSet
                DataSet          dataSet = new DataSet();
                OleDbDataAdapter adapter =
                    new OleDbDataAdapter("Select * from Verkäuferdaten", oleDbConnection);
                adapter.Fill(dataSet);

                DataSet          dataSetNumbers = new DataSet();
                OleDbDataAdapter adapterNumbers =
                    new OleDbDataAdapter("Select * from Verkaufsnummern", oleDbConnection);
                adapterNumbers.Fill(dataSetNumbers);

                oleDbConnection.Close();

                DataTable dt = dataSet.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Debug.WriteLine(dr["ID"].ToString() + " " + dr["Verkäufer_Name"].ToString());

                    string   name         = dr["Verkäufer_Name"].ToString();
                    string[] splittedName = name.Split(' ');

                    string streetHouseNumber = dr["Verkäufer_Straße"].ToString();

                    string villagePostalCode = dr["Verkäufer_Ort"].ToString();

                    InputForm inputForm;

                    if (splittedName.Length == 1)
                    {
                        inputForm = new InputForm("In den Namensdaten [ " + splittedName[0] + "] ist ein Fehler aufgedrehten", "Vorname", "Nachname");

                        if (inputForm.ShowDialog() == DialogResult.OK)
                        {
                            inputForm.GetTexts(ref splittedName);
                        }
                    }

                    CustomDataObjects.Seller seller = new CustomDataObjects.Seller(Convert.ToInt32(dr["ID"]),
                                                                                   splittedName[0],
                                                                                   splittedName[1],
                                                                                   streetHouseNumber,
                                                                                   villagePostalCode,
                                                                                   dr["Verkäufer_EMail"].ToString());
                    seller.CreateNewSeller = true;

                    DataTable dt2 = dataSetNumbers.Tables[0];
                    foreach (DataRow dr2 in dt2.Rows)
                    {
                        int sellerId1 = Convert.ToInt32(dr2["Verkäufer_ID"]);
                        int sellerId2 = Convert.ToInt32(dr["ID"]);

                        if (sellerId1 == sellerId2)
                        {
                            seller.SaleNumbers.Add(Convert.ToInt32(dr2["Verkaufsnr"]));
                        }
                    }

                    NetworkComms.SendObject("MessageSeller", _Model.ServerIpAddresse, Convert.ToInt32(_Model.ServerPort), seller);
                }
            }
        }