示例#1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Location] ([Name]) VALUES (N'{LocationName.Text}')");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Location] set [Name] = N'{LocationName.Text}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;
            bool   isSp = TypeCheckName.SelectedItem.Equals("СП");

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Sp_Si] ([RegisterNumber],[Deal],[Page],[IsSp]) VALUES (N'{RegisterNumberName.Text}',N'{DealName.Text}',N'{PageName.Text}',{isSp.ToString().ToLower()})");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Sp_Si] set [RegisterNumber] = N'{RegisterNumberName.Text}', [Deal] = N'{DealName.Text}', [Page] = N'{PageName.Text}', [IsSp] = '{isSp.ToString().ToLower()}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string exeption;
            var    typeId = ((DataRowView)TypeName.SelectedItem).Row["ID"];

            if (DR["ID"] == DBNull.Value)
            {
                exeption = ConnectBL.ExecAction($"INSERT INTO [dic].[Model] ([TypeId],[Name]) VALUES ({typeId},N'{ModelName.Text}')");
            }
            else
            {
                exeption = ConnectBL.ExecAction($"Update [dic].[Model] set [TypeId] = {typeId}, [Name] = N'{ModelName.Text}' where ID = {DR["ID"]}");
            }
            if (exeption != null)
            {
                MessageBox.Show(exeption, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DialogResult = true;
            Close();
        }