Beispiel #1
0
        private void GetDataAdapterList()
        {
            string mstart = _tableAdapterManagerType.FullName;

            mstart = mstart.Substring(0, mstart.Length - adapterManagerClassSuffix.Length);
            Type         tp;
            string       s;
            Object       o;
            PropertyInfo pri;
            Type         mtp = TableAdapterManager.GetType();

            sqlDataAdapters.Clear();
            dataAdapters.Clear();

            foreach (DataTable dt in DataSet.Tables)
            {
                s  = mstart + dt.TableName + adapterClassSuffix;
                tp = dt.GetType().Assembly.GetType(s, false, true);
                if (tp == null)
                {
                    continue;
                }
                o = Activator.CreateInstance(tp);
                dataAdapters[dt.TableName] = o;

                sqlDataAdapters[dt.TableName] = GetHiddenProperty(o, "Adapter") as DbDataAdapter;

                pri = mtp.GetProperty(dt.TableName + adapterClassSuffix);
                if (pri != null)
                {
                    pri.SetValue(TableAdapterManager, o, null);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// No conversion is done here, but a list of all Expressions is returned.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns>Expressions</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                _TAM     = new TableAdapterManager();
                _DataSet = new TrainingDataSet();
                _TAM.ExpressionTableAdapter = new ExpressionTableAdapter();

                _TAM.ExpressionTableAdapter.Fill(_DataSet.Expression);

                return(_DataSet.Expression);

                //TableAdapterManager _TAM = new TableAdapterManager();
                //TrainingDataSet _DataSet = new TrainingDataSet();
                //_TAM.ExpressionTableAdapter = new ExpressionTableAdapter();

                //_TAM.ExpressionTableAdapter.Fill(_DataSet.Expression);

                //ArrayList expressions = new ArrayList();

                //for (int i=0; i<_DataSet.Expression.Count; i++)
                //{
                //    expressions.Add(_DataSet.Expression[i].Expression);
                //}

                //return expressions;
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
Beispiel #3
0
        public async Task InsertVotersAsync(IEnumerable <VoterModel> voters)
        {
            await Task.CompletedTask;

            using (var dataSet = new StudentElectionDataSet())
            {
                using (var manager = new TableAdapterManager())
                {
                    manager.VoterTableAdapter = new VoterTableAdapter();

                    var id = -1;
                    foreach (var voter in voters)
                    {
                        var newRow = dataSet.Voter.NewVoterRow();
                        _mapper.Map(voter, newRow);

                        newRow.ID = id;
                        if (voter.Birthdate == null)
                        {
                            newRow.SetBirthdateNull();
                        }

                        dataSet.Voter.AddVoterRow(newRow);

                        id--;
                    }

                    manager.UpdateAll(dataSet);
                }
            }
        }
        public async Task CastVotesAsync(int ballotId, IEnumerable <VoteModel> votes, DateTime castedAt)
        {
            await Task.CompletedTask;

            using (var dataSet = new StudentElectionDataSet())
            {
                using (var manager = new TableAdapterManager())
                {
                    manager.VoteTableAdapter   = new VoteTableAdapter();
                    manager.BallotTableAdapter = new BallotTableAdapter();

                    foreach (var vote in votes)
                    {
                        var newRow = dataSet.Vote.NewVoteRow();
                        newRow.BallotId    = ballotId;
                        newRow.CandidateId = vote.CandidateId;

                        dataSet.Vote.AddVoteRow(newRow);
                    }

                    manager.BallotTableAdapter.FillBallotsById(dataSet.Ballot, ballotId);
                    var ballot = dataSet.Ballot.FindByID(ballotId);
                    ballot.CastedAt = castedAt;

                    manager.UpdateAll(dataSet);
                }
            }
        }
Beispiel #5
0
        public void CreateAdapterForTable(string tablename)
        {
            if (String.IsNullOrEmpty(tablename))
            {
                throw new ArgumentException();
            }

            string send   = "TableAdapter";
            string mend   = "TableAdapterManager";
            string mstart = _tableAdapterManagerType.FullName;

            mstart = mstart.Substring(0, mstart.Length - mend.Length);
            string adaptertypename = mstart + tablename + send;

            Type   tp = _tableAdapterManagerType.Assembly.GetType(adaptertypename, false, true);
            Object o  = Activator.CreateInstance(tp);

            Type         mtp = TableAdapterManager.GetType();
            PropertyInfo pri = mtp.GetProperty(tablename + send);

            if (pri != null)
            {
                pri.SetValue(TableAdapterManager, o, null);
            }

            dataAdapters[tablename]    = o;
            sqlDataAdapters[tablename] = GetHiddenProperty(o, "Adapter") as DbDataAdapter;
        }
Beispiel #6
0
 private void InitAdapterManager()
 {
     m_adapterManager                                        = new TableAdapterManager();
     m_adapterManager.Connection                             = m_connection;
     m_adapterManager.GroupsTableAdapter                     = new GroupsTableAdapter();
     m_adapterManager.GroupsTableAdapter.Connection          = m_connection;
     m_adapterManager.GroupTypesTableAdapter                 = new GroupTypesTableAdapter();
     m_adapterManager.GroupTypesTableAdapter.Connection      = m_connection;
     m_adapterManager.MarksTableAdapter                      = new MarksTableAdapter();
     m_adapterManager.MarksTableAdapter.Connection           = m_connection;
     m_adapterManager.MarkTypesTableAdapter                  = new MarkTypesTableAdapter();
     m_adapterManager.MarkTypesTableAdapter.Connection       = m_connection;
     m_adapterManager.PlansTableAdapter                      = new PlansTableAdapter();
     m_adapterManager.PlansTableAdapter.Connection           = m_connection;
     m_adapterManager.SemestersLengthTableAdapter            = new SemestersLengthTableAdapter();
     m_adapterManager.SemestersLengthTableAdapter.Connection = m_connection;
     m_adapterManager.SemestersTableAdapter                  = new SemestersTableAdapter();
     m_adapterManager.SemestersTableAdapter.Connection       = m_connection;
     m_adapterManager.SkipsTableAdapter                      = new SkipsTableAdapter();
     m_adapterManager.SkipsTableAdapter.Connection           = m_connection;
     m_adapterManager.StudentsTableAdapter                   = new StudentsTableAdapter();
     m_adapterManager.StudentsTableAdapter.Connection        = m_connection;
     m_adapterManager.SubjectsTableAdapter                   = new SubjectsTableAdapter();
     m_adapterManager.SubjectsTableAdapter.Connection        = m_connection;
     m_adapterManager.SubjectTypesTableAdapter               = new SubjectTypesTableAdapter();
     m_adapterManager.SubjectTypesTableAdapter.Connection    = m_connection;
 }
Beispiel #7
0
        public RecordIds(DbBase db, HluDataSet hluDataset,
                         TableAdapterManager hluTableAdapterMgr, ViewModelWindowMain.GeometryTypes gisLayerType)
        {
            if (db == null)
            {
                throw new ArgumentException("db");
            }
            if (hluDataset == null)
            {
                throw new ArgumentException("hluDataset");
            }
            if (hluTableAdapterMgr == null)
            {
                throw new ArgumentException("hluTableAdapterMgr");
            }

            _db                 = db;
            _hluDataset         = hluDataset;
            _hluTableAdapterMgr = hluTableAdapterMgr;
            _gisLayerType       = gisLayerType;
            if (_hluDataset.lut_last_incid.IsInitialized && _hluDataset.lut_last_incid.Count == 0)
            {
                if (_hluTableAdapterMgr.lut_last_incidTableAdapter == null)
                {
                    _hluTableAdapterMgr.lut_last_incidTableAdapter =
                        new HluTableAdapter <HluDataSet.lut_last_incidDataTable, HluDataSet.lut_last_incidRow>(_db);
                }
                _hluTableAdapterMgr.Fill(_hluDataset,
                                         new Type[] { typeof(HluDataSet.lut_last_incidDataTable) }, false);
            }
            _incidCurrentNumber = CurrentMaxIncidNumber(false);
            InitializeIncidChildRecordIds();
        }
Beispiel #8
0
        public async Task InsertCandidatesAsync(IEnumerable <CandidateModel> candidates)
        {
            await Task.CompletedTask;

            using (var dataSet = new StudentElectionDataSet())
            {
                using (var manager = new TableAdapterManager())
                {
                    manager.CandidateTableAdapter = new CandidateTableAdapter();

                    var id = -1;
                    foreach (var candidate in candidates)
                    {
                        var newRow = dataSet.Candidate.NewCandidateRow();
                        _mapper.Map(candidate, newRow);

                        newRow.ID = id;
                        if (candidate.Birthdate == null)
                        {
                            newRow.SetBirthdateNull();
                        }

                        dataSet.Candidate.AddCandidateRow(newRow);

                        id--;
                    }

                    manager.UpdateAll(dataSet);
                }
            }
        }
Beispiel #9
0
        protected bool Save()
        {
            try
            {
                BindingSource.EndEdit();
                TableAdapterManager.UpdateAll(DbDataSet);

                AddNewButton.Enabled = true;

                return(true);
            }
            catch (SqlException e)
            {
                if (e.Message.StartsWith("The DELETE statement conflicted with the REFERENCE constraint"))
                {
                    MessageBox.Show("You have removed an item which is referenced by other items.\r\nThis action jeopardizes data itegrity, so your changes will be reverted.", "An error has occured.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    LoadData();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "An error has occured.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(false);
        }
Beispiel #10
0
 public DataSetAdapter()
 {
     this.manager = new TableAdapterManager
     {
         StatesTableAdapter = new StatesTableAdapter()
     };
 }
        /// <summary>
        /// No conversion is done here, but a list of all Expressions is returned.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns>Expressions</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                _TAM = new TableAdapterManager();
                _DataSet = new TrainingDataSet();
                _TAM.ExpressionTableAdapter = new ExpressionTableAdapter();

                _TAM.ExpressionTableAdapter.Fill(_DataSet.Expression);

                return _DataSet.Expression;
                
                //TableAdapterManager _TAM = new TableAdapterManager();
                //TrainingDataSet _DataSet = new TrainingDataSet();
                //_TAM.ExpressionTableAdapter = new ExpressionTableAdapter();

                //_TAM.ExpressionTableAdapter.Fill(_DataSet.Expression);               

                //ArrayList expressions = new ArrayList();

                //for (int i=0; i<_DataSet.Expression.Count; i++)
                //{
                //    expressions.Add(_DataSet.Expression[i].Expression);
                //}

                //return expressions;
            }
            catch (NullReferenceException)
            {
                return null;
            }
        }
        public DatabaseModule()
        {
            db = new RecordsDataSet();
            dbmgr = new TableAdapterManager();
            qadp = new QueriesTableAdapter();

            //Initialize Adapters for Reference Tables
            dbmgr.ClientTableAdapter = new ClientTableAdapter();
            dbmgr.ItemTableAdapter = new ItemTableAdapter();
            dbmgr.WarehouseTableAdapter = new WarehouseTableAdapter();

            //Initialize Adapters for Transaction Tables
            dbmgr.ItemInventoryTableAdapter = new ItemInventoryTableAdapter();
            dbmgr.ReturnsInventoryTableAdapter = new ReturnsInventoryTableAdapter();
            
            dbmgr.ItemReturnedTableAdapter = new ItemReturnedTableAdapter();

            dbmgr.InvoiceTableAdapter = new InvoiceTableAdapter();
            dbmgr.InvoiceItemTableAdapter = new InvoiceItemTableAdapter();

            dbmgr.InventoryMovementTableAdapter = new InventoryMovementTableAdapter();
            dbmgr.ItemServedTableAdapter = new ItemServedTableAdapter();

            dbmgr.ItemReturnedTableAdapter = new ItemReturnedTableAdapter();
            dbmgr.ReturnServedTableAdapter = new ReturnServedTableAdapter();
        }        
        protected void Button1_Click(object sender, EventArgs e)
        {
            tb_userTableAdapter u2 = new tb_userTableAdapter();

            u2.ScalarQuery();
            TableAdapterManager u = new TableAdapterManager();
            //  u.
        }
Beispiel #14
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            TableAdapterManager tt    = new TableAdapterManager();
            DataTable           table = new DataTable();

            tt.Fill(table, cbDiemDi.SelectedValue.ToString(), cbDiemDen.SelectedValue.ToString(), dtpNgayDi.Value, cbLoaiVe.Text);
            dataGridView1.DataSource = table;
        }
        public SignaturesGuessForm(IGuessSignature guess, TableAdapterManager table_adapter, List<SignatureCounterDataSet.SignatureRow> target)
        {
            InitializeComponent();

            this.guess = guess;
            this.tables = table_adapter;
            this.target_signature = target;
        }
 public void ConnectionTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     IDbConnection expected = null; // TODO: Initialize to an appropriate value
     IDbConnection actual;
     target.Connection = expected;
     actual = target.Connection;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void BackupDataSetBeforeUpdateTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     target.BackupDataSetBeforeUpdate = expected;
     actual = target.BackupDataSetBeforeUpdate;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void car_madeTableAdapterTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     car_madeTableAdapter expected = null; // TODO: Initialize to an appropriate value
     car_madeTableAdapter actual;
     target.car_madeTableAdapter = expected;
     actual = target.car_madeTableAdapter;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        private void button1_Click(object sender, EventArgs e)
        {
            TableAdapterManager temp = new TableAdapterManager();

            temp.Connection = new SqlConnection("Data Source=DESKTOP-PA5M2I4\\SQLEXPRESS;Initial Catalog=KRBD_Restaraunt;Integrated Security=True");
            this.dishTableAdapter.Adapter.Update(this.kRBD_RestarauntDataSet.Rabotniki);
            this.Validate();
            this.dishBindingSource.EndEdit();
            temp.UpdateAll(kRBD_RestarauntDataSet);
        }
Beispiel #20
0
        /// <summary>
        ///  Initialisiert das DataSet und den TableAdapterManager.
        /// </summary>
        public static void Initialize()
        {
            DataSet = new AktienSimulatorDataSet();

            TableAdapterManager = new TableAdapterManager();
            TableAdapterManager.AccountTableAdapter = new AccountTableAdapter();
            TableAdapterManager.AktieTableAdapter   = new AktieTableAdapter();
            TableAdapterManager.DepotTableAdapter   = new DepotTableAdapter();
            TableAdapterManager.EventTableAdapter   = new EventTableAdapter();
            TableAdapterManager.KreditTableAdapter  = new KreditTableAdapter();
        }
Beispiel #21
0
        private LoadDeck()
        {
            _listcard = new LinkedList<Card>();
            this.dataset = new CardSourceDataSet();
            this.adapterManager = new TableAdapterManager();
            this.deckInfoTableAdapter = new DeckInfoTableAdapter();
            this.dataSourceTableAdapter = new DataSourceTableAdapter();

            this.adapterManager.DeckInfoTableAdapter = this.deckInfoTableAdapter;
            this.adapterManager.DataSourceTableAdapter = this.dataSourceTableAdapter;
            this.deckInfoTableAdapter.Fill(dataset.DeckInfo);
            this.dataSourceTableAdapter.Fill(dataset.DataSource);
        }
Beispiel #22
0
        private LoadDeck()
        {
            _listcard                   = new LinkedList <Card>();
            this.dataset                = new CardSourceDataSet();
            this.adapterManager         = new TableAdapterManager();
            this.deckInfoTableAdapter   = new DeckInfoTableAdapter();
            this.dataSourceTableAdapter = new DataSourceTableAdapter();

            this.adapterManager.DeckInfoTableAdapter   = this.deckInfoTableAdapter;
            this.adapterManager.DataSourceTableAdapter = this.dataSourceTableAdapter;
            this.deckInfoTableAdapter.Fill(dataset.DeckInfo);
            this.dataSourceTableAdapter.Fill(dataset.DataSource);
        }
Beispiel #23
0
        private void fillDataset()
        {
            //inicialitzar el dataset
            ds = new DataSetOracle();
            tableAdatpterMan = new TableAdapterManager();

            //omplir datatables/tableadapters,...
            #region datatables

            provTabAd = new DataSetOracleTableAdapters.PROVINCIESTableAdapter();
            provTabAd.Fill(ds.PROVINCIES);
            tableAdatpterMan.PROVINCIESTableAdapter = provTabAd;
            provincies = ds.PROVINCIES;

            munTabAd = new DataSetOracleTableAdapters.MUNICIPISTableAdapter();
            munTabAd.Fill(ds.MUNICIPIS);
            tableAdatpterMan.MUNICIPISTableAdapter = munTabAd;
            municipis = ds.MUNICIPIS;

            artTabAd = new DataSetOracleTableAdapters.ARTICLESTableAdapter();
            artTabAd.Fill(ds.ARTICLES);
            tableAdatpterMan.ARTICLESTableAdapter = artTabAd;
            articles = ds.ARTICLES;

            cliTabAd = new DataSetOracleTableAdapters.CLIENTSTableAdapter();
            cliTabAd.Fill(ds.CLIENTS);
            tableAdatpterMan.CLIENTSTableAdapter = cliTabAd;
            clients = ds.CLIENTS;

            cabTabAd = new DataSetOracleTableAdapters.CABALBARATableAdapter();
            cabTabAd.Fill(ds.CABALBARA);
            tableAdatpterMan.CABALBARATableAdapter = cabTabAd;
            cabalbara = ds.CABALBARA;

            cabFactTabAd = new DataSetOracleTableAdapters.CABFACTURASTableAdapter();
            cabFactTabAd.Fill(ds.CABFACTURAS);
            tableAdatpterMan.CABFACTURASTableAdapter = cabFactTabAd;
            cabfact = ds.CABFACTURAS;

            linAlbTabAd = new DataSetOracleTableAdapters.LINEASALBARATableAdapter();
            linAlbTabAd.Fill(ds.LINEASALBARA);
            tableAdatpterMan.LINEASALBARATableAdapter = linAlbTabAd;
            lineasalbara = ds.LINEASALBARA;

            linFactTabAd = new DataSetOracleTableAdapters.LINEASFACTURATableAdapter();
            linFactTabAd.Fill(ds.LINEASFACTURA);
            tableAdatpterMan.LINEASFACTURATableAdapter = linFactTabAd;
            lineasfact = ds.LINEASFACTURA;
            #endregion
        }
Beispiel #24
0
 public bool SaveNotes(DsInventory.NOTESMASTDataTable notesmastDataTable)
 {
     bool saved = false;
     if (!notesmastDataTable.HasErrors)
     {
         var manager = new TableAdapterManager
                           {   Connection = {ConnectionString = _constr},
                               NOTESMASTTableAdapter = new NOTESMASTTableAdapter(),
                               BackupDataSetBeforeUpdate = true
                           };
         saved = manager.NOTESMASTTableAdapter.Update(notesmastDataTable) > 0;
     }
     return saved;
 }
Beispiel #25
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                TableAdapterManager tam     = new TableAdapterManager();
                TrainingDataSet     dataSet = new TrainingDataSet();
                tam.ExpressionTableAdapter = new ExpressionTableAdapter();

                tam.ExpressionTableAdapter.Fill(dataSet.Expression);

                return(dataSet.Expression.FindByExpressionOID(System.Convert.ToInt32(value)).Expression);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                TableAdapterManager tam = new TableAdapterManager();
                TrainingDataSet dataSet = new TrainingDataSet();
                tam.ExpressionTableAdapter = new ExpressionTableAdapter();

                tam.ExpressionTableAdapter.Fill(dataSet.Expression);               

                return dataSet.Expression.FindByExpressionOID(System.Convert.ToInt32(value)).Expression;
            }
            catch (NullReferenceException)
            {
                return null;
            }
        }
Beispiel #27
0
        private CardSource()
        {
            cardSource = new CardSourceDataSet();
            adapterManager = new TableAdapterManager();
            dataSourceAdapter = new DataSourceTableAdapter();
            monsterSourceAdapter = new MonsterTableAdapter();
            trapSourceAdapter = new TrapTableAdapter();
            spellSourceAdapter = new SpellTableAdapter();

            adapterManager.DataSourceTableAdapter = this.dataSourceAdapter;
            adapterManager.MonsterTableAdapter = this.monsterSourceAdapter;

            dataSourceAdapter.Fill(cardSource.DataSource);
            monsterSourceAdapter.Fill(cardSource.Monster);
            trapSourceAdapter.Fill(cardSource.Trap);
            spellSourceAdapter.Fill(cardSource.Spell);
        }
Beispiel #28
0
        public void GetLayers(string groupName)
        {
            var query = "SELECT ti.* FROM sys_scheme.table_info ti " +
                        "LEFT JOIN inf_region.sys_scheme.table_groups_table tb ON ti.id = tb.id_table " +
                        "LEFT JOIN inf_region.sys_scheme.table_groups gr ON tb.id_group = gr.id " +
                        "WHERE gr.name_group = '@groupName' " +
                        "ORDER BY tb.order_num";

            using (var cmd = new NpgsqlCommand(query, _connection))
            {
                cmd.Parameters.AddWithValue("groupName", groupName);
                var reader = cmd.ExecuteReader();
                //reader.
            }

            var tableAdapterManager = new TableAdapterManager();
        }
Beispiel #29
0
        private CardSource()
        {
            cardSource           = new CardSourceDataSet();
            adapterManager       = new TableAdapterManager();
            dataSourceAdapter    = new DataSourceTableAdapter();
            monsterSourceAdapter = new MonsterTableAdapter();
            trapSourceAdapter    = new TrapTableAdapter();
            spellSourceAdapter   = new SpellTableAdapter();

            adapterManager.DataSourceTableAdapter = this.dataSourceAdapter;
            adapterManager.MonsterTableAdapter    = this.monsterSourceAdapter;

            dataSourceAdapter.Fill(cardSource.DataSource);
            monsterSourceAdapter.Fill(cardSource.Monster);
            trapSourceAdapter.Fill(cardSource.Trap);
            spellSourceAdapter.Fill(cardSource.Spell);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                TableAdapterManager tam = new TableAdapterManager();
                TrainingDataSet dataSet = new TrainingDataSet();
                tam.ExpressionTableAdapter = new ExpressionTableAdapter();

                tam.ExpressionTableAdapter.Fill(dataSet.Expression);

                int eoid = System.Convert.ToInt32(value);

                if (!DBNull.Value.Equals(eoid))
                {
                    TrainingDataSet.ExpressionRow row = dataSet.Expression.FindByExpressionOID(eoid);

                    if (!DBNull.Value.Equals(row) && !DBNull.Value.Equals(row.Thumbnail))
                    {
                        byte[] imageData = row.Thumbnail;

                        if (imageData != null && !DBNull.Value.Equals(imageData))
                        {
                            byte[] data = (byte[])value;
                            MemoryStream ms = new MemoryStream(data);

                            BitmapImage image = new BitmapImage();
                            image.BeginInit();
                            image.StreamSource = ms;
                            image.EndInit();

                            return image;
                        }
                    }
                }

                return null;
            }
            catch (NullReferenceException)
            {
                return null;
            }
            catch (System.Data.StrongTypingException)
            {
                return null;
            }
        }
Beispiel #31
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                TableAdapterManager tam     = new TableAdapterManager();
                TrainingDataSet     dataSet = new TrainingDataSet();
                tam.ExpressionTableAdapter = new ExpressionTableAdapter();

                tam.ExpressionTableAdapter.Fill(dataSet.Expression);

                int eoid = System.Convert.ToInt32(value);

                if (!DBNull.Value.Equals(eoid))
                {
                    TrainingDataSet.ExpressionRow row = dataSet.Expression.FindByExpressionOID(eoid);

                    if (!DBNull.Value.Equals(row) && !DBNull.Value.Equals(row.Thumbnail))
                    {
                        byte[] imageData = row.Thumbnail;

                        if (imageData != null && !DBNull.Value.Equals(imageData))
                        {
                            byte[]       data = (byte[])value;
                            MemoryStream ms   = new MemoryStream(data);

                            BitmapImage image = new BitmapImage();
                            image.BeginInit();
                            image.StreamSource = ms;
                            image.EndInit();

                            return(image);
                        }
                    }
                }

                return(null);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
            catch (System.Data.StrongTypingException)
            {
                return(null);
            }
        }
Beispiel #32
0
        private void button1_Click(object sender, EventArgs e)
        {
            aptekaTableAdapter  Tableadapter1 = new БанкиTableAdapter();
            TableAdapterManager Manager1      = new TableAdapterManager();

            Tableadapter1.Insert(textBox1.Text, textBox3.Text, int.Parse(textBox2.Text));
            try
            {
                MessageBox.Show("Банк успешно добавлен");
            }
            catch (SqlException)
            {
                MessageBox.Show("Не удалось сделать заполнение");
            }
            Manager1.UpdateAll(this.Dataset1);
            Manager1.Connection.Close();
        }
Beispiel #33
0
        private void button1_Click(object sender, EventArgs e)
        {
            installconnection   installconnection1 = new installconnection();
            TableAdapterManager Manager7           = new TableAdapterManager();
            string        dbLocation2 = Path.GetFullPath(installconnection1.connection);
            SqlConnection connection3 = new SqlConnection
                                        (
                installconnection1.connection1 + @dbLocation2
                                        );
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "Delete ";
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                cmd.CommandText += "from apteka where id_cl = " + textBox1.Text;
                break;

            case 1:
                cmd.CommandText += "from zavod where id_post = " + textBox1.Text;
                break;

            case 2:
                cmd.CommandText += "from postavka where id_part = " + textBox1.Text;
                break;

            case 3:
                cmd.CommandText += "from prodaza where id_otgr = " + textBox1.Text;
                break;
            }
            cmd.Connection = connection3;
            connection3.Open();
            label2.Text = cmd.CommandText;
            cmd.ExecuteNonQuery();
            connection3.Close();
            try
            {
                MessageBox.Show("Запись удалена");
            }
            catch (SqlException)
            {
                MessageBox.Show("Не удалось удалить запись");
            }
        }
        public async Task SwitchRankAsync(PositionModel selectedPosition, PositionModel closestPosition)
        {
            await Task.CompletedTask;

            using (var manager = new TableAdapterManager())
            {
                manager.PositionTableAdapter = new PositionTableAdapter();

                manager.PositionTableAdapter.UpdateRankQuery(
                    selectedPosition.Rank,
                    closestPosition.Id
                    );

                manager.PositionTableAdapter.UpdateRankQuery(
                    closestPosition.Rank,
                    selectedPosition.Id
                    );
            }
        }
Beispiel #35
0
        /// <summary>
        /// Create a new instance of the NyMPH Database class to wrap the persistence layer
        /// </summary>
        public Database()
        {
            //init data objects
            _ds = new DSNyMPH();

            SqlCeConnection _conn = new SqlCeConnection(this.ConnectionString);

            _tam = new TableAdapterManager();

//            _tam.Connection = _conn;

            _tam.tbKeywordRelationshipsTableAdapter = new tbKeywordRelationshipsTableAdapter();
            _tam.tbKeywordRelationshipsTableAdapter.Fill(_ds.tbKeywordRelationships);

            _tam.tbKeywordsInPatchTableAdapter = new tbKeywordsInPatchTableAdapter();
            _ds.EnforceConstraints             = false;

            _tam.tbKeywordsInPatchTableAdapter.Fill(_ds.tbKeywordsInPatch);
            // _ds.EnforceConstraints = true;

            _tam.tbKeywordTableAdapter = new tbKeywordTableAdapter();
            _tam.tbKeywordTableAdapter.Fill(_ds.tbKeyword);

            _tam.tbPatchBanksTableAdapter = new tbPatchBanksTableAdapter();
            _tam.tbPatchBanksTableAdapter.Fill(_ds.tbPatchBanks);

            _tam.tbPatchDataTableAdapter = new tbPatchDataTableAdapter();
            _tam.tbPatchDataTableAdapter.FillLight(_ds.tbPatchData);

            _tam.tbPatchDataVersionsTableAdapter = new tbPatchDataVersionsTableAdapter();
            _tam.tbPatchDataVersionsTableAdapter.Fill(_ds.tbPatchDataVersions);

            _tam.tbPatchesInBankTableAdapter = new tbPatchesInBankTableAdapter();
            _tam.tbPatchesInBankTableAdapter.Fill(_ds.tbPatchesInBank);

            _tam.tbPatchesTableAdapter = new tbPatchesTableAdapter();
            _tam.tbPatchesTableAdapter.Fill(_ds.tbPatches);


            KeywordDAL = new KeywordDataHelper(this.NyMPHTableAdapterManager.tbKeywordTableAdapter);
        }
Beispiel #36
0
        private void btnCatsFillLocal_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string connectionPrefix = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
            string client           = new Uri(dmc.origUrl).Host;
            string filename         = client + ".mdb";
            string app_data         = Path.GetDirectoryName(Application.ExecutablePath) + @"\App_data\";
            string dest             = app_data + filename;

            if (!File.Exists(dest))
            {
                File.Copy(app_data + "LocalCats.mdb", dest);
            }
            string connection = connectionPrefix + dest;

            using (TableAdapterManager tam = new TableAdapterManager())
            {
                OleDbConnection myConn = new OleDbConnection(connection);
                tam.Connection           = myConn;
                tam.CategoryTableAdapter = new CategoryTableAdapter(myConn);
                tam.CategoryTableAdapter.ClearBeforeFill = true;
                tam.clientTableAdapter = new clientTableAdapter(myConn);
                tam.clientTableAdapter.ClearBeforeFill = true;
                LocalCats myCats = new LocalCats();
                tam.clientTableAdapter.Fill(myCats.client);
                tam.CategoryTableAdapter.Fill(myCats.Category);
                if (myCats.client == null || myCats.client.Rows.Count == 0)
                {
                    DataRow dr = myCats.client.NewRow();
                    dr["cmsurl"] = client;
                    myCats.client.Rows.Add(dr);
                }
                DataTableReader dtr = myCats.CreateDataReader(cats);
                myCats.Load(dtr, LoadOption.Upsert, myCats.Category, myCats.client);
                tam.UpdateAll(myCats);
            }
            Cursor.Current = Cursors.Default;
            return;
        }
        public async Task InsertElectionAsync(ElectionModel model)
        {
            await Task.CompletedTask;

            using (var dataSet = new StudentElectionDataSet())
            {
                using (var manager = new TableAdapterManager())
                {
                    manager.ElectionTableAdapter = new ElectionTableAdapter();

                    var newRow = dataSet.Election.NewElectionRow();
                    _mapper.Map(model, newRow);
                    newRow.ID = -1;
                    newRow.SetCandidatesFinalizedAtNull();
                    newRow.SetClosedAtNull();

                    dataSet.Election.AddElectionRow(newRow);

                    manager.UpdateAll(dataSet);
                }
            }
        }
        /// <summary>
        /// The main entry point for this window.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            Console.WriteLine("Loc: " + System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                _CurrentImagePathIndex = 0;
                _ImagePathArray        = new ArrayList();
                _ProcessOptions        = new ProcessOptions();
                _FFP = new FaceFeaturePoints();

                _ProcessOptions.DoEyeProcessing          = 1;
                _ProcessOptions.DoMouthProcessing        = 1;
                _ProcessOptions.DrawAnthropometricPoints = 0;
                _ProcessOptions.DrawSearchRectangles     = 0;
                _ProcessOptions.DrawFaceRectangle        = 1;
                _ProcessOptions.DrawDetectionTime        = 1;
                _ProcessOptions.DrawFeaturePoints        = 1;
                _ProcessOptions.DoVisualDebug            = 0;

                #region Intialize encapsulated OpenCV subsystem
                _KLU        = new Klu();
                _TempBitmap = new System.Drawing.Bitmap(10, 10);

                // Create a Timer with a Normal Priority
                _CaptureTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Dispatcher);

                // Set the callback to just show the time ticking away
                // NOTE: We are using a control so this has to run on
                // the UI thread
                _CaptureTimer.Tick += new EventHandler(
                    delegate(object s, EventArgs a)
                {
                    _KLU.ProcessCaptureImage(ref _ProcessOptions, ref _FFP);

                    // Ensure the image (bitmap) we are writing to has the correct dimensions
                    int width = 0, height = 0;
                    _KLU.GetLastProcessedImageDims(ref width, ref height);

                    if (_TempBitmap.Width != width || _TempBitmap.Height != height)
                    {
                        Console.WriteLine("Need to resize the _TempBitmap to " + width + "x" + height);
                        _TempBitmap.Dispose();
                        GC.Collect();
                        _TempBitmap = new System.Drawing.Bitmap(width, height);
                    }

                    _KLU.GetLastProcessedImage(ref _TempBitmap);
                    _KLU.SetWpfImageFromBitmap(ref image1, ref _TempBitmap);
                    //_KLU.SetImageBrushFromBitmap(ref imageBrush, ref _TempBitmap);
                }
                    );
                #endregion

                #region "Connect" to database
                _TAM     = new TableAdapterManager();
                _DataSet = new TrainingDataSet();

                // Load data from SQL database and fill our DataSet
                _TAM.ExpressionTableAdapter = new ExpressionTableAdapter();
                _TAM.TrainingTableAdapter   = new TrainingTableAdapter();

                LoadData();
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 void SetupTables()
 {
     tables = new TableAdapterManager()
     {
         ImageFileTableAdapter = new ImageFileTableAdapter(),
         TypeTableAdapter = new TypeTableAdapter(),
         SignatureTableAdapter = new SignatureTableAdapter(),
         SignatoryTableAdapter = new SignatoryTableAdapter(),
         TrimTableAdapter = new TrimTableAdapter(),
         MatchingTableAdapter = new MatchingTableAdapter(),
     };
     tables.ImageFileTableAdapter.Fill(signatureCounterDataSet1.ImageFile);
 }
        /// <summary>
        /// The main entry point for this window.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            Console.WriteLine("Loc: " + System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                _CurrentImagePathIndex = 0;
                _ImagePathArray = new ArrayList();
                _ProcessOptions = new ProcessOptions();
                _FFP = new FaceFeaturePoints();

                _ProcessOptions.DoEyeProcessing = 1;
                _ProcessOptions.DoMouthProcessing = 1;
                _ProcessOptions.DrawAnthropometricPoints = 0;
                _ProcessOptions.DrawSearchRectangles = 0;
                _ProcessOptions.DrawFaceRectangle = 1;
                _ProcessOptions.DrawDetectionTime = 1;
                _ProcessOptions.DrawFeaturePoints = 1;
                _ProcessOptions.DoVisualDebug = 0;

                #region Intialize encapsulated OpenCV subsystem
                _KLU = new Klu();
                _TempBitmap = new System.Drawing.Bitmap(10, 10);

                // Create a Timer with a Normal Priority
                _CaptureTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Dispatcher);
                
                // Set the callback to just show the time ticking away
                // NOTE: We are using a control so this has to run on 
                // the UI thread
                _CaptureTimer.Tick += new EventHandler(
                    delegate(object s, EventArgs a)
                    {
                        _KLU.ProcessCaptureImage(ref _ProcessOptions, ref _FFP);

                        // Ensure the image (bitmap) we are writing to has the correct dimensions
                        int width = 0, height = 0;
                        _KLU.GetLastProcessedImageDims(ref width, ref height);

                        if (_TempBitmap.Width != width || _TempBitmap.Height != height)
                        {
                            Console.WriteLine("Need to resize the _TempBitmap to " + width + "x" + height);
                            _TempBitmap.Dispose();
                            GC.Collect();
                            _TempBitmap = new System.Drawing.Bitmap(width, height);
                        }

                        _KLU.GetLastProcessedImage(ref _TempBitmap);
                        _KLU.SetWpfImageFromBitmap(ref image1, ref _TempBitmap);
                        //_KLU.SetImageBrushFromBitmap(ref imageBrush, ref _TempBitmap);
                    }
                );
                #endregion

                #region "Connect" to database
                _TAM = new TableAdapterManager();  
                _DataSet = new TrainingDataSet();

                // Load data from SQL database and fill our DataSet
                _TAM.ExpressionTableAdapter = new ExpressionTableAdapter();
                _TAM.TrainingTableAdapter = new TrainingTableAdapter();

                LoadData();
                #endregion
            }            
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void TableAdapterInstanceCountTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     int actual;
     actual = target.TableAdapterInstanceCount;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #42
0
        protected string SaveInvestorPermRecord(int invAppId)
        {
            StringBuilder validationErrorSB       = new StringBuilder();
            bool          IsOtherApplicantPresent = false;


            InvestorDS ds = new InvestorDS();

            InvestorDS.InvestorApplicationsDataTable invAppDT = ds.InvestorApplications;
            InvestorDS.InvestorDataTable             invDT    = ds.Investor;



            InvestorApplicationsTableAdapter invAppTA = new DataUtils.InvestorDSTableAdapters.InvestorApplicationsTableAdapter();

            try
            {
                invAppTA.FillById(invAppDT, invAppId);
                //GetDataById(invAppId);
            }
            catch (System.Data.ConstraintException constrExc)
            {
                System.Data.DataRow[] rowsErr = invAppDT.GetErrors();
                for (int i = 0; i < rowsErr.Length; i++)
                {
                    if (rowsErr[i].HasErrors)
                    {
                        string err = rowsErr[i].RowError;
                        if (!String.IsNullOrWhiteSpace(err))
                        {
                            validationErrorSB.AppendLine(err);
                            return(validationErrorSB.ToString());
                        }
                    }
                }
            }


            if (invAppDT.Rows.Count != 1)
            {
                throw new ArgumentException(String.Concat("InvestorApplication with Id ", invAppId, " could not be found."), "InvestorApplication.Id");
            }

            DataUtils.InvestorDS.InvestorApplicationsRow currentInvAppRow = invAppDT.Rows[0] as InvestorDS.InvestorApplicationsRow;

            InvestorDS.InvestorRow invRow    = invDT.NewInvestorRow();
            InvestorDS.InvestorRow othinvRow = null;

            InvestorTableAdapter invTA  = new InvestorTableAdapter();
            PropertyTableAdapter prtyTA = new PropertyTableAdapter();


            TableAdapterManager tam = new TableAdapterManager();

            //tam.InvestorApplicationsTableAdapter = ;
            tam.PropertyTableAdapter = prtyTA;
            tam.InvestorTableAdapter = invTA;

            tam.UpdateOrder = TableAdapterManager.UpdateOrderOption.InsertUpdateDelete;


            //InvestorTableAdapter invTA = new InvestorTableAdapter();

            //if (currentInvAppRow.IsPrimary_FirstNameNull() || String.IsNullOrEmpty(currentInvAppRow.Primary_FirstName))
            //{
            //    validationErrorSB.AppendLine("Primary Applicant's First name is empty");
            //}

            invRow.InvestorApplicationId = currentInvAppRow.Id;
            if (!currentInvAppRow.IsOther_LastNameNull() && !String.IsNullOrWhiteSpace(currentInvAppRow.Other_LastName))
            {
                IsOtherApplicantPresent = true;
            }

            #region PrimaryInvestor
            //invRow.Id = -1;

            if (currentInvAppRow.IsPrimary_FirstNameNull())
            {
                invRow.FirstName = null;
            }
            else
            {
                invRow.FirstName = currentInvAppRow.Primary_FirstName.Trim();
            }


            if (currentInvAppRow.IsPrimary_OtherNamesNull())
            {
                invRow.OtherNames = null;
            }
            else
            {
                invRow.OtherNames = currentInvAppRow.Primary_OtherNames.Trim();
            }

            if (currentInvAppRow.IsPrimary_LastNameNull() || String.IsNullOrEmpty(currentInvAppRow.Primary_LastName))
            {
                validationErrorSB.AppendLine("Primary Applicant's Last name is empty");
            }
            else
            {
                invRow.LastName = currentInvAppRow.Primary_LastName.Trim();
            }

            if (currentInvAppRow.IsPrimary_DOBNull() || currentInvAppRow.Primary_DOB < DateTime.Today.AddYears(-100))
            {
                validationErrorSB.AppendLine("Primary Applicant's DOB is empty or invalid");
            }
            else
            {
                invRow.DOB = currentInvAppRow.Primary_DOB;
            }


            if (currentInvAppRow.IsPrimary_LastNameNull())
            {
                validationErrorSB.AppendLine("Primary Applicant's Last Name is empty or invalid");
            }
            else
            {
                invRow.LastName = currentInvAppRow.Primary_LastName.Trim();
            }

            if (currentInvAppRow.IsEmailNull() || String.IsNullOrWhiteSpace(currentInvAppRow.Email))
            {
                validationErrorSB.AppendLine("Primary Applicant's Email address is empty or invalid");
            }
            else
            {
                invRow.Email = currentInvAppRow.Email;
            }


            currentInvAppRow.Other_Email = null;

            //invRow.Gender =
            if (String.IsNullOrWhiteSpace(currentInvAppRow.Primary_Gender))
            {
                validationErrorSB.AppendLine("");
            }
            else
            {
                string gender = currentInvAppRow.Primary_Gender.Trim();

                if (gender.StartsWith("m", StringComparison.InvariantCultureIgnoreCase))
                {
                    invRow.Gender = 'M';
                }
                else if (gender.StartsWith("f", StringComparison.InvariantCultureIgnoreCase))
                {
                    invRow.Gender = 'F';
                }
                else
                {
                    invRow.Gender = 'O';
                }
            }


            if (currentInvAppRow.IsPrimary_Res_Street1Null() || String.IsNullOrWhiteSpace(currentInvAppRow.Primary_Res_Street1))
            {
                validationErrorSB.AppendLine("Primary Applicant's Street address is empty or invalid");
            }
            else
            {
                string unitKeyword    = "unit";
                string street1        = currentInvAppRow.Primary_Res_Street1;
                int    unitKeywdIndex = new CultureInfo("EN-AU").CompareInfo.IndexOf(street1, unitKeyword, CompareOptions.IgnoreCase);
                if (unitKeywdIndex > 0)
                {
                    string unitNo      = street1.Substring(unitKeywdIndex + unitKeyword.Length).TrimStart();
                    int    endOfUnitNo = unitNo.Length - unitNo.IndexOf(" ", StringComparison.InvariantCultureIgnoreCase);
                    unitNo = unitNo.Substring(0, endOfUnitNo);
                    if (!String.IsNullOrWhiteSpace(unitNo))
                    {
                        invRow.Res_UnitNum = unitNo;
                        invRow.Res_Street1 = street1.Substring(unitKeywdIndex + endOfUnitNo);
                    }
                    else
                    {
                        invRow.Res_Street1 = street1;
                    }
                }
                else
                {
                    invRow.Res_Street1 = currentInvAppRow.Primary_Res_Street1.Trim();
                }
            }

            if (String.IsNullOrWhiteSpace(currentInvAppRow.Primary_Res_Street2))
            {
                invRow.Res_Street2 = null;
            }
            else
            {
                invRow.Res_Street2 = currentInvAppRow.Primary_Res_Street2.Trim();
            }

            if (currentInvAppRow.IsPrimary_Res_PostCodeNull())
            {
                invRow.Res_Postcode = -1;
            }
            else
            {
                invRow.Res_Postcode = currentInvAppRow.Primary_Res_PostCode;
            }

            //  invRow.Res_Suburb = currentInvAppRow.Primary_Res

            if (currentInvAppRow.IsPrimary_Res_SuburbNull())
            {
                validationErrorSB.AppendLine("Primary current residence Suburb cannot be empty.");
                //invRow.Res_Suburb = null;
            }
            else
            {
                invRow.Res_Suburb = currentInvAppRow.Primary_Res_Suburb.Trim();
            }

            invRow.Res_City = null;

            if (currentInvAppRow.IsPrimary_Res_StateNull())
            {
                invRow.Res_State = null;
            }
            else
            {
                invRow.Res_State = currentInvAppRow.Primary_Res_State;
            }

            if (String.IsNullOrWhiteSpace(currentInvAppRow.Primary_Res_Country))
            {
                invRow.Res_Country = "Australia";
            }
            else
            {
                invRow.Res_Country = currentInvAppRow.Primary_Res_Country;
            }

            invRow.Res_Street3 = null;
            invRow.Res_Street4 = null;
            invRow.Res_Street5 = null;

            if (String.IsNullOrWhiteSpace(currentInvAppRow.Mobile))
            {
                invRow.PhoneMobile = null;
            }
            else
            {
                invRow.PhoneMobile = currentInvAppRow.Mobile.Trim();
            }


            if (currentInvAppRow.IsPrimary_HomePhoneNull())
            {
                invRow.PhoneHome = null;
            }
            else
            {
                invRow.PhoneHome = currentInvAppRow.Primary_HomePhone.Trim();
            }

            invRow.PhoneWork  = null;
            invRow.PhoneOther = null;

            invRow.Bill_Street1 = null;
            invRow.Bill_Street2 = null;
            invRow.Bill_Street3 = null;
            invRow.Bill_Street4 = null;
            invRow.Bill_Street5 = null;

            invRow.AssquireStatus = "New";
            invRow.AppliedDate    = currentInvAppRow.EntryDate;
            invRow.Created        = DateTime.Now;
            invRow.CreatedBy      = "pdvorak";

            invDT.AddInvestorRow(invRow);

            #endregion PrimaryInvestor

            #region PrimaryInvestorProperty

            // We will create property only if the details are provided and it must be confirmed
            //TODO
            bool hasProperty = true; //this.chckPrptyValFeePaid.Checked;
            InvestorDS.PropertyRow prptyNewR = null;
            // validate if property is included

            if (hasProperty)
            {
                //                InvestorDS.PropertyDataTable prptyDT = new InvestorDS.PropertyDataTable();

                AddPermPropertyFromInvAppRow(ds, currentInvAppRow, invRow);
            }

            #endregion PrimaryInvestorProperty

            #region OtherApplicant
            if (IsOtherApplicantPresent)
            {
                othinvRow = invDT.NewInvestorRow();


                othinvRow.PrimaryInvestorID = invRow.Id;
                //othinvRow.PrimaryInvestorID = invRow.Id;

                othinvRow.LastName = currentInvAppRow.Other_LastName;

                if (currentInvAppRow.IsOther_FirstNameNull())
                {
                    othinvRow = null;
                }
                else
                {
                    othinvRow.FirstName = currentInvAppRow.Other_FirstName;
                }

                if (currentInvAppRow.IsOther_OtherNamesNull())
                {
                    othinvRow.OtherNames = null;
                }
                else
                {
                    othinvRow.OtherNames = currentInvAppRow.Other_OtherNames.Trim();
                }


                if (currentInvAppRow.IsOther_DOBNull() || (currentInvAppRow.Other_DOB <= DateTime.Today.AddYears(-100)))
                {
                    validationErrorSB.AppendLine("Other Investor DOB cannot be null");
                }
                else
                {
                    othinvRow.DOB = currentInvAppRow.Other_DOB;
                }


                if (currentInvAppRow.IsOther_Res_Street1Null() || String.IsNullOrWhiteSpace(currentInvAppRow.Other_Res_Street1))
                {
                    validationErrorSB.AppendLine("Other Applicant's Street address is empty or invalid");
                }
                else
                {
                    string unitKeyword    = "unit";
                    string street1        = currentInvAppRow.Other_Res_Street1;
                    int    unitKeywdIndex = new CultureInfo("EN-AU").CompareInfo.IndexOf(street1, unitKeyword, CompareOptions.IgnoreCase);
                    if (unitKeywdIndex > 0)
                    {
                        string unitNo      = street1.Substring(unitKeywdIndex + unitKeyword.Length).TrimStart();
                        int    endOfUnitNo = unitNo.Length - unitNo.IndexOf(" ", StringComparison.InvariantCultureIgnoreCase);
                        unitNo = unitNo.Substring(0, endOfUnitNo);
                        if (!String.IsNullOrWhiteSpace(unitNo))
                        {
                            othinvRow.Res_UnitNum = unitNo;
                            othinvRow.Res_Street1 = street1.Substring(unitKeywdIndex + endOfUnitNo);
                        }
                        else
                        {
                            othinvRow.Res_Street1 = street1;
                        }
                    }
                    else
                    {
                        othinvRow.Res_Street1 = currentInvAppRow.Other_Res_Street1.Trim();
                    }
                }

                if (String.IsNullOrWhiteSpace(currentInvAppRow.Other_Res_Street2))
                {
                    othinvRow.Res_Street2 = null;
                }
                else
                {
                    othinvRow.Res_Street2 = currentInvAppRow.Other_Res_Street2.Trim();
                }

                if (currentInvAppRow.IsOther_Res_PostCodeNull())
                {
                    othinvRow.Res_Postcode = -1;
                }
                else
                {
                    othinvRow.Res_Postcode = currentInvAppRow.Other_Res_PostCode;
                }

                //  othinvRow.Res_Suburb = currentInvAppRow.Other_Res

                if (currentInvAppRow.IsOther_Res_SuburbNull())
                {
                    othinvRow.Res_Suburb = null;
                }
                else
                {
                    othinvRow.Res_Suburb = currentInvAppRow.Other_Res_Suburb.Trim();
                }

                othinvRow.Res_City = null;

                if (currentInvAppRow.IsOther_Res_StateNull())
                {
                    othinvRow.Res_State = null;
                }
                else
                {
                    othinvRow.Res_State = currentInvAppRow.Other_Res_State;
                }

                if (String.IsNullOrWhiteSpace(currentInvAppRow.Other_Res_Country))
                {
                    othinvRow.Res_Country = "Australia";
                }
                else
                {
                    othinvRow.Res_Country = currentInvAppRow.Other_Res_Country;
                }

                othinvRow.Res_Street3 = null;
                othinvRow.Res_Street4 = null;
                othinvRow.Res_Street5 = null;

                if (String.IsNullOrWhiteSpace(currentInvAppRow.Mobile))
                {
                    othinvRow.PhoneMobile = null;
                }
                else
                {
                    othinvRow.PhoneMobile = currentInvAppRow.Mobile.Trim();
                }


                if (currentInvAppRow.IsPrimary_HomePhoneNull())
                {
                    othinvRow.PhoneHome = null;
                }
                else
                {
                    othinvRow.PhoneHome = currentInvAppRow.Other_HomePhone.Trim();
                }

                othinvRow.PhoneWork  = null;
                othinvRow.PhoneOther = null;

                othinvRow.Bill_Street1 = null;
                othinvRow.Bill_Street2 = null;
                othinvRow.Bill_Street3 = null;
                othinvRow.Bill_Street4 = null;
                othinvRow.Bill_Street5 = null;

                othinvRow.InvestorApplicationId = currentInvAppRow.Id;

                othinvRow.AssquireStatus = "New";
                othinvRow.AppliedDate    = currentInvAppRow.EntryDate;
                othinvRow.Created        = DateTime.Now;
                othinvRow.CreatedBy      = "pdvorak";

                invDT.AddInvestorRow(othinvRow);
            }
            #endregion OtherApplicant


            if (validationErrorSB.Length > 0)
            {
                return(validationErrorSB.ToString());
            }
            else
            {
                //this.lblValidationErrorsTxtBoxLabel.Visible = false;
                //this.txtValidationErrors.Visible = false;
                //this.txtValidationErrors.Text = String.Empty();


                try
                {
                    //invTA.Update(invRow);
                    //invTA.Update(othinvRow);
                    //prtyTA.Update(prptyNewR);

                    //Inserts
                    tam.UpdateAll(ds);


                    //update relationships
                    bool refUpdate = false;
                    if (IsOtherApplicantPresent)
                    {
                        othinvRow.PrimaryInvestorID = invRow.Id;
                        refUpdate = true;
                    }

                    if (hasProperty)
                    {
                        //updates references
                        prptyNewR.PrimaryInvestorId = invRow.Id;
                        refUpdate = true;
                    }

                    if (refUpdate)
                    {
                        tam.UpdateAll(ds);
                    }
                }
                catch (SqlException se)
                {
                    return("Error adding new Investor(s): " + se.Message);
                }
            }

            return(null);
        }
 public void TableAdapterManagerConstructorTest()
 {
     TableAdapterManager target = new TableAdapterManager();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void UpdateAllTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     taxi_managementDataSet dataSet = null; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.UpdateAll(dataSet);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #45
0
 public SaveBs(User user, BindingSource bs, TableAdapterManager ta, EstateAgencyDataSet ds, int accessLevel) : base(user, bs, accessLevel)
 {
     this.ta = ta;
     this.ds = ds;
 }
 public void UpdateOrderTest()
 {
     TableAdapterManager target = new TableAdapterManager(); // TODO: Initialize to an appropriate value
     TableAdapterManager.UpdateOrderOption expected = new TableAdapterManager.UpdateOrderOption(); // TODO: Initialize to an appropriate value
     TableAdapterManager.UpdateOrderOption actual;
     target.UpdateOrder = expected;
     actual = target.UpdateOrder;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #47
0
        private void Form1_Load(object sender, EventArgs e)
        {
            BuildOrgStructureTree();

            //ADMethodsAccountManagement ADMethods = new ADMethodsAccountManagement();

            //UserPrincipal myUser = ADMethods.GetUser(@"druzhinin");

            //MessageBox.Show(myUser.GivenName + " " + myUser.EmailAddress);

            m_TableAdapterManager = new TableAdapterManager();
            m_TableAdapterManager.StaffTableAdapter = new StaffTableAdapter();
            m_TableAdapterManager.stfOrgStructureTableAdapter = new stfOrgStructureTableAdapter();
            m_TableAdapterManager.NewUserTableAdapter = new NewUserTableAdapter();

            m_CommonQuery = new QueriesTableAdapter();

            m_StaffTbl = new dsITO.StaffDataTable();
            m_NewUser = new dsITO.NewUserDataTable();
            m_TableAdapterManager.NewUserTableAdapter.Fill(m_NewUser);

            m_OrgStructure = new dsITO.stfOrgStructureDataTable();

            m_TableAdapterManager.StaffTableAdapter.Fill(m_StaffTbl);

            m_ITOSQLCommand = new ITODAL();

            m_ITOSQLCommand.OpenConnection("Data Source=10.15.140.2;Initial Catalog=ITO;Persist Security Info=True;User ID=evgeny;Password=ywfaggzu");

            //Заполняем ComboBox данными из базы

            //Должности
            DataTable dt = m_ITOSQLCommand.ExecuteSQLCommand("Select PositionID, Name from stfPositions");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString());
                cbPosition.Items.Add(le);

            }

            //Подразделения
            dt = m_ITOSQLCommand.ExecuteSQLCommand("Select DepartmentID, ShortName, Name from stfOrgStructure");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString() + " " + dt.Rows[curRow][2].ToString());
                cbDepartment.Items.Add(le);

            }

            //Здания
            dt = m_ITOSQLCommand.ExecuteSQLCommand("Select BuildingID, Name from stfBuildings");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString());
                cbWorkPlace.Items.Add(le);

            }

            dt = m_ITOSQLCommand.ExecuteSQLCommand("Select UserID,LastName,Name,SecondName from Staff");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                ListElement le = new ListElement(dt.Rows[curRow][0].ToString(), dt.Rows[curRow][1].ToString()+" "+dt.Rows[curRow][2].ToString()+" "+dt.Rows[curRow][3].ToString());
                cmbUser.Items.Add(le);

            }

            dt = m_ITOSQLCommand.ExecuteSQLCommand("Select distinct Place from Invent");

            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                cbPlace.Items.Add(dt.Rows[curRow][0].ToString());
            }

            dt = m_ITOSQLCommand.ExecuteSQLCommand("Select distinct Room from Invent");
            for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
            {
                cbRoom.Items.Add(dt.Rows[curRow][0].ToString());
            }
        }