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;
using System.Data.SqlClient;

namespace Emdad
{
    public partial class FrmHadese : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=emdad;Integrated Security=True");
        SqlCommand cmd = new SqlCommand();
        public FrmHadese()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txttype.Text == "")
                MessageBox.Show("لطفا فیلدهای ستاره دار را پر کنید");
            else
            {
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = "insert into [Hadese] (Name,time,level) values ('"+txttype.Text.Trim()+"','"+txttime.Text.Trim()+"','"+comboBox1.SelectedItem.ToString()+"')";
                cmd.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("ثبت اطلاعات با موفقیت انجام شد");
                txttype.Text = txttime.Text = "";
            }
        }
    }
}
