Beispiel #1
0
        private void Checkfordata(string itemnumber)
        {
            using (SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM [SPM_Database].[dbo].[Inventory] WHERE [ItemNumber]='" + itemnumber + "'", connectapi.cn))
            {
                try
                {
                    if (connectapi.cn.State == ConnectionState.Closed)
                    {
                        connectapi.cn.Open();
                    }

                    int userCount = (int)sqlCommand.ExecuteScalar();
                    if (userCount <= 0)
                    {
                        connectapi.Addcpoieditemtosqltablefromgenius(iteminfo2, iteminfo2);
                    }
                    connectapi.cn.Close();
                    Filldatatable(iteminfo2);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    connectapi.cn.Close();
                }
            }
        }
Beispiel #2
0
        private void Filldatatable(string itemnumber)
        {
            _acountsTb.Clear();
            string sql = "SELECT *  FROM [SPM_Database].[dbo].[Inventory] WHERE [ItemNumber]='" + itemnumber + "'";

            try
            {
                if (connectapi.cn.State == ConnectionState.Closed)
                {
                    connectapi.cn.Open();
                }
                SqlDataAdapter _adapter = new SqlDataAdapter(sql, connectapi.cn);
                _adapter?.Fill(_acountsTb);
                if (_acountsTb.Rows.Count > 0)
                {
                    Fillinfo();
                }
                else
                {
                    connectapi.Addcpoieditemtosqltablefromgenius(itemnumber, itemnumber);
                    Fillinfo();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "SPM Connect New Item - Fill Data Table", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                connectapi.cn.Close();
            }
        }
Beispiel #3
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();
                }
            }
        }