Пример #1
0
        public Anagrafica_Personale_Doc_PaxDataTable prodottoCartesianoIntelligeteDataview(DataView dt1, DataView dt2)
        {
            IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable dtMergeTable = new IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable();
            IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable dtPassaggio  = new IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable();
            List <int> elementiInseritiChiavi = new List <int>();

            foreach (DataRowView dr1 in dt1)

            {
                foreach (DataRowView dr2 in dt2)
                {
                    if (dr1.Row.Field <int>("Id_Personale") == dr2.Row.Field <int>("Id_Anagrafica_Pax") && !elementiInseritiChiavi.Contains(dr1.Row.Field <int>("Id_Personale")))
                    {
                        fillGenericDrNONPOSIZIONALEFromDRView(dr1.Row, dr2.Row, false, ref dtPassaggio);


                        elementiInseritiChiavi.Add(dr1.Row.Field <int>("Id_Personale"));
                    }
                }
            }
            return(dtPassaggio);
        }
Пример #2
0
        public Anagrafica_Personale_Doc_PaxDataTable selectOneToManyIntReferencesConProdCartesiano(DataTable DTOne, DataTable DTMany)
        {
            Assembly assembly = Assembly.LoadFrom(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\IMTS.exe");

            // Assembly assembly = Assembly.GetExecutingAssembly();
            assembly.CreateInstance("IMTSDB_NEW.Anagrafica_PersonaleDataTable");


            //Activator.CreateInstance(type);
            IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable dtMergeTable = new IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable();

            DataTable dt = DTOne;
            DataView  dv = dt.DefaultView;


            DataTable dt1 = DTMany;
            DataView  dv1 = new DataView();

            dtMergeTable = prodottoCartesianoIntelligeteTabelle(DTOne, DTMany);


            return(dtMergeTable);
        }
Пример #3
0
        public object selectOneToManyIntReferencesTB1(DataTable DTOne, DataTable DTMany, string filterDBOne, string filterDTMany, string keyDTOne, string keyDMany, Type tpkey, bool isDistinct, object typeofMergeDT, object dtMerge, int totColumn)
        {
            Assembly assembly = Assembly.LoadFrom(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\IMTS.exe");

            // Assembly assembly = Assembly.GetExecutingAssembly();
            assembly.CreateInstance("IMTSDB_NEW.Anagrafica_PersonaleDataTable");


            //Activator.CreateInstance(type);
            IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable dtMergeTable = new IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable();
            DataTable dt = DTOne;
            DataView  dv = dt.DefaultView;

            //dv.ApplyDefaultSort = true;


//            //prrova commento
            dv.Sort      = keyDTOne + " ASC";
            dv.RowFilter = filterDBOne;

            //dv.ApplyDefaultSort = true;

            DataTable dt1 = DTMany;
            DataView  dv1 = new DataView();

            dv1 = dt1.DefaultView;
            //            //dv1.ApplyDefaultSort = true;

            dv1.Sort      = keyDMany + ",Id_Documento ASC";
            dv1.RowFilter = filterDTMany;
            //            //dv1.RowStateFilter=DataViewRowState.
            ////fine prova commento



            //lista delle chiavi tablella many che hanno sperato il filtro quindi buone
            List <int> dtFilterGiantList = new List <int>();

            foreach (DataRowView vrowdp in dv1)
            {
                //anagRowFilterGiant.Append(vrowdp.Row.Field<int>("Id_Anagrafica_Pax")+"#");
                if (!dtFilterGiantList.Contains(vrowdp.Row.Field <int>(keyDMany)))
                {
                    dtFilterGiantList.Add(vrowdp.Row.Field <int>(keyDMany));
                }
                //anagRowFilterGiantArray[k] = vrowdp.Row.Field<int>("Id_Anagrafica_Pax");
                //k++;
                //first = true;
            }

            List <int> dtFilterGiantListAnag = new List <int>();

            foreach (DataRowView vrowdp in dv)
            {
                //anagRowFilterGiant.Append(vrowdp.Row.Field<int>("Id_Anagrafica_Pax")+"#");
                if (!dtFilterGiantListAnag.Contains(vrowdp.Row.Field <int>(keyDTOne)))
                {
                    dtFilterGiantListAnag.Add(vrowdp.Row.Field <int>(keyDTOne));
                }
                //anagRowFilterGiantArray[k] = vrowdp.Row.Field<int>("Id_Anagrafica_Pax");
                //k++;
                //first = true;
            }
            DataRow[]  associated             = null;
            DataRow[]  associatedFiltered     = null;
            DataRow[]  associatedDP           = null;
            DataRow[]  associatedDPFiterred   = null;
            List <int> elementiInseritiChiavi = new List <int>();

            foreach (int key in dtFilterGiantList)
            {
                associated = dt.Select("Id_Personale=" + key);

                associatedDP = dt1.Select("Id_Anagrafica_Pax=" + key);



                associatedFiltered   = associated.CopyToDataTable().Select(filterDBOne);
                associatedDPFiterred = associatedDP.CopyToDataTable().Select(filterDTMany);

                for (int k = 0; k <= associatedFiltered.Length - 1; k++)
                // foreach (DataRow rowresult in associatedFiltered)
                {
                    for (int i = 0; i < associatedDPFiterred.Length - 1; i++)
                    {
                        if (associatedFiltered[k].Field <int>("Id_Personale") == associatedDPFiterred[i].Field <int>("Id_Anagrafica_Pax") && !elementiInseritiChiavi.Contains(key))
                        {
                            dtMergeTable.AddAnagrafica_Personale_Doc_PaxRow(fillGenericDrFromDRView(associatedFiltered[k], associatedDPFiterred[i], false, ref dtMergeTable));
                            dtMergeTable.AcceptChanges();
                            elementiInseritiChiavi.Add(key);
                        }
                    }
                }

                for (int k = 0; k < associatedDPFiterred.Length - 1; k++)
                // foreach (DataRow rowresult in associatedFiltered)
                {
                    for (int i = 0; i < associatedFiltered.Length - 1; i++)
                    {
                        if (associatedDPFiterred[k].Field <int>("Id_Anagrafica_Pax") == associatedFiltered[i].Field <int>("Id_Personale") && !elementiInseritiChiavi.Contains(key))
                        {
                            dtMergeTable.AddAnagrafica_Personale_Doc_PaxRow(fillGenericDrFromDRView(associatedFiltered[i], associatedDPFiterred[k], false, ref dtMergeTable));
                            dtMergeTable.AcceptChanges();
                            elementiInseritiChiavi.Add(key);
                        }
                    }
                }
            }
            foreach (int key in dtFilterGiantListAnag)
            {
                associated = dt.Select("Id_Personale=" + key);

                associatedDP = dt1.Select("Id_Anagrafica_Pax=" + key);



                associatedFiltered   = associated.CopyToDataTable().Select(filterDBOne);
                associatedDPFiterred = associatedDP.CopyToDataTable().Select(filterDTMany);

                for (int k = 0; k <= associatedFiltered.Length - 1; k++)
                // foreach (DataRow rowresult in associatedFiltered)
                {
                    for (int i = 0; i < associatedDPFiterred.Length - 1; i++)
                    {
                        if (associatedFiltered[k].Field <int>("Id_Personale") == associatedDPFiterred[i].Field <int>("Id_Anagrafica_Pax") && !elementiInseritiChiavi.Contains(key))
                        {
                            dtMergeTable.AddAnagrafica_Personale_Doc_PaxRow(fillGenericDrFromDRView(associatedFiltered[k], associatedDPFiterred[i], false, ref dtMergeTable));
                            dtMergeTable.AcceptChanges();
                            elementiInseritiChiavi.Add(key);
                        }
                    }
                }

                for (int k = 0; k < associatedDPFiterred.Length - 1; k++)
                // foreach (DataRow rowresult in associatedFiltered)
                {
                    for (int i = 0; i < associatedFiltered.Length - 1; i++)
                    {
                        if (associatedDPFiterred[k].Field <int>("Id_Anagrafica_Pax") == associatedFiltered[i].Field <int>("Id_Personale") && !elementiInseritiChiavi.Contains(key))
                        {
                            dtMergeTable.AddAnagrafica_Personale_Doc_PaxRow(fillGenericDrFromDRView(associatedFiltered[i], associatedDPFiterred[k], false, ref dtMergeTable));
                            dtMergeTable.AcceptChanges();
                            elementiInseritiChiavi.Add(key);
                        }
                    }
                }
            }

            return(dtMergeTable);
        }
Пример #4
0
        //todo fillGenericDrFromDRView non posizionale con i column name!
        public Anagrafica_Personale_Doc_PaxRow fillGenericDrNONPOSIZIONALEFromDRView(DataRow vrowOne, DataRow vrowMany, bool partiallyFill, ref IMTSDB_NEW.Anagrafica_Personale_Doc_PaxDataTable JaggedDT)
        {
            Anagrafica_Personale_Doc_PaxRow anprow = JaggedDT.NewAnagrafica_Personale_Doc_PaxRow();

            anprow.BeginEdit();
            int k = 0;

            for (int h = 0; h < anprow.ItemArray.Length; h++)
            {
                if (h < vrowOne.ItemArray.Length)
                {
                    if (anprow.Table.Columns[h].DataType == typeof(int) && (anprow.Table.Columns[h].ColumnName == vrowOne.Table.Columns[h].ColumnName))
                    {
                        try
                        {
                            if (!DBNull.Value.Equals(vrowOne.Field <int>(h)))
                            {
                                anprow[h] = Convert.ToInt32(vrowOne.Field <int>(h));
                            }
                            else
                            {
                                anprow[h] = 0;
                            }
                        }
                        catch { }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(string) && (anprow.Table.Columns[h].ColumnName == vrowOne.Table.Columns[h].ColumnName))
                    {
                        try
                        {
                            if (!DBNull.Value.Equals(vrowOne.Field <string>(h)))
                            {
                                anprow[h] = Convert.ToString(vrowOne.Field <string>(h));
                            }

                            else
                            {
                                anprow[h] = String.Empty;
                            }
                        }
                        catch { }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(DateTime) && (anprow.Table.Columns[h].ColumnName == vrowOne.Table.Columns[h].ColumnName))
                    {
                        if (!DBNull.Value.Equals(vrowOne.Field <string>(h)))
                        {
                            anprow[h] = Convert.ToDateTime(vrowOne.Field <string>(h));
                        }

                        else
                        {
                            anprow[h] = DateTime.MinValue;
                        }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(short) && (anprow.Table.Columns[h].ColumnName == vrowOne.Table.Columns[h].ColumnName))
                    {
                        if (!DBNull.Value.Equals(vrowOne.Field <short>(h)))
                        {
                            anprow[h] = Convert.ToUInt16(vrowOne.Field <short>(h));
                        }

                        else
                        {
                            anprow[h] = 0;
                        }
                    }
                }



                else
                if (h < vrowOne.ItemArray.Length + vrowMany.ItemArray.Length && h > vrowOne.ItemArray.Length - 1)
                {
                    if (anprow.Table.Columns[h].DataType == typeof(int) && (anprow.Table.Columns[h].ColumnName == vrowMany.Table.Columns[k].ColumnName))
                    {
                        try
                        {
                            if (!DBNull.Value.Equals(vrowMany.Field <int>(k)))
                            {
                                anprow[h] = Convert.ToInt32(vrowMany.Field <int>(k));
                            }
                            else
                            {
                                anprow[h] = 0;
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(string) && (anprow.Table.Columns[h].ColumnName == vrowMany.Table.Columns[k].ColumnName))
                    {
                        try
                        {
                            if (!DBNull.Value.Equals(vrowMany.Field <string>(k)))
                            {
                                anprow[h] = Convert.ToString(vrowMany.Field <string>(k));
                            }

                            else
                            {
                                anprow[h] = String.Empty;
                            }
                        }
                        catch { }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(DateTime) && (anprow.Table.Columns[h].ColumnName == vrowMany.Table.Columns[k].ColumnName))
                    {
                        if (!DBNull.Value.Equals(vrowMany.Field <string>(k)))
                        {
                            anprow[h] = Convert.ToDateTime(vrowMany.Field <string>(k));
                        }

                        else
                        {
                            anprow[h] = DateTime.MinValue;
                        }
                    }
                    if (anprow.Table.Columns[h].DataType == typeof(short) && (anprow.Table.Columns[h].ColumnName == vrowMany.Table.Columns[k].ColumnName))
                    {
                        if (!DBNull.Value.Equals(vrowMany.Field <short>(k)))
                        {
                            anprow[h] = Convert.ToUInt16(vrowMany.Field <short>(k));
                        }

                        else
                        {
                            anprow[h] = 0;
                        }
                    }

                    k++;
                }
            }
            anprow.EndEdit();
            JaggedDT.AddAnagrafica_Personale_Doc_PaxRow(anprow);
            JaggedDT.AcceptChanges();

            return(anprow);
        }