Beispiel #1
0
        /// <summary>
        /// Update existing data or include new data
        /// </summary>
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            string error      = null;
            var    itemToSave = SuppliersDataContext.modelNotifiedForSuppliersMain;

            if (btnUpdate.Tag == "btnSave")//todo este if nao funciona mais. pegar da "if new " da classe.
            {
                dataConnection.AddData(itemToSave, out error);
            }
            else
            {
                dataConnection.SaveData(itemToSave, out error);
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                MessageBox.Show("OK");
            }
        }
Beispiel #2
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForSuppliers itemSelected = (ModelNotifiedForSuppliers)DataGridSuppliers.SelectedItem;

            if (itemSelected == null)
            {
                return;
            }

            string error = null;

            if (itemSelected.NewItem)
            {
                dataConnection.AddData(itemSelected, out error);

                if (error == null)
                {
                    btnReload_Click(null, null);
                }
            }
            else
            {
                dataConnection.SaveData(itemSelected, out error);
            }

            if (error == null)
            {
                //MessageBox.Show(MessageBoxSaveOK);
                MessageBox.Show(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }