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;

namespace Entity_FrameWork
{
    public partial class Factor : Form
    {
        int CodFactor;
        public Factor(int _CodFactor)
        {
            InitializeComponent();

            CodFactor = _CodFactor;

            this.MinimumSize = new System.Drawing.Size(773, 548);
         
        }
        Entity_FrameWorkEntities5 MyModel = new Entity_FrameWorkEntities5();
        private void Factor_Load(object sender, EventArgs e)
        {
            dataGridViewFactor.DataSource = MyModel.Sp_SelectFactor(CodFactor).ToList();
            dataGridViewFactor.Columns[0].HeaderText = "كد فاكتور";
            dataGridViewFactor.Columns[1].HeaderText = "كد كالا";
            dataGridViewFactor.Columns[2].HeaderText = "نام كالا";
            dataGridViewFactor.Columns[3].HeaderText = "مدل";
            dataGridViewFactor.Columns[4].HeaderText = "رنگ";
            dataGridViewFactor.Columns[5].HeaderText = "تعداد";
            dataGridViewFactor.Columns[6].HeaderText = "مبلغ";


        }

        private void dataGridViewFactor_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            
        }

        private void button_Insert_Click(object sender, EventArgs e)
        {

            MyModel.Sp_InsertFactor(CodFactor,textBox_NameKala.Text,textBox_Model.Text,textBox_Color.Text,textBox_Tedad.Text,Convert.ToInt32(textBox_Money.Text));

        }

        private void button_PrintFactor_Click(object sender, EventArgs e)
        {
            PrintFactor.Load(Application.StartupPath + @"\ReportFactor.mrt");
         spPrintFactornewResultBindingSource.DataSource=  MyModel.Sp_PrintFactornew(CodFactor);
            PrintFactor.RegReportDataSources();
            PrintFactor.Show();
        }

        private void dataGridViewFactor_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {

          
          textBox_NameKala.Text = dataGridViewFactor.CurrentRow.Cells[2].Value.ToString();
           textBox_Model.Text = dataGridViewFactor.CurrentRow.Cells[3].Value.ToString();
            textBox_Color.Text = dataGridViewFactor.CurrentRow.Cells[4].Value.ToString();
           textBox_Tedad.Text = dataGridViewFactor.CurrentRow.Cells[5].Value.ToString();
           textBox_Money.Text = dataGridViewFactor.CurrentRow.Cells[6].Value.ToString();
        }

        private void spSearchFactorResultBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void dataGridViewFactor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void buttonPrintA5_Click(object sender, EventArgs e)
        {
            stiReportA5.Load(Application.StartupPath + @"\ReportA5Factor.mrt");
            spPrintFactornewResultBindingSource.DataSource = MyModel.Sp_PrintFactornew(CodFactor);
            stiReportA5.RegReportDataSources();
            stiReportA5.Show();
        }
    }
}
