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

namespace WindowsApplication1
{
    public partial class frmSearchPhones : Form
    {
        public frmSearchPhones()
        {
            InitializeComponent();
        }

        private void dbSearch()
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("لطقا شماره تلفن را وارد فرمائید");
            }
            else
            {
                FirstClass db = new FirstClass();
                DataTable dt = new DataTable();

                dt = db.dbOut(@"SELECT     PhoneNumbers.PhoneNumberID AS [کد شماره], PhoneNumberTypes.PhoneNumberType AS [نوع شماره تلفن], 
                      CustumerCode.Name + N'  ' + CustumerCode.Sname AS [نام و نام خانوادگی], PhoneNumbers.PhoneNumber AS [شماره تلفن]
                        FROM         CustumerCode INNER JOIN PhoneNumbers ON CustumerCode.CustomerID = PhoneNumbers.CostumerID INNER JOIN
                      PhoneNumberTypes ON PhoneNumbers.PhoneNumberTypeID = PhoneNumberTypes.PhonesTypeID WHERE     (PhoneNumbers.PhoneNumber = N'" + textBox1.Text.Trim() + "')");

                if (dt.Rows.Count <= 0)
                {
                    MessageBox.Show("موردی پیدا نشد");
                }
                else
                {
                    dataGridView1.DataSource = dt;
                }
            }

        }

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


    }
}