Exemple #1
0
        private void Checkfordata(string itemnumber)
        {
            using (SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM [SPM_Database].[dbo].[Inventory] WHERE [ItemNumber]='" + itemnumber.ToString() + "'", _connection))
            {
                try
                {
                    _connection.Open();

                    int userCount = (int)sqlCommand.ExecuteScalar();
                    if (userCount > 0)
                    {
                        _connection.Close();
                        Filldatatable(iteminfo2);
                    }
                    else
                    {
                        //SPM_Connect sPM_Connect = new SPM_Connect();
                        SPMConnectAPI.SPMSQLCommands sPMSQLCommands = new SPMConnectAPI.SPMSQLCommands();
                        //sPMSQLCommands.SPM_Connect();
                        sPMSQLCommands.Addcpoieditemtosqltablefromgenius(iteminfo2, iteminfo2);
                        Filldatatable(iteminfo2);
                        //MessageBox.Show("Data not found on SPM Connect server.", "SPM Connect", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //this.Close();
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("Not Licensed User", "SPM Connect", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //Application.Exit();
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    _connection.Close();
                }
            }
        }