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 Sell
    {
    }
    class DrugSell : Sell
    {
        //Define Sqlconnection For connect to Database
        SqlConnection objConnect = new SqlConnection("server=(local);database=Drug;Integrated Security=True");
        public void AddSell(string DrugSellerV, string AccessCodeDrugV, string DrugTotalBuyV, string DrugFactorNumV, string DrugFactorDateV, string AccessCodeSellV,string DrugBuyAmountV)
        {
            try
            {
                SqlCommand objcom = new SqlCommand();
                objcom.Connection = objConnect;
                objcom.CommandText = "INSERT INTO DrugSelling (DrugSeller,AccessCodeDrug,DrugTotalBuy,DrugFactorNum,DrugFactorDate,AccessCodeSell,DrugBuyAmount) VALUES(@DrugSeller,@AccessCodeDrug,@DrugTotalBuy,@DrugFactorNum,@DrugFactorDate,@AccessCodeSell,@DrugBuyAmount)";
                objcom.Parameters.AddWithValue("@DrugSeller", DrugSellerV);
                objcom.Parameters.AddWithValue("@AccessCodeDrug", AccessCodeDrugV);
                objcom.Parameters.AddWithValue("@DrugTotalBuy", DrugTotalBuyV);
                objcom.Parameters.AddWithValue("@DrugFactorNum", DrugFactorNumV);
                objcom.Parameters.AddWithValue("@DrugFactorDate", DrugFactorDateV);
                objcom.Parameters.AddWithValue("@AccessCodeSell", AccessCodeSellV);
                objcom.Parameters.AddWithValue("@DrugBuyAmount", DrugBuyAmountV);
                objConnect.Open();
                objcom.ExecuteNonQuery();
                objConnect.Close();
                //send Message For user
                MessageBox.Show("اطلاعات ذخیره شد", "ذخیره سازی");
            }
            catch
            {
                MessageBox.Show("شماره دسترسی تکراری است ", "خطا");
            }
        }
    }
}