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

namespace amlakyar
{
    public partial class frm_dakhast_rahn_ejare : Form
    {
        static SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\amlak.mdf;integrated security=true;User Instance=True");
        SqlDataAdapter da = new SqlDataAdapter("", con);
        DataSet ds = new DataSet();
        DataSet dsc = new DataSet();

        public frm_dakhast_rahn_ejare()
        {
            InitializeComponent();
        }

        

        private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frm_etelat_kharidar_va_foroshande vorod21 = new frm_etelat_kharidar_va_foroshande();
            vorod21.ShowDialog();
        }

        private void frm_dakhast_rahn_ejare_Load(object sender, EventArgs e)
        {
            da.SelectCommand.CommandText = "select * from etelat_melk ";
            da.Fill(ds, "h");
            commelk.DataSource = ds;
            commelk.DisplayMember = "h.name_melk";


            da.SelectCommand.CommandText = "select * from kharidar_forushande ";
            da.Fill(ds, "z");

            comdarkhast.DataSource = ds;
            comdarkhast.DisplayMember = "z.name";


            da.SelectCommand.CommandText = "select * from manategh ";
            da.Fill(ds, "g");
            commantaghe.DataSource = ds;
            commantaghe.DisplayMember = "g.mantaghe";


            timer1.Enabled = true;
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            DateTime dt = new DateTime();
            dt = DateTime.Now;
            Class_date cdate = new Class_date();
            string date = dt.Year.ToString() + "/" + dt.Month.ToString() + "/" + dt.Day.ToString();

           
        }

       

        private void comdarkhast_MouseEnter(object sender, EventArgs e)
        {
            dsc.Clear();
            da.SelectCommand.CommandText = "select * from kharidar_forushande ";
            da.Fill(dsc, "z");

            comdarkhast.DataSource = dsc;
            comdarkhast.DisplayMember = "z.name";
        }

       

        private void glassButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void glassButton2_Click(object sender, EventArgs e)
        {
            string c;


            SqlDataAdapter da = new SqlDataAdapter("", con);
            if (txtmablagh_rahn.Text != "")
            {



                c = "insert into darkhast_rahn_ejare(type,melk,darkhast,max_mablagh_rahn,max_mablagh_ejare,mantaghe,tasis,tedad,hodod_metraj,tedad_otagh,ghedmat,saer) values ('" + comtype.Text + "', '" + commelk.Text + "', '" + comdarkhast.Text + "', '" + txtmablagh_rahn.Text + "', '" + txtmablagh_ejare.Text + "', '" + commantaghe.Text + "', '" + txttasis.Text + "', '" + txttedad.Text + "', '" + txthodod_metraj.Text + "','" + txttedad_otagh.Text + "','" + txtghedmat.Text + "','" + txtsaer.Text + "' )";
                SqlCommand cmd = new SqlCommand(c, con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();






                MessageBox.Show("اطلاعات با موفقیت ثبت شد");
            }
            else { MessageBox.Show("لطفا فيلد های ستاره دار را به دقت وارد نماييد"); }
        }
    }
}