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 Sick
    {
    }
    class DrugSick : Sick
    {
        //Define sqlconnection for connect to database
        SqlConnection objConnecting = new SqlConnection("server=(local);database=Drug;Integrated Security=True");
        public void AddSick(string SickMeliCodeV, string SickFNameV, string SickLNameV, string SickSexV, string SickYearV, string SickPolicyTypeV, string SickPolicyNumV, string AccessCodeDrugV, string SickNumDrugV)
        {
            try
            {
                SqlCommand objcommanding = new SqlCommand();
                objcommanding.Connection = objConnecting;
                objcommanding.CommandText = "insert into DrugSick (SickMeliCode,SickFName,SickLName,SickSex,SickYear,SickPolicyType,SickPolicyNum,AccessCodeDrug,SickNumDrug) values(@SickMeliCode,@SickFName,@SickLName,@SickSex,@SickYear,@SickPolicyType,@SickPolicyNum,@AccessCodeDrug,@SickNumDrug)";
                objcommanding.Parameters.AddWithValue("@SickMeliCode", SickMeliCodeV);
                objcommanding.Parameters.AddWithValue("@SickFName", SickFNameV);
                objcommanding.Parameters.AddWithValue("@SickLName", SickLNameV);
                objcommanding.Parameters.AddWithValue("@SickSex", SickSexV);
                objcommanding.Parameters.AddWithValue("@SickYear", SickYearV);
                objcommanding.Parameters.AddWithValue("@SickPolicyType", SickPolicyTypeV);
                objcommanding.Parameters.AddWithValue("@SickPolicyNum", SickPolicyNumV);
                objcommanding.Parameters.AddWithValue("@AccessCodeDrug", AccessCodeDrugV);
                objcommanding.Parameters.AddWithValue("@SickNumDrug", SickNumDrugV);
                objConnecting.Open();
                objcommanding.ExecuteNonQuery();
                objConnecting.Close();
                //Send message for user 
                MessageBox.Show("اطلاعات ذخیره شد", "ذخیره سازی");

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

        }
    }
}
