﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UI.Desktop
{
    public partial class AddPlan : Form
    {
        private static Business.Logic.DatabaseLink dbLink = new Business.Logic.DatabaseLink();
        public AddPlan()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            dbLink.refreshLink();
            System.Data.SqlClient.SqlCommand addplansql = dbLink.getQuery("INSERT INTO dbo.plans (name,description) VALUES (@name,@description)");
            addplansql.Parameters.AddWithValue("@name", txtName.Text);
            addplansql.Parameters.AddWithValue("@description", txtDescription.Text);
            addplansql.ExecuteNonQuery();
            addplansql.Parameters.Clear();
            dbLink.refreshLink();
            this.DialogResult = DialogResult.OK; 
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
