Ejemplo n.º 1
0
        private void Matches_Name(ProgressBarForm progressBarForm)
        {
            DataTable      dt        = (DataTable)myDataGridView1.DataSource;
            string         cInvName  = dictparam["cInvName"];
            List <DataRow> rowlist   = new List <DataRow>();
            List <int>     indexlist = new List <int>();
            DataTable      dtData    = new DataTable();

            foreach (DataColumn col in dt.Columns)
            {
                dtData.Columns.Add(col.ColumnName);
            }
            try
            {
                for (int index = 0; index < dt.Rows.Count; index++)
                {
                    if (progressBarForm.Stop == true)
                    {
                        return;
                    }
                    progressBarForm.Value = index + 1;
                    DataRow row  = dt.Rows[index];
                    string  str1 = row[cInvName].ToString().Trim();

                    DataRow newRow = null;
                    if (!str1.Equals(""))
                    {
                        DataTable data = sqlProcessor.AccurateQuery_Like(str1, "cInvName");
                        if (data != null)
                        {
                            if (data != null)
                            {
                                if (data.Rows.Count == 1)
                                {
                                    newRow = data.Rows[0];
                                    rowlist.Add(data.Rows[0]);
                                    indexlist.Add(index);
                                }
                                else if (data.Rows.Count > 1)
                                {
                                    dtData.Clear();
                                    dtData.Rows.Add(dt.Rows[index].ItemArray);

                                    DataForm form2 = new DataForm(sqlProcessor, data, dtData);
                                    if (form2.ShowDialog() == DialogResult.OK)
                                    {
                                        DataRow rowf = form2._row;
                                        newRow = rowf;
                                        rowlist.Add(rowf);
                                        indexlist.Add(index);
                                    }
                                }
                            }
                        }
                    }
                    row.BeginEdit();
                    //progressBarForm.AddProgress(40);
                    if (newRow != null)
                    {
                        foreach (var map in param.Maps)
                        {
                            if (row.Table.Columns.Contains(map.Value) && newRow.Table.Columns.Contains(map.Name))
                            {
                                row[map.Value] = newRow[map.Name].ToString();
                            }
                            else if (row.Table.Columns.Contains(map.Value) && newRow.Table.Columns.Contains(map.Value))
                            {
                                row[map.Value] = newRow[map.Value].ToString();
                            }
                        }
                    }
                    row.EndEdit();
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
            dt.AcceptChanges();
        }