//public invoicedetailform(int _id, int _userid)
        //{
        //    initializecomponent();
        //    userid = _userid;
        //    invoiceid = _id;
        //    blclient blclient = new blclient();
        //    cmbclientfullname.datasource = blclient.getclientfullname(0);
        //    cmbclientfullname.displaymember = "clientfullname";
        //}
        public InvoiceDetailForm(int _id, int _userId)
        {
            InitializeComponent();
            //userId = _userId;
            invoiceId = _id;
            userId    = _userId;

            BLInvoice bLInvoice             = new BLInvoice();
            List <DisplayInvoiceModel> list = bLInvoice.GetDisplayInvoice(invoiceId, "", DateTime.Now, DateTime.Now, "");
            DisplayInvoiceModel        displayInvoiceModel = new DisplayInvoiceModel();

            if (list.Count > 0)
            {
                displayInvoiceModel = list[0];
            }
            //txtAddress.Text = displayInvoiceModel.Address;
            //txtClientFullName.Text = displayInvoiceModel.ClientFullName;
            txtInvoiceNumber.Text = displayInvoiceModel.InvoiceNumber;
            dateInvoice.Value     = (displayInvoiceModel.InvoiceDate == DateTime.Parse("1/1/0001 12:00:00 AM")) ? DateTime.Now : displayInvoiceModel.InvoiceDate;

            BLClient bLClient = new BLClient();
            List <ClientFullNameModel> clients = bLClient.GetClientFullName(0);

            cmbClientFullName.DataSource = clients;



            ClientFullNameModel clientFullName = bLClient.GetClientFullName(displayInvoiceModel.ClientId)[0];

            //int index = clients.IndexOf(clientFullName);

            int index = clients.FindIndex(a => a.ClientId == clientFullName.ClientId);



            cmbClientFullName.SelectedIndex = index;
            //MessageBox.Show(cmbClientFullName.SelectedIndex.ToString());
            //cmbClientFullName.

            //MessageBox.Show(cmbClientFullName.SelectedItem.ClientId);

            //cmbClientFullName.

            cmbClientFullName.DisplayMember = "ClientFullName";
            //cmbClientFullName.DisplayMember = "ClientSurname";
            //txtInvoiceDate.Text = displayInvoiceModel.InvoiceDate.Year.ToString()+"-"+ displayInvoiceModel.InvoiceDate.Month.ToString()+"-"+ displayInvoiceModel.InvoiceDate.Day.ToString();
            txtObservations.Text = displayInvoiceModel.Observations;
            BLInvoiceDetail bLInvoiceDetail = new BLInvoiceDetail();

            dataGridDetails.DataSource = bLInvoiceDetail.GetInvoiceDetail(invoiceId);

            dataGridDetails.Columns["InvoiceDetailId"].Visible = false;
            dataGridDetails.Columns["ItemId"].Visible          = false;
            dataGridDetails.Columns["InvoiceId"].Visible       = false;
            dataGridDetails.Columns["Status"].Visible          = false;
            dataGridDetails.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }