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

            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");
            }
        }
예제 #2
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForTagEmployee itemSelected = (ModelNotifiedForTagEmployee)DataGridTagEmployee.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(TagEmployeeDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(TagEmployeeDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }