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

namespace WindowsFormsApplication1
{
    class Drug
    {
    }
    class DrugStore : Drug
    {
        //define sqlconnection for connect to database
        SqlConnection objConnection = new SqlConnection("server=(local);database=Drug;Integrated Security=True");
        public void AddDrug(string LatinDrugV, string ShortDrugV, string PersionDrugV, string AccessCodeDrugV, string ExchangeUnitV, string PriceV, string DrugFormV)
        {
            try
            {
                SqlCommand objCommand = new SqlCommand();
                objCommand.Connection = objConnection;
                objCommand.CommandText = "insert into DrugDefinition (LatinDrug,ShortDrug,PersionDrug,AccessCodeDrug,ExchangeUnit,Price,DrugForm) values(@LatinDrug,@ShortDrug,@PersionDrug,@AccessCodeDrug,@ExchangeUnit,@Price,@DrugForm)";
                objCommand.Parameters.AddWithValue("@LatinDrug", LatinDrugV);
                objCommand.Parameters.AddWithValue("@ShortDrug", ShortDrugV);
                objCommand.Parameters.AddWithValue("@PersionDrug", PersionDrugV);
                objCommand.Parameters.AddWithValue("@AccessCodeDrug", AccessCodeDrugV);
                objCommand.Parameters.AddWithValue("@ExchangeUnit", ExchangeUnitV);
                objCommand.Parameters.AddWithValue("@Price", PriceV);
                objCommand.Parameters.AddWithValue("@DrugForm", DrugFormV);
                objConnection.Open();
                objCommand.ExecuteNonQuery();
                objConnection.Close();
                //Send message for user 
                MessageBox.Show("اطلاعات ذخیره شد", "ذخیره سازی");

            }
            catch
            {
                MessageBox.Show("شماره دسترسی تکراری است ", "خطا");
            }

        }


    }
  
    }


